Skip to content

Commit 88464a5

Browse files
committed
AArch64: emit @llvm.debugtrap as brk #0xf000 on all platforms
It's useful for a debugger to be able to distinguish an @llvm.debugtrap from a (noreturn) @llvm.trap, so this extends the existing Windows behaviour to other platforms.
1 parent ef377d3 commit 88464a5

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

llvm/lib/Target/AArch64/AArch64FastISel.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,14 +3652,10 @@ bool AArch64FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
36523652
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
36533653
.addImm(1);
36543654
return true;
3655-
case Intrinsic::debugtrap: {
3656-
if (Subtarget->isTargetWindows()) {
3657-
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
3658-
.addImm(0xF000);
3659-
return true;
3660-
}
3661-
break;
3662-
}
3655+
case Intrinsic::debugtrap:
3656+
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
3657+
.addImm(0xF000);
3658+
return true;
36633659

36643660
case Intrinsic::sqrt: {
36653661
Type *RetTy = II->getCalledFunction()->getReturnType();

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
677677

678678
// Trap.
679679
setOperationAction(ISD::TRAP, MVT::Other, Legal);
680-
if (Subtarget->isTargetWindows())
681-
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
680+
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
682681

683682
// We combine OR nodes for bitfield operations.
684683
setTargetDAGCombine(ISD::OR);

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6663,7 +6663,7 @@ def : Pat<(i32 (trunc GPR64sp:$src)),
66636663

66646664
// __builtin_trap() uses the BRK instruction on AArch64.
66656665
def : Pat<(trap), (BRK 1)>;
6666-
def : Pat<(debugtrap), (BRK 0xF000)>, Requires<[IsWindows]>;
6666+
def : Pat<(debugtrap), (BRK 0xF000)>;
66676667

66686668
// Multiply high patterns which multiply the lower subvector using smull/umull
66696669
// and the upper subvector with smull2/umull2. Then shuffle the high the high

llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4633,8 +4633,6 @@ bool AArch64InstructionSelector::selectIntrinsicWithSideEffects(
46334633
MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(1);
46344634
break;
46354635
case Intrinsic::debugtrap:
4636-
if (!STI.isTargetWindows())
4637-
return false;
46384636
MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(0xF000);
46394637
break;
46404638
}

llvm/test/CodeGen/AArch64/windows-trap1.ll renamed to llvm/test/CodeGen/AArch64/debugtrap.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; RUN: llc -mtriple=aarch64-windows %s -o -| FileCheck %s
22
; RUN: llc -mtriple=aarch64-windows -fast-isel %s -o - | FileCheck %s
33
; RUN: llc -mtriple=aarch64-windows -global-isel %s -o - | FileCheck %s
4+
; RUN: llc -mtriple=aarch64-linux-gnu %s -o -| FileCheck %s
5+
; RUN: llc -mtriple=arm64-apple-ios -global-isel %s -o - | FileCheck %s
6+
; RUN: llc -mtriple=arm64-apple-macosx -fast-isel %s -o - | FileCheck %s
47

58
; CHECK-LABEL: test1:
69
; CHECK: brk #0xf000

0 commit comments

Comments
 (0)