Skip to content

Commit 675f463

Browse files
committed
fixup! [CHERI StdCompat] Expand CGetSealed
Need to use -1 and not zero!
1 parent 37c3ae2 commit 675f463

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13581,8 +13581,11 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
1358113581
ISD::INTRINSIC_WO_CHAIN, DL, XLenVT,
1358213582
DAG.getConstant(Intrinsic::cheri_cap_type_get, DL, MVT::i64),
1358313583
N->getOperand(1));
13584-
// Unsealed capabilities have a zero type, so non-zero means sealed.
13585-
return DAG.getSetCC(DL, MVT::i1, Type, DAG.getConstant(0, DL, XLenVT),
13584+
// Note in the RISC-V standard unsealed capabilities have a zero type,
13585+
// but in ISAv9 unsealed is otype - 1.
13586+
int64_t UnsealedOtype = Subtarget.hasXCheri() ? -1 : 0;
13587+
return DAG.getSetCC(DL, MVT::i1, Type,
13588+
DAG.getConstant(UnsealedOtype, DL, XLenVT),
1358613589
ISD::SETNE);
1358713590
} else {
1358813591
SDValue IntRes =

llvm/test/CodeGen/RISCV/cheri/std-compat/get-sealed.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ define internal i64 @test(ptr addrspace(200) %cap) addrspace(200) nounwind {
1919
; STD-COMPAT-LABEL: test:
2020
; STD-COMPAT: # %bb.0: # %entry
2121
; STD-COMPAT-NEXT: cgettype a0, ca0
22-
; STD-COMPAT-NEXT: beqz a0, .LBB0_2
22+
; STD-COMPAT-NEXT: li a1, -1
23+
; STD-COMPAT-NEXT: beq a0, a1, .LBB0_2
2324
; STD-COMPAT-NEXT: # %bb.1: # %if.then
2425
; STD-COMPAT-NEXT: li a0, 4
2526
; STD-COMPAT-NEXT: cret

0 commit comments

Comments
 (0)