summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-06-29 16:12:45 +0000
committerJessica Paquette <jpaquette@apple.com>2018-06-29 16:12:45 +0000
commit79917b9686dcf7bd84bdd0328dbad6582fbac606 (patch)
tree62beb2aaed0e9a0b58143cf869920642a6e3446f
parent17f3f7ae6b78e10ffeeec28bee67375d4af0f0e6 (diff)
downloadbcm5719-llvm-79917b9686dcf7bd84bdd0328dbad6582fbac606.tar.gz
bcm5719-llvm-79917b9686dcf7bd84bdd0328dbad6582fbac606.zip
[MachineOutliner] Add always and never options to -enable-machine-outliner
This is a recommit of r335887, which was erroneously committed earlier. To enable the MachineOutliner by default on AArch64, we need to be able to disable the MachineOutliner and also provide an option to "always" enable the outliner. This adds that capability. It allows the user to still use the old -enable-machine-outliner option, which defaults to "always". This is building up to allowing the user to specify "always" versus the target default outlining behaviour. https://reviews.llvm.org/D48682 llvm-svn: 335986
-rw-r--r--llvm/lib/CodeGen/TargetPassConfig.cpp15
-rw-r--r--llvm/test/CodeGen/AArch64/machine-outliner-flags.ll12
2 files changed, 23 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp
index 044dcf7c749..dfdf676e40f 100644
--- a/llvm/lib/CodeGen/TargetPassConfig.cpp
+++ b/llvm/lib/CodeGen/TargetPassConfig.cpp
@@ -111,9 +111,16 @@ static cl::opt<bool> VerifyMachineCode("verify-machineinstrs", cl::Hidden,
cl::desc("Verify generated machine code"),
cl::init(false),
cl::ZeroOrMore);
-static cl::opt<bool> EnableMachineOutliner("enable-machine-outliner",
- cl::Hidden,
- cl::desc("Enable machine outliner"));
+enum RunOutliner { AlwaysOutline, NeverOutline };
+// Enable or disable the MachineOutliner.
+static cl::opt<RunOutliner> EnableMachineOutliner(
+ "enable-machine-outliner", cl::desc("Enable the machine outliner"),
+ cl::Hidden, cl::ValueOptional, cl::init(NeverOutline),
+ cl::values(clEnumValN(AlwaysOutline, "always",
+ "Run on all functions guaranteed to be beneficial"),
+ clEnumValN(NeverOutline, "never", "Disable all outlining"),
+ // Sentinel value for unspecified option.
+ clEnumValN(AlwaysOutline, "", "")));
// Enable or disable FastISel. Both options are needed, because
// FastISel is enabled by default with -fast, and we wish to be
// able to enable or disable fast-isel independently from -O0.
@@ -907,7 +914,7 @@ void TargetPassConfig::addMachinePasses() {
addPass(&PatchableFunctionID, false);
if (TM->Options.EnableMachineOutliner && getOptLevel() != CodeGenOpt::None &&
- EnableMachineOutliner)
+ EnableMachineOutliner == AlwaysOutline)
addPass(createMachineOutlinerPass());
// Add passes that directly emit MI after all other MI passes.
diff --git a/llvm/test/CodeGen/AArch64/machine-outliner-flags.ll b/llvm/test/CodeGen/AArch64/machine-outliner-flags.ll
index 33180ddb384..5f59c1060ac 100644
--- a/llvm/test/CodeGen/AArch64/machine-outliner-flags.ll
+++ b/llvm/test/CodeGen/AArch64/machine-outliner-flags.ll
@@ -1,8 +1,16 @@
; RUN: llc %s -debug-pass=Structure -verify-machineinstrs \
+; RUN: -enable-machine-outliner=always -mtriple arm64---- -o /dev/null 2>&1 \
+; RUN: | FileCheck %s -check-prefix=ALWAYS
+
+; RUN: llc %s -debug-pass=Structure -verify-machineinstrs \
; RUN: -enable-machine-outliner -mtriple arm64---- -o /dev/null 2>&1 \
; RUN: | FileCheck %s -check-prefix=ENABLE
; RUN: llc %s -debug-pass=Structure -verify-machineinstrs \
+; RUN: -enable-machine-outliner=never -mtriple arm64---- -o /dev/null 2>&1 \
+; RUN: | FileCheck %s -check-prefix=NEVER
+
+; RUN: llc %s -debug-pass=Structure -verify-machineinstrs \
; RUN: -mtriple arm64---- -o /dev/null 2>&1 \
; RUN: | FileCheck %s -check-prefix=NOT-ADDED
@@ -15,12 +23,16 @@
;
; Cases where it should be added:
; * -enable-machine-outliner
+; * -enable-machine-outliner=always
;
; Cases where it should not be added:
; * -O0 or equivalent
; * -enable-machine-outliner is not passed
+; * -enable-machine-outliner=never is passed
+; ALWAYS: Machine Outliner
; ENABLE: Machine Outliner
+; NEVER-NOT: Machine Outliner
; NOT-ADDED-NOT: Machine Outliner
; OPTNONE-NOT: Machine Outliner
OpenPOWER on IntegriCloud