Take advantage of undefined behavior if the source program tries to GEP
authorOwen Anderson <resistor@mac.com>
Mon, 16 Jul 2007 23:34:39 +0000 (23:34 +0000)
committerOwen Anderson <resistor@mac.com>
Mon, 16 Jul 2007 23:34:39 +0000 (23:34 +0000)
beyond the end of an alloca to make FastDSE faster and more aggressive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@39945 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/FastDSE.cpp

index 45985ba7175a74a1851fc45e201b2d7c07865b1b..72857b9c47a5f6e3f98e2bbb7adfd3fb46c468ae 100644 (file)
@@ -61,17 +61,10 @@ namespace {
       
       // See through pointer-to-pointer bitcasts
       while (isa<BitCastInst>(v) || isa<GetElementPtrInst>(v))
-        if (BitCastInst* C = dyn_cast<BitCastInst>(v)) {
-          if (isa<PointerType>(C->getSrcTy()))
-            v = C->getOperand(0);
-          else
-            break;
-        } else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(v)) {
-          if (G->hasAllZeroIndices())
-            v = G->getOperand(0);
-          else
-            break;
-        }
+        if (BitCastInst* C = dyn_cast<BitCastInst>(v))
+          v = C->getOperand(0);
+        else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(v))
+          v = G->getOperand(0);
     }
 
     // getAnalysisUsage - We require post dominance frontiers (aka Control