]> granicus.if.org Git - llvm/commitdiff
[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.

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

lib/Analysis/ValueTracking.cpp

index d4c0e7092eaa146cad0504514baf52d60c71e0c7..0309afd98af35dfa11572b4fa06d87f8c57dce4f 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()) {