diff options
author | Daniel Hoekwater <hoekwater@google.com> | 2023-04-10 17:09:59 -0700 |
---|---|---|
committer | Daniel Hoekwater <hoekwater@google.com> | 2023-04-14 16:14:50 -0700 |
commit | 6b62166b4cf8ec69f40a81d143fa1d623b4b0d0c (patch) | |
tree | ae9ab0bbcf44ee96e0b4cd988f5b2d48b330de10 /llvm/lib/CodeGen/TargetInstrInfo.cpp | |
parent | af78197857115716802189ef073f83cdac9ede15 (diff) | |
download | llvm-6b62166b4cf8ec69f40a81d143fa1d623b4b0d0c.zip llvm-6b62166b4cf8ec69f40a81d143fa1d623b4b0d0c.tar.gz llvm-6b62166b4cf8ec69f40a81d143fa1d623b4b0d0c.tar.bz2 |
Account for PATCHABLE instrs in Branch Relaxation
PATCHABLE_* instructions expand to up to 36-byte
sleds. Updating the size of PATCHABLE instructions
causes them to be outlined, so we need to add a
check to prevent the outliner from considering
basic blocks that contain PATCHABLE instructions.
Differential Revision: https://reviews.llvm.org/D147982
Diffstat (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetInstrInfo.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index 5c5b6a0..9d6c9a6 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -1651,10 +1651,25 @@ bool TargetInstrInfo::isMBBSafeToOutlineFrom(MachineBasicBlock &MBB, // 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)) + if (First == MBB.end()) + return true; + + if (First->getOpcode() == TargetOpcode::FENTRY_CALL || + First->getOpcode() == TargetOpcode::PATCHABLE_FUNCTION_ENTER) + return false; + + // Some instrumentations create special pseudo-instructions at or just before + // the end that must be present. + auto Last = MBB.getLastNonDebugInstr(); + if (Last->getOpcode() == TargetOpcode::PATCHABLE_RET || + Last->getOpcode() == TargetOpcode::PATCHABLE_TAIL_CALL) return false; + if (Last != First && Last->isReturn()) { + --Last; + if (Last->getOpcode() == TargetOpcode::PATCHABLE_FUNCTION_EXIT || + Last->getOpcode() == TargetOpcode::PATCHABLE_TAIL_CALL) + return false; + } return true; } |