diff options
author | Jessica Paquette <jpaquette@apple.com> | 2018-04-04 19:13:31 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2018-04-04 19:13:31 +0000 |
commit | bccd18b816c0413f63b14ccb77077cced6f033f7 (patch) | |
tree | 5229911afb5c62cfe8e4848899b504bc4e2523a5 /llvm/lib/CodeGen/MachineOutliner.cpp | |
parent | f7c5a10e55103ea8c8c46c7d9f0bbae50e39f96e (diff) | |
download | llvm-bccd18b816c0413f63b14ccb77077cced6f033f7.zip llvm-bccd18b816c0413f63b14ccb77077cced6f033f7.tar.gz llvm-bccd18b816c0413f63b14ccb77077cced6f033f7.tar.bz2 |
[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.
llvm-svn: 329220
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index 2a6a94d..932316f 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -1416,7 +1416,15 @@ bool MachineOutliner::runOnModule(Module &M) { 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 |