aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOutliner.cpp
diff options
context:
space:
mode:
authorNathan Lanza <nathanlanza@gmail.com>2023-04-08 02:10:27 -0400
committerNathan Lanza <nathanlanza@gmail.com>2023-04-08 02:12:40 -0400
commit87c0f6773970f41f0e464690862f05bc109ee8d0 (patch)
treeb97cc06b5b29240981337970973c711df2338458 /llvm/lib/CodeGen/MachineOutliner.cpp
parent92910a51b9043550cec6c9e63a5b92a15d42c665 (diff)
downloadllvm-87c0f6773970f41f0e464690862f05bc109ee8d0.zip
llvm-87c0f6773970f41f0e464690862f05bc109ee8d0.tar.gz
llvm-87c0f6773970f41f0e464690862f05bc109ee8d0.tar.bz2
[Outliner] Add an option to only enable outlining of patterns above a certain threshold
Outlining isn't always a win when the saved instruction count is >= 1. The overhead of representing a new function in the binary depends on exception metadata and alignment. So parameterize this for local tuning. Reviewed By: paquette Differential Revision: https://reviews.llvm.org/D136774
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 8d72208..d116c54 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -116,6 +116,11 @@ static cl::opt<unsigned> OutlinerReruns(
cl::desc(
"Number of times to rerun the outliner after the initial outline"));
+static cl::opt<unsigned> OutlinerBenefitThreshold(
+ "outliner-benefit-threshold", cl::init(1), cl::Hidden,
+ cl::desc(
+ "The minimum size in bytes before an outlining candidate is accepted"));
+
namespace {
/// Maps \p MachineInstrs to unsigned integers and stores the mappings.
@@ -664,7 +669,7 @@ void MachineOutliner::findCandidates(
continue;
// Is it better to outline this candidate than not?
- if (OF->getBenefit() < 1) {
+ if (OF->getBenefit() < OutlinerBenefitThreshold) {
emitNotOutliningCheaperRemark(StringLen, CandidatesForRepeatedSeq, *OF);
continue;
}
@@ -840,7 +845,7 @@ bool MachineOutliner::outline(Module &M,
});
// If we made it unbeneficial to outline this function, skip it.
- if (OF.getBenefit() < 1)
+ if (OF.getBenefit() < OutlinerBenefitThreshold)
continue;
// It's beneficial. Create the function and outline its sequence's