diff options
author | Jessica Paquette <jpaquette@apple.com> | 2017-08-30 23:31:49 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2017-08-30 23:31:49 +0000 |
commit | 65d953e0b1b1681082d1d3a1fdae169eeb5bafd8 (patch) | |
tree | 54fac21b6c1df90e304acd431dc8e67c10c9368b /llvm/lib/CodeGen | |
parent | 8f1559c2386463cea5c83128de6a4e6078800346 (diff) | |
download | bcm5719-llvm-65d953e0b1b1681082d1d3a1fdae169eeb5bafd8.tar.gz bcm5719-llvm-65d953e0b1b1681082d1d3a1fdae169eeb5bafd8.zip |
[MachineOutliner] Add missed optimization remarks for the outliner.
This adds missed optimization remarks which report viable candidates that
were not outlined because they would increase code size.
Other remarks will come in separate commits.
This will help to diagnose code size regressions and changes in outliner
behaviour in projects using the outliner.
https://reviews.llvm.org/D37085
llvm-svn: 312194
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; |