llvm-6502/lib/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.cpp Change errs() to dbgs(). 2010-01-05 01:26:54 +00:00
BasicBlockUtils.cpp No need to look through bitcasts for DbgInfoIntrinsic 2010-01-21 23:09:12 +00:00
BasicInliner.cpp Change errs() to dbgs(). 2010-01-05 01:26:39 +00:00
BreakCriticalEdges.cpp Add Loop contains utility methods for testing whether a loop 2009-12-18 01:24:09 +00:00
CloneFunction.cpp Don't bother with sprintf, just pass the Twine through. 2010-01-27 19:58:47 +00:00
CloneLoop.cpp Use do+while instead of while for loops which obviously have a 2010-01-05 16:27:25 +00:00
CloneModule.cpp MapValue doesn't needs its LLVMContext argument. 2009-10-24 23:37:16 +00:00
CMakeLists.txt Alphabetize. 2009-11-03 04:01:53 +00:00
CodeExtractor.cpp Fix nondeterministic behavior. 2010-01-10 01:07:22 +00:00
DemoteRegToStack.cpp Revert yesterday's change by removing the LLVMContext parameter to AllocaInst and MallocInst. 2009-07-15 23:53:25 +00:00
InlineFunction.cpp Remove dead debug info intrinsics. 2010-01-05 01:10:40 +00:00
InstructionNamer.cpp Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer. 2010-01-05 13:12:22 +00:00
LCSSA.cpp Fix a comment in a typo that Duncan noticed. 2009-11-09 18:59:22 +00:00
Local.cpp Fix pr6198 by moving the isSized() check to an outer conditional. 2010-02-01 17:41:44 +00:00
LoopSimplify.cpp Use a SmallSetVector instead of a SetVector; this code showed up as a 2010-02-05 19:20:15 +00:00
LoopUnroll.cpp Don't bother with sprintf, just pass the Twine through. 2010-01-27 19:58:47 +00:00
LowerInvoke.cpp Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer. 2010-01-05 13:12:22 +00:00
LowerSwitch.cpp Change errs() to dbgs(). 2010-01-05 01:26:45 +00:00
Makefile make -fno-rtti the default unless a directory builds with REQUIRES_RTTI. 2010-01-24 20:43:08 +00:00
Mem2Reg.cpp Pull LLVMContext out of PromoteMemToReg. 2009-11-23 03:50:44 +00:00
PromoteMemoryToRegister.cpp mem2reg erases the dbg.declare intrinsics that it converts to dbg.val intrinsics 2010-01-29 00:01:35 +00:00
SimplifyCFG.cpp Teach SimplifyCFG about magic pointer constants. 2010-02-05 22:03:18 +00:00
SSAUpdater.cpp Avoid creating redundant PHIs in SSAUpdater::GetValueInMiddleOfBlock. 2010-01-27 22:01:02 +00:00
SSI.cpp Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer. 2010-01-05 13:12:22 +00:00
UnifyFunctionExitNodes.cpp Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer. 2010-01-05 13:12:22 +00:00
ValueMapper.cpp Avoid extra calls to MD->getNumOperands() 2010-01-26 23:29:09 +00:00