[llvm] r266099 - Check alloca's special state

JF Bastien via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 11:06:56 PDT 2016


Author: jfb
Date: Tue Apr 12 13:06:55 2016
New Revision: 266099

URL: http://llvm.org/viewvc/llvm-project?rev=266099&view=rev
Log:
Check alloca's special state

Following up to a similar fix in MergeFunctions: r266022. This patch keeps both in sync, it would be nice to not have to do this. It doesn't look like there's an easy way to test this code directly at the moment: AFAICT all currect uses of isSameOperationAs are looking at instructions deep inside a function. IndVarSimplify/pr24952.ll and InstMerge/st_sink_* look at alloca inadvertently but are brittle tests.

Modified:
    llvm/trunk/lib/IR/Instruction.cpp

Modified: llvm/trunk/lib/IR/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=266099&r1=266098&r2=266099&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instruction.cpp (original)
+++ llvm/trunk/lib/IR/Instruction.cpp Tue Apr 12 13:06:55 2016
@@ -279,6 +279,10 @@ static bool haveSameSpecialState(const I
   assert(I1->getOpcode() == I2->getOpcode() &&
          "Can not compare special state of different instructions");
 
+  if (const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
+    return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
+           (AI->getAlignment() == cast<AllocaInst>(I2)->getAlignment() ||
+            IgnoreAlignment);
   if (const LoadInst *LI = dyn_cast<LoadInst>(I1))
     return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&
            (LI->getAlignment() == cast<LoadInst>(I2)->getAlignment() ||




More information about the llvm-commits mailing list