summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstrInfo.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index f15a41ee468..f0f5bfa351d 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -5084,6 +5084,13 @@ AArch64InstrInfo::getOutliningCandidateInfo(
unsigned FrameID = MachineOutlinerDefault;
unsigned NumBytesToCreateFrame = 4;
+ bool HasBTI =
+ std::any_of(RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
+ [](outliner::Candidate &C) {
+ return C.getMF()->getFunction().hasFnAttribute(
+ "branch-target-enforcement");
+ });
+
// If the last instruction in any candidate is a terminator, then we should
// tail call all of the candidates.
if (RepeatedSequenceLocs[0].back()->isTerminator()) {
@@ -5092,7 +5099,8 @@ AArch64InstrInfo::getOutliningCandidateInfo(
SetCandidateCallInfo(MachineOutlinerTailCall, 4);
}
- else if (LastInstrOpcode == AArch64::BL || LastInstrOpcode == AArch64::BLR) {
+ else if (LastInstrOpcode == AArch64::BL ||
+ (LastInstrOpcode == AArch64::BLR && !HasBTI)) {
// FIXME: Do we need to check if the code after this uses the value of LR?
FrameID = MachineOutlinerThunk;
NumBytesToCreateFrame = 0;
OpenPOWER on IntegriCloud