aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2016-08-30 10:56:08 +0000
committerJames Molloy <james.molloy@arm.com>2016-08-30 10:56:08 +0000
commitd13b1239e4e4c1a653d3b7549aff679892a7f727 (patch)
tree2bde42a1c7b5468ae75e57a9ba44a5e08aed7da9 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent002572318938f74bb0177dd83d24a59b1cdd013d (diff)
downloadllvm-d13b1239e4e4c1a653d3b7549aff679892a7f727.zip
llvm-d13b1239e4e4c1a653d3b7549aff679892a7f727.tar.gz
llvm-d13b1239e4e4c1a653d3b7549aff679892a7f727.tar.bz2
[SimplifyCFG] Properly CSE metadata in SinkThenElseCodeToEnd
This was missing, meaning the metadata in sunk instructions was potentially bogus and could cause miscompiles. llvm-svn: 280072
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 59f416e..2868641 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1533,6 +1533,11 @@ static void sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) {
I0->getOperandUse(O).set(NewOperands[O]);
I0->moveBefore(&*BBEnd->getFirstInsertionPt());
+ // Update metadata.
+ for (auto *I : Insts)
+ if (I != I0)
+ combineMetadataForCSE(I0, I);
+
if (!isa<StoreInst>(I0)) {
// canSinkLastInstruction checked that all instructions were used by
// one and only one PHI node. Find that now, RAUW it to our common