[polly] r311261 - [ManagedMemoryRewrite] Iterate over operands of the expanded instruction, not the constantexpr itself.
Siddharth Bhat via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 19 13:52:11 PDT 2017
Author: bollu
Date: Sat Aug 19 13:52:11 2017
New Revision: 311261
URL: http://llvm.org/viewvc/llvm-project?rev=311261&view=rev
Log:
[ManagedMemoryRewrite] Iterate over operands of the expanded instruction, not the constantexpr itself.
- We should iterate over `I`, which is `Cur` expanded out to an
instruction, and not `Cur` itself.
- This is a bugfix.
Differential Revision: https://reviews.llvm.org/D36923
Modified:
polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp
Modified: polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp?rev=311261&r1=311260&r2=311261&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp (original)
+++ polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp Sat Aug 19 13:52:11 2017
@@ -121,21 +121,26 @@ static void expandConstantExpr(ConstantE
Instruction *Parent, int index,
SmallPtrSet<Instruction *, 4> &Expands) {
assert(Cur && "invalid constant expression passed");
-
Instruction *I = Cur->getAsInstruction();
+ assert(I && "unable to convert ConstantExpr to Instruction");
+
+ DEBUG(dbgs() << "Expanding ConstantExpression: " << *Cur
+ << " | in Instruction: " << *I << "\n";);
+
+ // Invalidate `Cur` so that no one after this point uses `Cur`. Rather,
+ // they should mutate `I`.
+ Cur = nullptr;
+
Expands.insert(I);
Parent->setOperand(index, I);
- assert(I && "unable to convert ConstantExpr to Instruction");
// The things that `Parent` uses (its operands) should be created
// before `Parent`.
Builder.SetInsertPoint(Parent);
Builder.Insert(I);
- DEBUG(dbgs() << "Expanding ConstantExpression: " << *Cur
- << " | in Instruction: " << *I << "\n";);
- for (unsigned i = 0; i < Cur->getNumOperands(); i++) {
- Value *Op = Cur->getOperand(i);
+ for (unsigned i = 0; i < I->getNumOperands(); i++) {
+ Value *Op = I->getOperand(i);
assert(isa<Constant>(Op) && "constant must have a constant operand");
if (ConstantExpr *CExprOp = dyn_cast<ConstantExpr>(Op))
More information about the llvm-commits
mailing list