diff options
author | Jessica Paquette <jpaquette@apple.com> | 2018-06-28 17:45:43 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2018-06-28 17:45:43 +0000 |
commit | dafa198c96d29b5cb3694494a3cb01da72745772 (patch) | |
tree | b4e7a6bdd39285946278c987701eef1cc4579fad | |
parent | 9c70d48cb2e9aafbfb3193aa366a53fccd3c7b2f (diff) | |
download | bcm5719-llvm-dafa198c96d29b5cb3694494a3cb01da72745772.tar.gz bcm5719-llvm-dafa198c96d29b5cb3694494a3cb01da72745772.zip |
[MachineOutliner] Define MachineOutliner support in TargetOptions
Targets should be able to define whether or not they support the outliner
without the outliner being added to the pass pipeline. Before this, the
outliner pass would be added, and ask the target whether or not it supports the
outliner.
After this, it's possible to query the target in TargetPassConfig, before the
outliner pass is created. This ensures that passing -enable-machine-outliner
will not modify the pass pipeline of any target that does not support it.
https://reviews.llvm.org/D48683
llvm-svn: 335887
-rw-r--r-- | llvm/include/llvm/CodeGen/TargetInstrInfo.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Target/TargetMachine.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Target/TargetOptions.h | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetPassConfig.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.h | 2 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64TargetMachine.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.h | 3 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86TargetMachine.cpp | 4 |
9 files changed, 17 insertions, 19 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h index 2619488c525..b477680a5b1 100644 --- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h +++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h @@ -1602,9 +1602,6 @@ public: return false; } - /// Returns true if the target implements the MachineOutliner. - virtual bool useMachineOutliner() const { return false; } - /// Returns a \p outliner::TargetCostInfo struct containing target-specific /// information for a set of outlining candidates. virtual outliner::TargetCostInfo getOutlininingCandidateInfo( diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 1dfb9ddcc86..c2b74543c88 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -202,6 +202,9 @@ public: bool getO0WantsFastISel() { return O0WantsFastISel; } void setO0WantsFastISel(bool Enable) { O0WantsFastISel = Enable; } void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; } + void setMachineOutliner(bool Enable) { + Options.EnableMachineOutliner = Enable; + } bool shouldPrintMachineCode() const { return Options.PrintMachineCode; } diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index 726dddac517..db2818c1ea8 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -110,7 +110,8 @@ namespace llvm { UniqueSectionNames(true), TrapUnreachable(false), NoTrapAfterNoreturn(false), EmulatedTLS(false), ExplicitEmulatedTLS(false), - EnableIPRA(false), EmitStackSizeSection(false) {} + EnableIPRA(false), EmitStackSizeSection(false), + EnableMachineOutliner(false) {} /// PrintMachineCode - This flag is enabled when the -print-machineinstrs /// option is specified on the command line, and should enable debugging @@ -231,6 +232,9 @@ namespace llvm { /// Emit section containing metadata on function stack sizes. unsigned EmitStackSizeSection : 1; + /// Enables the MachineOutliner pass. + unsigned EnableMachineOutliner : 1; + /// FloatABIType - This setting is set by -float-abi=xxx option is specfied /// on the command line. This setting may either be Default, Soft, or Hard. /// Default selects the target's default behavior. Soft selects the ABI for diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index 8f78240e1f7..8e92cd482d8 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -1331,15 +1331,6 @@ bool MachineOutliner::runOnModule(Module &M) { const TargetRegisterInfo *TRI = STI.getRegisterInfo(); const TargetInstrInfo *TII = STI.getInstrInfo(); - // Does the target implement the MachineOutliner? If it doesn't, quit here. - if (!TII->useMachineOutliner()) { - // No. So we're done. - LLVM_DEBUG( - dbgs() - << "Skipping pass: Target does not support the MachineOutliner.\n"); - return false; - } - // If the user specifies that they want to outline from linkonceodrs, set // it here. OutlineFromLinkOnceODRs = EnableLinkOnceODROutlining; diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index 8c5bdde888e..0ac89917012 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -906,7 +906,8 @@ void TargetPassConfig::addMachinePasses() { addPass(&XRayInstrumentationID, false); addPass(&PatchableFunctionID, false); - if (EnableMachineOutliner) + if (TM->Options.EnableMachineOutliner && + EnableMachineOutliner) addPass(createMachineOutlinerPass()); // Add passes that directly emit MI after all other MI passes. diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h index 0e5e7976f93..80cae6c6071 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h @@ -236,8 +236,6 @@ public: ArrayRef<std::pair<MachineMemOperand::Flags, const char *>> getSerializableMachineMemOperandTargetFlags() const override; - /// AArch64 supports the MachineOutliner. - bool useMachineOutliner() const override { return true; } bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override; outliner::TargetCostInfo getOutlininingCandidateInfo( diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp index b25bcdb7edc..01a997e5aed 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -252,6 +252,9 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT, // Enable GlobalISel at or below EnableGlobalISelAt0. if (getOptLevel() <= EnableGlobalISelAtO) setGlobalISel(true); + + // AArch64 supports the MachineOutliner. + setMachineOutliner(true); } AArch64TargetMachine::~AArch64TargetMachine() = default; diff --git a/llvm/lib/Target/X86/X86InstrInfo.h b/llvm/lib/Target/X86/X86InstrInfo.h index 8fee1d950df..aa31c837924 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.h +++ b/llvm/lib/Target/X86/X86InstrInfo.h @@ -553,9 +553,6 @@ public: ArrayRef<std::pair<unsigned, const char *>> getSerializableDirectMachineOperandTargetFlags() const override; - /// X86 supports the MachineOutliner. - bool useMachineOutliner() const override { return true; } - virtual outliner::TargetCostInfo getOutlininingCandidateInfo( std::vector<outliner::Candidate> &RepeatedSequenceLocs) const override; diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index 9b45e3bddc8..c5f476b54b9 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -234,6 +234,10 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT, this->Options.NoTrapAfterNoreturn = TT.isOSBinFormatMachO(); } + // Outlining is available for x86-64. + if (TT.getArch() == Triple::x86_64) + setMachineOutliner(true); + initAsmInfo(); } |