diff options
author | Vivek Pandya <vivekvpandya@gmail.com> | 2017-10-11 17:12:59 +0000 |
---|---|---|
committer | Vivek Pandya <vivekvpandya@gmail.com> | 2017-10-11 17:12:59 +0000 |
commit | 9590658fb88d40b88ad5bb34c66c946513579384 (patch) | |
tree | 7153e7514adc5b98d16cc7a026988c9644b7fa47 /llvm/lib/CodeGen | |
parent | 87867988f9a57bae14a1d14865cca926205685ba (diff) | |
download | bcm5719-llvm-9590658fb88d40b88ad5bb34c66c946513579384.tar.gz bcm5719-llvm-9590658fb88d40b88ad5bb34c66c946513579384.zip |
[NFC] Convert OptimizationRemarkEmitter old emit() calls to new closure
parameterized emit() calls
Summary: This is not functional change to adopt new emit() API added in r313691.
Reviewed By: anemet
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D38285
llvm-svn: 315476
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 47 | ||||
-rw-r--r-- | llvm/lib/CodeGen/PrologEpilogInserter.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/CodeGen/RegAllocGreedy.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/CodeGen/StackProtector.cpp | 44 |
4 files changed, 71 insertions, 56 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index ef9eb55f622..6c633d53992 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -939,29 +939,32 @@ MachineOutliner::findCandidates(SuffixTree &ST, const TargetInstrInfo &TII, // Emit a remark explaining why we didn't outline this candidate. std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator> C = RepeatedSequenceLocs[0]; - MachineOptimizationRemarkEmitter MORE(*(C.first->getMF()), nullptr); - MachineOptimizationRemarkMissed R(DEBUG_TYPE, "NotOutliningCheaper", - C.first->getDebugLoc(), - C.first->getParent()); - R << "Did not outline " << NV("Length", StringLen) << " instructions" - << " from " << NV("NumOccurrences", RepeatedSequenceLocs.size()) - << " locations." - << " Instructions from outlining all occurrences (" - << NV("OutliningCost", OF.getOutliningCost()) << ")" - << " >= Unoutlined instruction count (" - << NV("NotOutliningCost", StringLen * OF.OccurrenceCount) << ")" - << " (Also found at: "; - - // Tell the user the other places the candidate was found. - for (unsigned i = 1, e = RepeatedSequenceLocs.size(); i < e; i++) { - R << NV((Twine("OtherStartLoc") + Twine(i)).str(), - RepeatedSequenceLocs[i].first->getDebugLoc()); - if (i != e - 1) - R << ", "; - } + MachineOptimizationRemarkEmitter MORE( + *(C.first->getParent()->getParent()), nullptr); + MORE.emit([&]() { + MachineOptimizationRemarkMissed R(DEBUG_TYPE, "NotOutliningCheaper", + C.first->getDebugLoc(), + C.first->getParent()); + R << "Did not outline " << NV("Length", StringLen) << " instructions" + << " from " << NV("NumOccurrences", RepeatedSequenceLocs.size()) + << " locations." + << " Instructions from outlining all occurrences (" + << NV("OutliningCost", OF.getOutliningCost()) << ")" + << " >= Unoutlined instruction count (" + << NV("NotOutliningCost", StringLen * OF.OccurrenceCount) << ")" + << " (Also found at: "; + + // Tell the user the other places the candidate was found. + for (unsigned i = 1, e = RepeatedSequenceLocs.size(); i < e; i++) { + R << NV((Twine("OtherStartLoc") + Twine(i)).str(), + RepeatedSequenceLocs[i].first->getDebugLoc()); + if (i != e - 1) + R << ", "; + } - R << ")"; - MORE.emit(R); + R << ")"; + return R; + }); // Move to the next candidate. continue; diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index e105dbe18ec..d9e9b3360a0 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -960,11 +960,12 @@ void PEI::calculateFrameObjectOffsets(MachineFunction &Fn) { MFI.setStackSize(StackSize); NumBytesStackSpace += StackSize; - MachineOptimizationRemarkAnalysis R( - DEBUG_TYPE, "StackSize", Fn.getFunction()->getSubprogram(), &Fn.front()); - R << ore::NV("NumStackBytes", StackSize) - << " stack bytes in function"; - ORE->emit(R); + ORE->emit([&]() { + return MachineOptimizationRemarkAnalysis(DEBUG_TYPE, "StackSize", + Fn.getFunction()->getSubprogram(), + &Fn.front()) + << ore::NV("NumStackBytes", StackSize) << " stack bytes in function"; + }); } /// insertPrologEpilogCode - Scan the function for modified callee saved diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index e9529e3509c..5ddec3db326 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -2717,17 +2717,20 @@ void RAGreedy::reportNumberOfSplillsReloads(MachineLoop *L, unsigned &Reloads, if (Reloads || FoldedReloads || Spills || FoldedSpills) { using namespace ore; - MachineOptimizationRemarkMissed R(DEBUG_TYPE, "LoopSpillReload", - L->getStartLoc(), L->getHeader()); - if (Spills) - R << NV("NumSpills", Spills) << " spills "; - if (FoldedSpills) - R << NV("NumFoldedSpills", FoldedSpills) << " folded spills "; - if (Reloads) - R << NV("NumReloads", Reloads) << " reloads "; - if (FoldedReloads) - R << NV("NumFoldedReloads", FoldedReloads) << " folded reloads "; - ORE->emit(R << "generated in loop"); + ORE->emit([&]() { + MachineOptimizationRemarkMissed R(DEBUG_TYPE, "LoopSpillReload", + L->getStartLoc(), L->getHeader()); + if (Spills) + R << NV("NumSpills", Spills) << " spills "; + if (FoldedSpills) + R << NV("NumFoldedSpills", FoldedSpills) << " folded spills "; + if (Reloads) + R << NV("NumReloads", Reloads) << " reloads "; + if (FoldedReloads) + R << NV("NumFoldedReloads", FoldedReloads) << " folded reloads "; + R << "generated in loop"; + return R; + }); } } diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 8138b52c92b..ae3d49c5e23 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -247,10 +247,12 @@ bool StackProtector::RequiresStackProtector() { OptimizationRemarkEmitter ORE(F); if (F->hasFnAttribute(Attribute::StackProtectReq)) { - ORE.emit(OptimizationRemark(DEBUG_TYPE, "StackProtectorRequested", F) + ORE.emit([&]() { + return OptimizationRemark(DEBUG_TYPE, "StackProtectorRequested", F) << "Stack protection applied to function " << ore::NV("Function", F) - << " due to a function attribute or command-line switch"); + << " due to a function attribute or command-line switch"; + }); NeedsProtector = true; Strong = true; // Use the same heuristic as strong to determine SSPLayout } else if (F->hasFnAttribute(Attribute::StackProtectStrong)) @@ -264,29 +266,31 @@ bool StackProtector::RequiresStackProtector() { for (const Instruction &I : BB) { if (const AllocaInst *AI = dyn_cast<AllocaInst>(&I)) { if (AI->isArrayAllocation()) { - OptimizationRemark Remark(DEBUG_TYPE, "StackProtectorAllocaOrArray", - &I); - Remark - << "Stack protection applied to function " - << ore::NV("Function", F) - << " due to a call to alloca or use of a variable length array"; + auto RemarkBuilder = [&]() { + return OptimizationRemark(DEBUG_TYPE, "StackProtectorAllocaOrArray", + &I) + << "Stack protection applied to function " + << ore::NV("Function", F) + << " due to a call to alloca or use of a variable length " + "array"; + }; if (const auto *CI = dyn_cast<ConstantInt>(AI->getArraySize())) { if (CI->getLimitedValue(SSPBufferSize) >= SSPBufferSize) { // A call to alloca with size >= SSPBufferSize requires // stack protectors. Layout.insert(std::make_pair(AI, SSPLK_LargeArray)); - ORE.emit(Remark); + ORE.emit(RemarkBuilder); NeedsProtector = true; } else if (Strong) { // Require protectors for all alloca calls in strong mode. Layout.insert(std::make_pair(AI, SSPLK_SmallArray)); - ORE.emit(Remark); + ORE.emit(RemarkBuilder); NeedsProtector = true; } } else { // A call to alloca with a variable size requires protectors. Layout.insert(std::make_pair(AI, SSPLK_LargeArray)); - ORE.emit(Remark); + ORE.emit(RemarkBuilder); NeedsProtector = true; } continue; @@ -296,11 +300,13 @@ bool StackProtector::RequiresStackProtector() { if (ContainsProtectableArray(AI->getAllocatedType(), IsLarge, Strong)) { Layout.insert(std::make_pair(AI, IsLarge ? SSPLK_LargeArray : SSPLK_SmallArray)); - ORE.emit(OptimizationRemark(DEBUG_TYPE, "StackProtectorBuffer", &I) + ORE.emit([&]() { + return OptimizationRemark(DEBUG_TYPE, "StackProtectorBuffer", &I) << "Stack protection applied to function " << ore::NV("Function", F) << " due to a stack allocated buffer or struct containing a " - "buffer"); + "buffer"; + }); NeedsProtector = true; continue; } @@ -308,11 +314,13 @@ bool StackProtector::RequiresStackProtector() { if (Strong && HasAddressTaken(AI)) { ++NumAddrTaken; Layout.insert(std::make_pair(AI, SSPLK_AddrOf)); - ORE.emit( - OptimizationRemark(DEBUG_TYPE, "StackProtectorAddressTaken", &I) - << "Stack protection applied to function " - << ore::NV("Function", F) - << " due to the address of a local variable being taken"); + ORE.emit([&]() { + return OptimizationRemark(DEBUG_TYPE, "StackProtectorAddressTaken", + &I) + << "Stack protection applied to function " + << ore::NV("Function", F) + << " due to the address of a local variable being taken"; + }); NeedsProtector = true; } } |