[llvm] 88464a5 - AArch64: emit @llvm.debugtrap as `brk #0xf000` on all platforms
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 20 02:31:33 PDT 2020
Author: Tim Northover
Date: 2020-07-20T10:31:26+01:00
New Revision: 88464a55b4eda9b778a8b9ca0193d4c6c11c6053
URL: https://github.com/llvm/llvm-project/commit/88464a55b4eda9b778a8b9ca0193d4c6c11c6053
DIFF: https://github.com/llvm/llvm-project/commit/88464a55b4eda9b778a8b9ca0193d4c6c11c6053.diff
LOG: 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.
Added:
llvm/test/CodeGen/AArch64/debugtrap.ll
Modified:
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
Removed:
llvm/test/CodeGen/AArch64/windows-trap1.ll
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64FastISel.cpp b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
index 0f63f4ca62e5..f0b35c2aef26 100644
--- a/llvm/lib/Target/AArch64/AArch64FastISel.cpp
+++ b/llvm/lib/Target/AArch64/AArch64FastISel.cpp
@@ -3652,14 +3652,10 @@ bool AArch64FastISel::fastLowerIntrinsicCall(const IntrinsicInst *II) {
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
.addImm(1);
return true;
- case Intrinsic::debugtrap: {
- if (Subtarget->isTargetWindows()) {
- BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
- .addImm(0xF000);
- return true;
- }
- break;
- }
+ case Intrinsic::debugtrap:
+ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(AArch64::BRK))
+ .addImm(0xF000);
+ return true;
case Intrinsic::sqrt: {
Type *RetTy = II->getCalledFunction()->getReturnType();
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index dae347cd8c2b..118eb26c9849 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -677,8 +677,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
// Trap.
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.
setTargetDAGCombine(ISD::OR);
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index f4a5f639e497..b3516623d9a0 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -6663,7 +6663,7 @@ def : Pat<(i32 (trunc GPR64sp:$src)),
// __builtin_trap() uses the BRK instruction on AArch64.
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
// and the upper subvector with smull2/umull2. Then shuffle the high the high
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 408f0cb77e73..8a6f79893527 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4633,8 +4633,6 @@ bool AArch64InstructionSelector::selectIntrinsicWithSideEffects(
MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(1);
break;
case Intrinsic::debugtrap:
- if (!STI.isTargetWindows())
- return false;
MIRBuilder.buildInstr(AArch64::BRK, {}, {}).addImm(0xF000);
break;
}
diff --git a/llvm/test/CodeGen/AArch64/windows-trap1.ll b/llvm/test/CodeGen/AArch64/debugtrap.ll
similarity index 65%
rename from llvm/test/CodeGen/AArch64/windows-trap1.ll
rename to llvm/test/CodeGen/AArch64/debugtrap.ll
index 6f6fa3a6609a..ec9027236321 100644
--- a/llvm/test/CodeGen/AArch64/windows-trap1.ll
+++ b/llvm/test/CodeGen/AArch64/debugtrap.ll
@@ -1,6 +1,9 @@
; 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 -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: brk #0xf000
More information about the llvm-commits
mailing list