summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-06-17 14:13:29 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2019-06-17 14:13:29 +0000
commit1df203d78e478bea989736fd9f1657adea70db0d (patch)
tree342c2017cc82356496c401ccd6564b0cfc757a25 /llvm/lib/Transforms
parentb10f0978334ab2beb4477497323ddb6d44399b62 (diff)
downloadbcm5719-llvm-1df203d78e478bea989736fd9f1657adea70db0d.tar.gz
bcm5719-llvm-1df203d78e478bea989736fd9f1657adea70db0d.zip
InferAddressSpaces: Fix cloning original addrspacecast
If an addrspacecast needed to be inserted again, this was creating a clone of the original cast for each user. Just use the original, which also saves losing the value name. llvm-svn: 363562
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 36115e96cf4..5f0e2001c73 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -1006,8 +1006,12 @@ bool InferAddressSpaces::rewriteWithNewAddressSpaces(
}
// Otherwise, replaces the use with flat(NewV).
- if (Instruction *I = dyn_cast<Instruction>(V)) {
- BasicBlock::iterator InsertPos = std::next(I->getIterator());
+ if (Instruction *Inst = dyn_cast<Instruction>(V)) {
+ // Don't create a copy of the original addrspacecast.
+ if (U == V && isa<AddrSpaceCastInst>(V))
+ continue;
+
+ BasicBlock::iterator InsertPos = std::next(Inst->getIterator());
while (isa<PHINode>(InsertPos))
++InsertPos;
U.set(new AddrSpaceCastInst(NewV, V->getType(), "", &*InsertPos));
OpenPOWER on IntegriCloud