diff options
author | Michael Kuperstein <mkuper@google.com> | 2016-12-16 21:23:59 +0000 |
---|---|---|
committer | Michael Kuperstein <mkuper@google.com> | 2016-12-16 21:23:59 +0000 |
commit | 3ca147ea3d8c2364542c2e4c2b7ba83fdf5e6dcd (patch) | |
tree | f56a38a5418f67dc6c144643b9fe52b62cdd780c /llvm/lib/Transforms/Utils | |
parent | 35f6d66b0d4da029fbd2d6f97cd9121d59d20322 (diff) | |
download | bcm5719-llvm-3ca147ea3d8c2364542c2e4c2b7ba83fdf5e6dcd.tar.gz bcm5719-llvm-3ca147ea3d8c2364542c2e4c2b7ba83fdf5e6dcd.zip |
Preserve loop metadata when folding branches to a common destination.
Differential Revision: https://reviews.llvm.org/D27830
llvm-svn: 289992
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index a47d0774fa7..668e22f46f4 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2792,6 +2792,11 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, unsigned BonusInstThreshold) { PBI = New_PBI; } + // If BI was a loop latch, it may have had associated loop metadata. + // We need to copy it to the new latch, that is, PBI. + if (MDNode *LoopMD = BI->getMetadata(LLVMContext::MD_loop)) + PBI->setMetadata(LLVMContext::MD_loop, LoopMD); + // TODO: If BB is reachable from all paths through PredBlock, then we // could replace PBI's branch probabilities with BI's. |