[llvm] r329220 - [MachineOutliner] Add `useMachineOutliner` target hook
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 4 12:13:31 PDT 2018
Author: paquette
Date: Wed Apr 4 12:13:31 2018
New Revision: 329220
URL: http://llvm.org/viewvc/llvm-project?rev=329220&view=rev
Log:
[MachineOutliner] Add `useMachineOutliner` target hook
The MachineOutliner has a bunch of target hooks that will call llvm_unreachable
if the target doesn't implement them. Therefore, if you enable the outliner on
such a target, it'll just crash. It'd be much better if it'd just *not* run
the outliner at all in this case.
This commit adds a hook to TargetInstrInfo that returns false by default.
Targets that implement the hook make it return true. The outliner checks the
return value of this hook to decide whether or not to continue.
Modified:
llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h
llvm/trunk/lib/CodeGen/MachineOutliner.cpp
llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.h
llvm/trunk/lib/Target/X86/X86InstrInfo.h
Modified: llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h?rev=329220&r1=329219&r2=329220&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h Wed Apr 4 12:13:31 2018
@@ -1574,6 +1574,9 @@ public:
return false;
}
+ /// Returns true if the target implements the MachineOutliner.
+ virtual bool useMachineOutliner() const { return false; }
+
/// \brief Describes the number of instructions that it will take to call and
/// construct a frame for a given outlining candidate.
struct MachineOutlinerInfo {
Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=329220&r1=329219&r2=329220&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Wed Apr 4 12:13:31 2018
@@ -1416,7 +1416,15 @@ bool MachineOutliner::runOnModule(Module
MMI.getOrCreateMachineFunction(*M.begin()).getSubtarget();
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.
+ DEBUG(dbgs()
+ << "Skipping pass: Target does not support the MachineOutliner.\n");
+ return false;
+ }
+
InstructionMapper Mapper;
// Build instruction mappings for each function in the module. Start by
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.h?rev=329220&r1=329219&r2=329220&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.h (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.h Wed Apr 4 12:13:31 2018
@@ -236,6 +236,9 @@ public:
ArrayRef<std::pair<MachineMemOperand::Flags, const char *>>
getSerializableMachineMemOperandTargetFlags() const override;
+ /// AArch64 supports the MachineOutliner.
+ bool useMachineOutliner() const override { return true; }
+
bool
canOutlineWithoutLRSave(MachineBasicBlock::iterator &CallInsertionPt) const;
bool isFunctionSafeToOutlineFrom(MachineFunction &MF,
Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=329220&r1=329219&r2=329220&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Wed Apr 4 12:13:31 2018
@@ -582,6 +582,9 @@ public:
ArrayRef<std::pair<unsigned, const char *>>
getSerializableDirectMachineOperandTargetFlags() const override;
+ /// X86 supports the MachineOutliner.
+ bool useMachineOutliner() const override { return true; }
+
virtual MachineOutlinerInfo getOutlininingCandidateInfo(
std::vector<
std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
More information about the llvm-commits
mailing list