llvm-6502/include/llvm/Transforms/Utils
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
..
AddrModeMatcher.h Convert a few more uses of llvm/Support/Streams.h to raw_ostream. 2009-07-25 01:13:51 +00:00
BasicBlockUtils.h Make RecursivelyDeleteTriviallyDeadInstructions, 2010-01-05 15:45:31 +00:00
BasicInliner.h Move the InlineCost code from Transforms/Utils to Analysis. 2009-10-13 18:30:07 +00:00
Cloning.h Don't bother with sprintf, just pass the Twine through. 2010-01-27 19:58:47 +00:00
FunctionUtils.h Forward-declare Loop and LoopInfo instead of #including LoopInfo.h. 2009-07-13 22:19:41 +00:00
Local.h Teach SimplifyCFG about magic pointer constants. 2010-02-05 22:03:18 +00:00
PromoteMemToReg.h Pull LLVMContext out of PromoteMemToReg. 2009-11-23 03:50:44 +00:00
SSAUpdater.h comment fix: weakvh -> tracking vh 2009-12-22 00:51:57 +00:00
SSI.h Make a few more LLVM headers parsable as standalone headers. 2009-11-05 23:01:30 +00:00
UnifyFunctionExitNodes.h Tidy up several unbeseeming casts from pointer to intptr_t. 2008-09-04 17:05:41 +00:00
UnrollLoop.h Forward-declare Loop and LoopInfo instead of #including LoopInfo.h. 2009-07-13 22:19:41 +00:00
ValueMapper.h MapValue doesn't needs its LLVMContext argument. 2009-10-24 23:37:16 +00:00