Skip to content

Commit 7748492

Browse files
authored
[hexagon] Add support for llvm.debugtrap (#117049)
Also: set `hasSideEffects` on `Y2_break` instruction.
1 parent cd92c6a commit 7748492

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

llvm/lib/Target/Hexagon/HexagonDepInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40411,6 +40411,7 @@ def Y2_break : HInst<
4041140411
tc_55255f2b, TypeCR>, Enc_e3b0c4 {
4041240412
let Inst{13-0} = 0b00000000000000;
4041340413
let Inst{31-16} = 0b0110110000100000;
40414+
let hasSideEffects = 1;
4041440415
let isSolo = 1;
4041540416
}
4041640417
def Y2_ciad : HInst<

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,7 +1498,7 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
14981498
// All operations default to "legal", except:
14991499
// - indexed loads and stores (pre-/post-incremented),
15001500
// - ANY_EXTEND_VECTOR_INREG, ATOMIC_CMP_SWAP_WITH_SUCCESS, CONCAT_VECTORS,
1501-
// ConstantFP, DEBUGTRAP, FCEIL, FCOPYSIGN, FEXP, FEXP2, FFLOOR, FGETSIGN,
1501+
// ConstantFP, FCEIL, FCOPYSIGN, FEXP, FEXP2, FFLOOR, FGETSIGN,
15021502
// FLOG, FLOG2, FLOG10, FMAXNUM, FMINNUM, FNEARBYINT, FRINT, FROUND, TRAP,
15031503
// FTRUNC, PREFETCH, SIGN_EXTEND_VECTOR_INREG, ZERO_EXTEND_VECTOR_INREG,
15041504
// which default to "expand" for at least one type.
@@ -1507,6 +1507,7 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
15071507
setOperationAction(ISD::ConstantFP, MVT::f32, Legal);
15081508
setOperationAction(ISD::ConstantFP, MVT::f64, Legal);
15091509
setOperationAction(ISD::TRAP, MVT::Other, Legal);
1510+
setOperationAction(ISD::DEBUGTRAP, MVT::Other, Legal);
15101511
setOperationAction(ISD::ConstantPool, MVT::i32, Custom);
15111512
setOperationAction(ISD::JumpTable, MVT::i32, Custom);
15121513
setOperationAction(ISD::BUILD_PAIR, MVT::i64, Expand);

llvm/lib/Target/Hexagon/HexagonPatterns.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3384,6 +3384,7 @@ def HexagonBARRIER: SDNode<"HexagonISD::BARRIER", SDTNone, [SDNPHasChain]>;
33843384
def: Pat<(HexagonBARRIER), (Y2_barrier)>;
33853385

33863386
def: Pat<(trap), (PS_crash)>;
3387+
def: Pat<(debugtrap), (Y2_break)>;
33873388

33883389
// Read cycle counter.
33893390
def SDTInt64Leaf: SDTypeProfile<1, 0, [SDTCisVT<0, i64>]>;
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
; RUN: llc -march=hexagon < %s | FileCheck %s
1+
; RUN: llc -march=hexagon --verify-machineinstrs < %s | FileCheck %s
22

33
; Generate code that is guaranteed to crash. At the moment, it's a
44
; misaligned load.
5+
; CHECK-LABEL: f0
56
; CHECK: memd(##3134984174)
67

78
target triple = "hexagon"
89

9-
; Function Attrs: noreturn nounwind
10-
define i32 @f0() #0 {
10+
define i32 @f0() noreturn nounwind {
1111
entry:
1212
tail call void @llvm.trap()
1313
unreachable
1414
}
1515

16-
; Function Attrs: cold noreturn nounwind
17-
declare void @llvm.trap() #1
16+
; CHECK-LABEL: f1
17+
; CHECK: brkpt
18+
define i32 @f1() noreturn nounwind {
19+
entry:
20+
tail call void @llvm.debugtrap()
21+
unreachable
22+
}
1823

19-
attributes #0 = { noreturn nounwind "target-cpu"="hexagonv60" }
20-
attributes #1 = { cold noreturn nounwind }
24+
declare void @llvm.trap() nounwind
25+
declare void @llvm.debugtrap() nounwind

0 commit comments

Comments
 (0)