[ValueTracking] Teach GetUnderlyingObject to stop when it reachs an alloca instruction.
authorCraig Topper <craig.topper@gmail.com>
Wed, 12 Apr 2017 22:29:23 +0000 (22:29 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 12 Apr 2017 22:29:23 +0000 (22:29 +0000)
Previously it tried to call SimplifyInstruction which doesn't know anything about alloca so defers to constant folding which also doesn't do anything with alloca. This results in wasted cycles making calls that won't do anything. Given the frequency with which this function is called this time adds up.

llvm-svn: 300118

llvm/lib/Analysis/ValueTracking.cpp

index d4c0e70..0309afd 100644 (file)
@@ -3216,6 +3216,9 @@ Value *llvm::GetUnderlyingObject(Value *V, const DataLayout &DL,
       if (GA->isInterposable())
         return V;
       V = GA->getAliasee();
+    } else if (isa<AllocaInst>(V)) {
+      // An alloca can't be further simplified.
+      return V;
     } else {
       if (auto CS = CallSite(V))
         if (Value *RV = CS.getReturnedArgOperand()) {