From 1ccb66c5fb6f61fee8ea9dfcc99cca828c587bdb Mon Sep 17 00:00:00 2001 From: Jessica Paquette Date: Thu, 28 Jun 2018 16:39:42 +0000 Subject: [PATCH] [MachineOutliner] Add always and never options to -enable-machine-outliner 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. llvm-svn: 335872 --- llvm/lib/CodeGen/TargetPassConfig.cpp | 16 +++++++++--- .../test/CodeGen/AArch64/machine-outliner-flags.ll | 30 ++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 llvm/test/CodeGen/AArch64/machine-outliner-flags.ll diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 8c5bdde..20771ee 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -111,9 +111,17 @@ static cl::opt VerifyMachineCode("verify-machineinstrs", cl::Hidden, cl::desc("Verify generated machine code"), cl::init(false), cl::ZeroOrMore); -static cl::opt EnableMachineOutliner("enable-machine-outliner", - cl::Hidden, - cl::desc("Enable machine outliner")); +enum RunOutliner { AlwaysOutline, NeverOutline }; +// Enable or disable the MachineOutliner. +static cl::opt 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 " + "(pass -enable-linkonceodr-outlining for more)"), + 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. @@ -906,7 +914,7 @@ void TargetPassConfig::addMachinePasses() { addPass(&XRayInstrumentationID, false); addPass(&PatchableFunctionID, false); - if (EnableMachineOutliner) + if (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 new file mode 100644 index 0000000..0f232c8 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/machine-outliner-flags.ll @@ -0,0 +1,30 @@ +; 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 + +; Make sure that the outliner flags all work properly. If we specify +; -enable-machine-outliner with always or no argument, it should be added to the +; pass pipeline. If we specify it with never, or don't pass the flag, +; then we shouldn't add it. + +; ALWAYS: Machine Outliner +; ENABLE: Machine Outliner +; NEVER-NOT: Machine Outliner +; NOT-ADDED-NOT: Machine Outliner + +define void @foo() { + ret void; +} + -- 2.7.4