Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions llvm/lib/Target/AArch64/AArch64BranchTargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void AArch64BranchTargets::getAnalysisUsage(AnalysisUsage &AU) const {
FunctionPass *llvm::createAArch64BranchTargetsPass() {
return new AArch64BranchTargets();
}

bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) {
if (!MF.getInfo<AArch64FunctionInfo>()->branchTargetEnforcement())
return false;
Expand Down Expand Up @@ -100,7 +99,7 @@ bool AArch64BranchTargets::runOnMachineFunction(MachineFunction &MF) {
// If the block itself is address-taken, it could be indirectly branched
// to, but not called.
if (MBB.isMachineBlockAddressTaken() || MBB.isIRBlockAddressTaken() ||
JumpTableTargets.count(&MBB))
JumpTableTargets.count(&MBB) || MBB.isEHPad())
CouldJump = true;

if (CouldCall || CouldJump) {
Expand Down Expand Up @@ -147,7 +146,15 @@ void AArch64BranchTargets::addBTI(MachineBasicBlock &MBB, bool CouldCall,
BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()),
TII->get(AArch64::SEH_Nop));
}
BuildMI(MBB, MBB.begin(), MBB.findDebugLoc(MBB.begin()),

MBBI = MBB.begin();
if (MBB.isEHPad()) {
while (MBBI != MBB.end() &&
MBBI->getOpcode() == TargetOpcode::EH_LABEL)
++MBBI;
}

BuildMI(MBB, MBBI, MBB.findDebugLoc(MBBI),
TII->get(AArch64::HINT))
.addImm(HintNum);
}
26 changes: 26 additions & 0 deletions llvm/test/CodeGen/AArch64/bti-ehpad.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
; llvm/test/CodeGen/AArch64/bti-ehpad.ll
; REQUIRES: aarch64-registered-target
Comment on lines +1 to +2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these, the REQUIRES is handled by the folder.
Also it looks like it would be worth running update_llc_test_checks.py to generate a good set of test checks.

; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - | FileCheck %s

declare i32 @__gxx_personality_v0(...)

define void @test() #0 personality ptr @__gxx_personality_v0 {
entry:
invoke void @may_throw()
to label %ret unwind label %lpad
lpad: ; catch.dispatch
landingpad { ptr, i32 }
cleanup
ret void
ret:
ret void
}

declare void @may_throw()

attributes #0 = { "branch-target-enforcement"="true" }

; Function needs both the architectural feature *and* the enforcement request.
attributes #0 = { "branch-target-enforcement"="true" "target-features"="+bti" }
Comment on lines +21 to +24
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't define attribute #0 twice?


; CHECK: bti
Loading