summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorNirav Dave <niravd@google.com>2017-06-08 13:20:55 +0000
committerNirav Dave <niravd@google.com>2017-06-08 13:20:55 +0000
commit62fb8498d32ae76c316437c7429095dad6873a82 (patch)
tree66b406bff99774c5672031004f21e3581a47015e /llvm/lib/Transforms/Scalar
parenta6d48f59a16f7cac43e55a346a7fed2de053cc13 (diff)
downloadbcm5719-llvm-62fb8498d32ae76c316437c7429095dad6873a82.tar.gz
bcm5719-llvm-62fb8498d32ae76c316437c7429095dad6873a82.zip
InferAddressSpaces: Avoid assertion failure with replacing identical
cloned constexpr Have cloneConstantExprWithNewAddressSpaces return nullptr when returning initial ConstantExpr. Reviewers: arsenm Subscribers: jholewinski, wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D33995 llvm-svn: 304975
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 85a017e9bce..3c8fbd35bf8 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -500,6 +500,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
}
// Computes the operands of the new constant expression.
+ bool IsNew = false;
SmallVector<Constant *, 4> NewOperands;
for (unsigned Index = 0; Index < CE->getNumOperands(); ++Index) {
Constant *Operand = CE->getOperand(Index);
@@ -509,6 +510,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
// bitcast, and getelementptr) do not incur cycles in the data flow graph
// and (2) this function is called on constant expressions in postorder.
if (Value *NewOperand = ValueWithNewAddrSpace.lookup(Operand)) {
+ IsNew = true;
NewOperands.push_back(cast<Constant>(NewOperand));
} else {
// Otherwise, reuses the old operand.
@@ -516,6 +518,11 @@ static Value *cloneConstantExprWithNewAddressSpace(
}
}
+ // If !IsNew, we will replace the Value with itself. However, replaced values
+ // are assumed to wrapped in a addrspace cast later so drop it now.
+ if (!IsNew)
+ return nullptr;
+
if (CE->getOpcode() == Instruction::GetElementPtr) {
// Needs to specify the source type while constructing a getelementptr
// constant expression.
OpenPOWER on IntegriCloud