Skip to content

Commit 8ea51a3

Browse files
committed
[AArch64] Emit BTI j on EH landing pads ()
Landing pads reached by the unwinder are entered via 'br', so they must start with BTI j when -mbranch-protection requests BTI. Add isEHPad() to the jump-target test. Size/perf: +4 B per pad only when BTI is enabled. Test: new CodeGen/AArch64/bti-ehpad.ll. Signed-off-by: Shashi Shankar <[email protected]>
1 parent 07100c6 commit 8ea51a3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

llvm/lib/Target/AArch64/AArch64BranchTargets.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) {
100100
// If the block itself is address-taken, it could be indirectly branched
101101
// to, but not called.
102102
if (MBB.isMachineBlockAddressTaken() || MBB.isIRBlockAddressTaken() ||
103-
JumpTableTargets.count(&MBB))
103+
JumpTableTargets.count(&MBB) || MBB.isEHPad())
104104
CouldJump = true;
105105

106106
if (CouldCall || CouldJump) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: llc -mtriple=aarch64-linux-gnu -mbranch-protection=standard %s -o - | FileCheck %s
2+
3+
declare i32 @__gxx_personality_v0(...)
4+
5+
define void @foo() personality ptr @__gxx_personality_v0 {
6+
entry:
7+
invoke void @bar() to label %exit unwind label %lpad
8+
9+
lpad: ; CHECK-LABEL: lpad:
10+
landingpad { ptr, i32 } cleanup ; CHECK: bti j
11+
resume { ptr null, i32 0 }
12+
13+
exit:
14+
ret void
15+
}
16+
17+
declare void @bar()

0 commit comments

Comments
 (0)