diff options
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation')
3 files changed, 34 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp index 31af2d0f35d..dcda44d1bd5 100644 --- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp +++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp @@ -277,38 +277,48 @@ ICallPromotionFunc::getPromotionCandidatesForCallSite( if (ICPInvokeOnly && dyn_cast<CallInst>(Inst)) { DEBUG(dbgs() << " Not promote: User options.\n"); - ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "UserOptions", Inst) - << " Not promote: User options"); + ORE.emit([&]() { + return OptimizationRemarkMissed(DEBUG_TYPE, "UserOptions", Inst) + << " Not promote: User options"; + }); break; } if (ICPCallOnly && dyn_cast<InvokeInst>(Inst)) { DEBUG(dbgs() << " Not promote: User option.\n"); - ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "UserOptions", Inst) - << " Not promote: User options"); + ORE.emit([&]() { + return OptimizationRemarkMissed(DEBUG_TYPE, "UserOptions", Inst) + << " Not promote: User options"; + }); break; } if (ICPCutOff != 0 && NumOfPGOICallPromotion >= ICPCutOff) { DEBUG(dbgs() << " Not promote: Cutoff reached.\n"); - ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "CutOffReached", Inst) - << " Not promote: Cutoff reached"); + ORE.emit([&]() { + return OptimizationRemarkMissed(DEBUG_TYPE, "CutOffReached", Inst) + << " Not promote: Cutoff reached"; + }); break; } Function *TargetFunction = Symtab->getFunction(Target); if (TargetFunction == nullptr) { DEBUG(dbgs() << " Not promote: Cannot find the target\n"); - ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "UnableToFindTarget", Inst) - << "Cannot promote indirect call: target not found"); + ORE.emit([&]() { + return OptimizationRemarkMissed(DEBUG_TYPE, "UnableToFindTarget", Inst) + << "Cannot promote indirect call: target not found"; + }); break; } const char *Reason = nullptr; if (!isLegalToPromote(Inst, TargetFunction, &Reason)) { using namespace ore; - ORE.emit(OptimizationRemarkMissed(DEBUG_TYPE, "UnableToPromote", Inst) + ORE.emit([&]() { + return OptimizationRemarkMissed(DEBUG_TYPE, "UnableToPromote", Inst) << "Cannot promote indirect call to " << NV("TargetFunction", TargetFunction) << " with count of " - << NV("Count", Count) << ": " << Reason); + << NV("Count", Count) << ": " << Reason; + }); break; } @@ -604,10 +614,12 @@ Instruction *llvm::promoteIndirectCall(Instruction *Inst, using namespace ore; if (ORE) - ORE->emit(OptimizationRemark(DEBUG_TYPE, "Promoted", Inst) - << "Promote indirect call to " << NV("DirectCallee", DirectCallee) - << " with count " << NV("Count", Count) << " out of " - << NV("TotalCount", TotalCount)); + ORE->emit([&]() { + return OptimizationRemark(DEBUG_TYPE, "Promoted", Inst) + << "Promote indirect call to " << NV("DirectCallee", DirectCallee) + << " with count " << NV("Count", Count) << " out of " + << NV("TotalCount", TotalCount); + }); return NewInst; } diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 82c89a67445..f8223496997 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -1510,8 +1510,10 @@ void setProfMetadata(Module *M, Instruction *TI, ArrayRef<uint64_t> EdgeCounts, OS.flush(); Function *F = TI->getParent()->getParent(); OptimizationRemarkEmitter ORE(F); - ORE.emit(OptimizationRemark(DEBUG_TYPE, "pgo-instrumentation", TI) - << BrCondStr << " is true with probability : " << BranchProbStr); + ORE.emit([&]() { + return OptimizationRemark(DEBUG_TYPE, "pgo-instrumentation", TI) + << BrCondStr << " is true with probability : " << BranchProbStr; + }); } } diff --git a/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp b/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp index b1d8fb25a4d..95eb3680403 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp @@ -382,14 +382,14 @@ bool MemOPSizeOpt::perform(MemIntrinsic *MI) { DEBUG(dbgs() << *DefaultBB << "\n"); DEBUG(dbgs() << *MergeBB << "\n"); - { + ORE.emit([&]() { using namespace ore; - ORE.emit(OptimizationRemark(DEBUG_TYPE, "memopt-opt", MI) + return OptimizationRemark(DEBUG_TYPE, "memopt-opt", MI) << "optimized " << NV("Intrinsic", StringRef(getMIName(MI))) << " with count " << NV("Count", SumForOpt) << " out of " << NV("Total", TotalCount) << " for " << NV("Versions", Version) - << " versions"); - } + << " versions"; + }); return true; } |