aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2017-09-19 23:00:55 +0000
committerAdam Nemet <anemet@apple.com>2017-09-19 23:00:55 +0000
commit15fccf00097dd5b07710539fb4e3ff68c50f44de (patch)
tree4cf3c7bc18bb6eb3e9d534c9fb2acab9429252cc /llvm/lib/Transforms/Utils/LoopUnroll.cpp
parent89972e21f8971e86e0a9e32dc91ee868db195f80 (diff)
downloadllvm-15fccf00097dd5b07710539fb4e3ff68c50f44de.zip
llvm-15fccf00097dd5b07710539fb4e3ff68c50f44de.tar.gz
llvm-15fccf00097dd5b07710539fb4e3ff68c50f44de.tar.bz2
Allow ORE.emit to take a closure to delay building the remark object
In the lambda we are now returning the remark by value so we need to preserve its type in the insertion operator. This requires making the insertion operator generic. I've also converted a few cases to use the new API. It seems to work pretty well. See the LoopUnroller for a slightly more interesting case. llvm-svn: 313691
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnroll.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
index 7759ac7..1fdc5e1 100644
--- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp
@@ -476,23 +476,30 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount, bool Force,
<< " peeled loop by " << NV("PeelCount", PeelCount)
<< " iterations");
} else {
- OptimizationRemark Diag(DEBUG_TYPE, "PartialUnrolled", L->getStartLoc(),
- L->getHeader());
- Diag << "unrolled loop by a factor of " << NV("UnrollCount", Count);
+ auto DiagBuilder = [&]() {
+ OptimizationRemark Diag(DEBUG_TYPE, "PartialUnrolled", L->getStartLoc(),
+ L->getHeader());
+ return Diag << "unrolled loop by a factor of "
+ << NV("UnrollCount", Count);
+ };
DEBUG(dbgs() << "UNROLLING loop %" << Header->getName()
<< " by " << Count);
if (TripMultiple == 0 || BreakoutTrip != TripMultiple) {
DEBUG(dbgs() << " with a breakout at trip " << BreakoutTrip);
- ORE->emit(Diag << " with a breakout at trip "
- << NV("BreakoutTrip", BreakoutTrip));
+ ORE->emit([&]() {
+ return DiagBuilder() << " with a breakout at trip "
+ << NV("BreakoutTrip", BreakoutTrip);
+ });
} else if (TripMultiple != 1) {
DEBUG(dbgs() << " with " << TripMultiple << " trips per branch");
- ORE->emit(Diag << " with " << NV("TripMultiple", TripMultiple)
- << " trips per branch");
+ ORE->emit([&]() {
+ return DiagBuilder() << " with " << NV("TripMultiple", TripMultiple)
+ << " trips per branch";
+ });
} else if (RuntimeTripCount) {
DEBUG(dbgs() << " with run-time trip count");
- ORE->emit(Diag << " with run-time trip count");
+ ORE->emit([&]() { return DiagBuilder() << " with run-time trip count"; });
}
DEBUG(dbgs() << "!\n");
}