diff options
author | Jessica Paquette <jpaquette@apple.com> | 2017-08-31 21:02:45 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2017-08-31 21:02:45 +0000 |
commit | ffe4abc51b063a2dc0e18857c2bd0971dba84d1e (patch) | |
tree | 25c525ed9dff25164d023023d7dafec3456b4f72 /llvm/lib/CodeGen | |
parent | 841acbbca0503a9b8f1972a803a42b75d4f49f96 (diff) | |
download | bcm5719-llvm-ffe4abc51b063a2dc0e18857c2bd0971dba84d1e.tar.gz bcm5719-llvm-ffe4abc51b063a2dc0e18857c2bd0971dba84d1e.zip |
[MachineOutliner] Recommit r312194, missed optimization remarks
Before, this commit caused a buildbot failure:
http://bb.pgr.jp/builders/test-llvm-i686-linux-RA/builds/6026/steps/test_llvm/logs/LLVM%20%3A%3A%20CodeGen__AArch64__machine-outliner-remarks.ll
This was caused by the Key value in DiagnosticInfoOptimizationBase being
deallocated before emitting the remarks defined in MachineOutliner.cpp. As of
r312277 this should no longer be an issue.
llvm-svn: 312280
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index 9a8eebff2b5..c12035455ab 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -46,6 +46,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" #include "llvm/CodeGen/Passes.h" #include "llvm/IR/IRBuilder.h" #include "llvm/Support/Allocator.h" @@ -64,6 +65,7 @@ #define DEBUG_TYPE "machine-outliner" using namespace llvm; +using namespace ore; STATISTIC(NumOutlined, "Number of candidates outlined"); STATISTIC(FunctionsCreated, "Number of functions created"); @@ -895,8 +897,41 @@ MachineOutliner::findCandidates(SuffixTree &ST, const TargetInstrInfo &TII, size_t OutliningCost = CallOverhead + FrameOverhead + SequenceOverhead; size_t NotOutliningCost = SequenceOverhead * Parent.OccurrenceCount; - if (NotOutliningCost <= OutliningCost) + // Is it better to outline this candidate than not? + if (NotOutliningCost <= OutliningCost) { + // Outlining this candidate would take more instructions than not + // outlining. + // Emit a remark explaining why we didn't outline this candidate. + std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator> C = + CandidateClass[0]; + MachineOptimizationRemarkEmitter MORE( + *(C.first->getParent()->getParent()), nullptr); + MachineOptimizationRemarkMissed R(DEBUG_TYPE, "NotOutliningCheaper", + C.first->getDebugLoc(), + C.first->getParent()); + R << "Did not outline " << NV("Length", StringLen) << " instructions" + << " from " << NV("NumOccurrences", CandidateClass.size()) + << " locations." + << " Instructions from outlining all occurrences (" + << NV("OutliningCost", OutliningCost) << ")" + << " >= Unoutlined instruction count (" + << NV("NotOutliningCost", NotOutliningCost) << ")" + << " (Also found at: "; + + // Tell the user the other places the candidate was found. + for (size_t i = 1, e = CandidateClass.size(); i < e; i++) { + R << NV((Twine("OtherStartLoc") + Twine(i)).str(), + CandidateClass[i].first->getDebugLoc()); + if (i != e - 1) + R << ", "; + } + + R << ")"; + MORE.emit(R); + + // Move to the next candidate. continue; + } size_t Benefit = NotOutliningCost - OutliningCost; |