llvm-6502/lib/Transforms/Scalar
Jakob Stoklund Olesen 58e9ee85fd Teach SimplifyCFG about magic pointer constants.
Weird code sometimes uses pointer constants other than null. This patch
teaches SimplifyCFG to build switch instructions in those cases.

Code like this:

void f(const char *x) {
  if (!x)
    puts("null");
  else if ((uintptr_t)x == 1)
    puts("one");
  else if (x == (char*)2 || x == (char*)3)
    puts("two");
  else if ((intptr_t)x == 4)
    puts("four");
  else
    puts(x);
}

Now becomes a switch:

define void @f(i8* %x) nounwind ssp {
entry:
  %magicptr23 = ptrtoint i8* %x to i64            ; <i64> [#uses=1]
  switch i64 %magicptr23, label %if.else16 [
    i64 0, label %if.then
    i64 1, label %if.then2
    i64 2, label %if.then9
    i64 3, label %if.then9
    i64 4, label %if.then14
  ]

Note that LLVM's own DenseMap uses magic pointers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95439 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 22:03:18 +00:00
..
ABCD.cpp Change errs() to dbgs(). 2010-01-05 01:27:39 +00:00
ADCE.cpp Use do+while instead of while for loops which obviously have a 2010-01-05 16:27:25 +00:00
BasicBlockPlacement.cpp
CMakeLists.txt move instcombine to its own library, it's past time. 2010-01-04 06:23:24 +00:00
CodeGenPrepare.cpp Implement releaseMemory in CodeGenPrepare and free the BackEdges 2010-02-05 19:24:11 +00:00
ConstantProp.cpp remove a bunch of extraneous LLVMContext arguments 2009-11-06 04:27:31 +00:00
DCE.cpp
DeadStoreElimination.cpp Use do+while instead of while for loops which obviously have a 2010-01-05 16:27:25 +00:00
GEPSplitter.cpp Check in the experimental GEP splitter pass. This pass splits complex 2009-10-26 19:12:14 +00:00
GVN.cpp Fix some comment typos. 2010-02-03 00:33:21 +00:00
IndVarSimplify.cpp Re-implement the main strength-reduction portion of LoopStrengthReduction. 2010-01-21 02:09:26 +00:00
JumpThreading.cpp third bug from PR6119: the xor dupe extension allows 2010-01-23 19:21:31 +00:00
LICM.cpp Change errs() to dbgs(). 2010-01-05 01:27:30 +00:00
LoopDeletion.cpp LoopDeletion depends on loops having dedicated exits. 2009-11-05 21:47:04 +00:00
LoopIndexSplit.cpp Use do+while instead of while for loops which obviously have a 2010-01-05 16:27:25 +00:00
LoopRotation.cpp Update various Loop optimization passes to cope with the possibility that 2009-11-05 21:11:53 +00:00
LoopStrengthReduce.cpp Generic reformatting and comment fixing. No functionality change. 2010-01-29 00:52:43 +00:00
LoopUnrollPass.cpp Change errs() to dbgs(). 2010-01-05 01:27:44 +00:00
LoopUnswitch.cpp fix a crash in loop unswitch on a loop invariant vector condition. 2010-02-02 02:26:54 +00:00
Makefile make -fno-rtti the default unless a directory builds with REQUIRES_RTTI. 2010-01-24 20:43:08 +00:00
MemCpyOptimizer.cpp Convert a ton of simple integer type equality tests to the new predicate. 2010-01-05 20:07:06 +00:00
Reassociate.cpp Do not reassociate expressions with i1 type. SimplifyCFG converts some 2010-02-04 23:32:37 +00:00
Reg2Mem.cpp
Scalar.cpp remove the now dead condprop pass, PR3906. 2009-11-11 05:56:35 +00:00
ScalarReplAggregates.cpp Adjust the heuristics used to decide when SROA is likely to be profitable. 2010-02-03 17:23:56 +00:00
SCCP.cpp Change errs() to dbgs(). 2010-01-05 01:27:15 +00:00
SCCVN.cpp Use do+while instead of while for loops which obviously have a 2010-01-05 16:27:25 +00:00
SimplifyCFGPass.cpp Teach SimplifyCFG about magic pointer constants. 2010-02-05 22:03:18 +00:00
SimplifyHalfPowrLibCalls.cpp improve portability to avoid conflicting with std::next in c++'0x. 2009-12-03 00:50:42 +00:00
SimplifyLibCalls.cpp Recommit this, looks like it wasn't the cause. 2010-02-03 00:21:58 +00:00
TailDuplication.cpp Change errs() to dbgs(). 2010-01-05 01:27:33 +00:00
TailRecursionElimination.cpp Revert 94937 and move the noreturn check to codegen. 2010-02-03 03:55:59 +00:00