diff options
author | Siddharth Bhat <siddu.druid@gmail.com> | 2017-08-19 20:52:11 +0000 |
---|---|---|
committer | Siddharth Bhat <siddu.druid@gmail.com> | 2017-08-19 20:52:11 +0000 |
commit | 205a78a6f92dfabe859995daa71e270e1b27a242 (patch) | |
tree | d2cf3712680efada7a8198cdbb10faf5e66e24e9 /polly/lib/CodeGen/ManagedMemoryRewrite.cpp | |
parent | d606d2a643da45fb1de3475f5987affdf7c7a8bc (diff) | |
download | bcm5719-llvm-205a78a6f92dfabe859995daa71e270e1b27a242.tar.gz bcm5719-llvm-205a78a6f92dfabe859995daa71e270e1b27a242.zip |
[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
llvm-svn: 311261
Diffstat (limited to 'polly/lib/CodeGen/ManagedMemoryRewrite.cpp')
-rw-r--r-- | polly/lib/CodeGen/ManagedMemoryRewrite.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp index ec58bf49391..95f9d7dceed 100644 --- a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp +++ b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp @@ -121,21 +121,26 @@ static void expandConstantExpr(ConstantExpr *Cur, PollyIRBuilder &Builder, 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)) |