[llvm] r300118 - [ValueTracking] Teach GetUnderlyingObject to stop when it reachs an alloca instruction.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 15:29:24 PDT 2017


Author: ctopper
Date: Wed Apr 12 17:29:23 2017
New Revision: 300118

URL: http://llvm.org/viewvc/llvm-project?rev=300118&view=rev
Log:
[ValueTracking] Teach GetUnderlyingObject to stop when it reachs an alloca instruction.

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.


Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=300118&r1=300117&r2=300118&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Wed Apr 12 17:29:23 2017
@@ -3216,6 +3216,9 @@ Value *llvm::GetUnderlyingObject(Value *
       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()) {




More information about the llvm-commits mailing list