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.
This commit is contained in:
Tim Northover 2020-07-17 11:25:59 +01:00
parent ef377d3f2d
commit 88464a55b4
5 changed files with 9 additions and 13 deletions

View File

@ -3652,14 +3652,10 @@ bool AArch64FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK)) BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
.addImm(1); .addImm(1);
return true; return true;
case Intrinsic::debugtrap: { case Intrinsic::debugtrap:
if (Subtarget->isTargetWindows()) { BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK)) .addImm(0xF000);
.addImm(0xF000); return true;
return true;
}
break;
}
case Intrinsic::sqrt: { case Intrinsic::sqrt: {
Type *RetTy = II->getCalledFunction()->getReturnType(); Type *RetTy = II->getCalledFunction()->getReturnType();

View File

@ -677,8 +677,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
// Trap. // Trap.
setOperationAction(ISD::TRAP, MVT::Other, Legal); setOperationAction(ISD::TRAP, MVT::Other, Legal);
if (Subtarget->isTargetWindows()) setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
// We combine OR nodes for bitfield operations. // We combine OR nodes for bitfield operations.
setTargetDAGCombine(ISD::OR); setTargetDAGCombine(ISD::OR);

View File

@ -6663,7 +6663,7 @@ def : Pat<(i32 (trunc GPR64sp:$src)),
// __builtin_trap() uses the BRK instruction on AArch64. // __builtin_trap() uses the BRK instruction on AArch64.
def : Pat<(trap), (BRK 1)>; def : Pat<(trap), (BRK 1)>;
def : Pat<(debugtrap), (BRK 0xF000)>, Requires<[IsWindows]>; def : Pat<(debugtrap), (BRK 0xF000)>;
// Multiply high patterns which multiply the lower subvector using smull/umull // Multiply high patterns which multiply the lower subvector using smull/umull
// and the upper subvector with smull2/umull2. Then shuffle the high the high // and the upper subvector with smull2/umull2. Then shuffle the high the high

View File

@ -4633,8 +4633,6 @@ bool AArch64InstructionSelector::selectIntrinsicWithSideEffects(
MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(1); MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(1);
break; break;
case Intrinsic::debugtrap: case Intrinsic::debugtrap:
if (!STI.isTargetWindows())
return false;
MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(0xF000); MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(0xF000);
break; break;
} }

View File

@ -1,6 +1,9 @@
; RUN: llc -mtriple=aarch64-windows %s -o -| FileCheck %s ; RUN: llc -mtriple=aarch64-windows %s -o -| FileCheck %s
; RUN: llc -mtriple=aarch64-windows -fast-isel %s -o - | FileCheck %s ; RUN: llc -mtriple=aarch64-windows -fast-isel %s -o - | FileCheck %s
; RUN: llc -mtriple=aarch64-windows -global-isel %s -o - | FileCheck %s ; RUN: llc -mtriple=aarch64-windows -global-isel %s -o - | FileCheck %s
; RUN: llc -mtriple=aarch64-linux-gnu %s -o -| FileCheck %s
; RUN: llc -mtriple=arm64-apple-ios -global-isel %s -o - | FileCheck %s
; RUN: llc -mtriple=arm64-apple-macosx -fast-isel %s -o - | FileCheck %s
; CHECK-LABEL: test1: ; CHECK-LABEL: test1:
; CHECK: brk #0xf000 ; CHECK: brk #0xf000