diff options
author | Fangrui Song <i@maskray.me> | 2021-12-13 13:24:29 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-12-13 13:24:29 -0800 |
commit | a6a07a514b8a084feaa7f4f15d569698b9840d83 (patch) | |
tree | e04efbc760de5925306f24ba724abf31ab23be57 /llvm/lib/CodeGen/TargetInstrInfo.cpp | |
parent | f2120328e81879bf14d2a5c381749a11577fa304 (diff) | |
download | llvm-a6a07a514b8a084feaa7f4f15d569698b9840d83.zip llvm-a6a07a514b8a084feaa7f4f15d569698b9840d83.tar.gz llvm-a6a07a514b8a084feaa7f4f15d569698b9840d83.tar.bz2 |
[MachineOutliner] Don't outline functions starting with PATCHABLE_FUNCTION_ENTER/FENTRL_CALL
MachineOutliner may outline a "patchable-function-entry" function whose body has
a TargetOpcode::PATCHABLE_FUNCTION_ENTER MachineInstr. This is incorrect because
the special code sequence must stay unchanged to be used at run-time.
Avoid outlining PATCHABLE_FUNCTION_ENTER. While here, avoid outlining FENTRY_CALL too
(which doesn't reproduce currently) to allow phase ordering flexibility.
Fixes #52635
Reviewed By: paquette
Differential Revision: https://reviews.llvm.org/D115614
Diffstat (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfo.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index 6dd4dc2..3f22cc4 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -1418,3 +1418,16 @@ void TargetInstrInfo::mergeOutliningCandidateAttributes( })) F.addFnAttr(Attribute::NoUnwind); } + +bool TargetInstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB, + unsigned &Flags) const { + // Some instrumentations create special TargetOpcode at the start which + // expands to special code sequences which must be present. + auto First = MBB.getFirstNonDebugInstr(); + if (First != MBB.end() && + (First->getOpcode() == TargetOpcode::FENTRY_CALL || + First->getOpcode() == TargetOpcode::PATCHABLE_FUNCTION_ENTER)) + return false; + + return true; +} |