diff options
author | Oliver Stannard <oliver.stannard@arm.com> | 2018-10-08 14:12:08 +0000 |
---|---|---|
committer | Oliver Stannard <oliver.stannard@arm.com> | 2018-10-08 14:12:08 +0000 |
commit | 367b4741f4954c9d4013ffcbfb48ca2c535fd6d1 (patch) | |
tree | a6d1f631906bd362e9850540fb753ecab3439ac2 /llvm/lib/Target | |
parent | c922116a5152b80fad932b6a963973ffb6eee76c (diff) | |
download | bcm5719-llvm-367b4741f4954c9d4013ffcbfb48ca2c535fd6d1.tar.gz bcm5719-llvm-367b4741f4954c9d4013ffcbfb48ca2c535fd6d1.zip |
[AArch64][v8.5A] Don't create BR instructions in outliner when BTI enabled
When branch target identification is enabled, we can only do indirect
tail-calls through x16 or x17. This means that the outliner can't
transform a BLR instruction at the end of an outlined region into a BR.
Differential revision: https://reviews.llvm.org/D52869
llvm-svn: 343969
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 10 |
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; |