Skip to content

Commit ded75f4

Browse files
committed
[CHERI] Remove support for CHERI256.
1 parent 6bc4cd7 commit ded75f4

File tree

22 files changed

+193
-356
lines changed

22 files changed

+193
-356
lines changed
-38.8 KB
Binary file not shown.

lld/test/ELF/cheri/cap-table/interposing_table.c

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
2-
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri256 -target-abi purecap -position-independent -filetype=obj %s -o %t-cheri256-main.o
31
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri128 -target-abi purecap -position-independent -filetype=obj %s -o %t-cheri128-main.o
4-
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri256 -target-abi n64 -position-independent -filetype=obj %s -o %t-cheri256-hybrid-main.o
52
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri128 -target-abi n64 -position-independent -filetype=obj %s -o %t-cheri128-hybrid-main.o
63
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=beri -target-abi n64 -position-independent -filetype=obj %s -o %t-beri-main.o
7-
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri256 -target-abi purecap -position-independent -filetype=obj %S/../Inputs/mips-dynamic.s -o %t-cheri256-lib.o
84
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri128 -target-abi purecap -position-independent -filetype=obj %S/../Inputs/mips-dynamic.s -o %t-cheri128-lib.o
9-
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri256 -target-abi n64 -position-independent -filetype=obj %S/../Inputs/mips-dynamic.s -o %t-cheri256-hybrid-lib.o
105
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri128 -target-abi n64 -position-independent -filetype=obj %S/../Inputs/mips-dynamic.s -o %t-cheri128-hybrid-lib.o
116
# RUN: llvm-readobj -h %t-cheri128-main.o | FileCheck --check-prefix=CHERI128-FLAGS %s
12-
# RUN: llvm-readobj -h %t-cheri256-main.o | FileCheck --check-prefix=CHERI256-FLAGS %s
137
# RUN: llvm-readobj -h %t-cheri128-hybrid-main.o | FileCheck --check-prefix=CHERI128-HYBRID-FLAGS %s
14-
# RUN: llvm-readobj -h %t-cheri256-hybrid-main.o | FileCheck --check-prefix=CHERI256-HYBRID-FLAGS %s
158

169

1710
# Check that setting an explicit CHERI emulation overrides the target ABI from the first .o:
@@ -34,23 +27,15 @@
3427
# RUN: %S/../Inputs/mips-dynamic.s -mcpu=mips4 -o %t-mips4.o
3528
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-freebsd \
3629
# RUN: %S/../Inputs/mips-dynamic.s -mcpu=beri -o %t-beri.o
37-
# RUN: not ld.lld %t-cheri256-main.o %t-mips64.o -o %t.exe 2>&1 | FileCheck -check-prefix=CHERI256-vs-MIPS %s
3830
# RUN: not ld.lld %t-cheri128-main.o %t-mips64.o -o %t.exe 2>&1 | FileCheck -check-prefix=CHERI128-vs-MIPS %s
39-
# RUN: not ld.lld %t-cheri256-main.o %t-cheri128-lib.o -o %t.exe 2>&1 | FileCheck -check-prefix=CHERI256-vs-CHERI128 %s
40-
# RUN: not ld.lld %t-cheri128-main.o %t-cheri256-lib.o -o %t.exe 2>&1 | FileCheck -check-prefix=CHERI128-vs-CHERI256 %s
41-
# RUN: not ld.lld %t-cheri256-main.o %t-cheri256-hybrid-lib.o -o %t.exe 2>&1 | FileCheck -check-prefix=CHERI256-vs-CHERI256-HYBRID %s
4231
# RUN: not ld.lld %t-cheri128-main.o %t-cheri128-hybrid-lib.o -o %t.exe 2>&1 | FileCheck -check-prefix=CHERI128-vs-CHERI128-HYBRID %s
4332

4433
# linking plain mips with hybrid results in a hybrid binary:
45-
# RUN: ld.lld %t-cheri256-hybrid-main.o %t-mips4.o -o %t.exe
46-
# RUN: llvm-readobj -h %t.exe | FileCheck --check-prefix=CHERI256-HYBRID-FLAGS %s
4734
# RUN: ld.lld %t-cheri128-hybrid-main.o %t-mips4.o -o %t.exe
4835
# RUN: llvm-readobj -h %t.exe | FileCheck --check-prefix=CHERI128-HYBRID-FLAGS %s
4936
# Same for -mcpu=beri
5037
# RUN: ld.lld %t-cheri128-hybrid-main.o %t-beri.o -o %t.exe
5138
# RUN: llvm-readobj -h %t.exe | FileCheck --check-prefix=CHERI128-HYBRID-FLAGS %s
52-
# RUN: ld.lld %t-cheri256-hybrid-main.o %t-beri.o -o %t.exe
53-
# RUN: llvm-readobj -h %t.exe | FileCheck --check-prefix=CHERI256-HYBRID-FLAGS %s
5439

5540

5641
# Should be able to link beri with MIPS4
@@ -65,7 +50,6 @@
6550

6651
# but not if the plain MIPS arch is a superset of the cheri arch
6752
# RUN: not ld.lld %t-cheri128-hybrid-main.o %t-mips64.o -o %t.exe 2>&1 | FileCheck -DCHERI_TYPE=cheri128 -check-prefix CHERI-MIPS4-vs-MIPS64 %s
68-
# RUN: not ld.lld %t-cheri256-hybrid-main.o %t-mips64.o -o %t.exe 2>&1 | FileCheck -DCHERI_TYPE=cheri256 -check-prefix CHERI-MIPS4-vs-MIPS64 %s
6953
# CHERI-MIPS4-vs-MIPS64: incompatible target ISA:
7054
# CHERI-MIPS4-vs-MIPS64-NEXT: {{.+}}-[[CHERI_TYPE]]-hybrid-main.o: mips4 ([[CHERI_TYPE]])
7155
# CHERI-MIPS4-vs-MIPS64-NEXT: {{.+}}-mips64.o: mips64
@@ -75,7 +59,6 @@
7559
# because -mcpu=mips4 doesn't schedule loads sensibly
7660
# RUN: not ld.lld --fatal-warnings %t-beri-main.o %t-mips4.o -o /dev/null 2>&1 | FileCheck %s -check-prefix BERI-NON-BERI -DARCH=beri
7761
# RUN: not ld.lld --fatal-warnings %t-cheri128-hybrid-main.o %t-mips4.o -o /dev/null 2>&1 | FileCheck %s -check-prefix BERI-NON-BERI -DARCH=cheri128
78-
# RUN: not ld.lld --fatal-warnings %t-cheri256-hybrid-main.o %t-mips4.o -o /dev/null 2>&1 | FileCheck %s -check-prefix BERI-NON-BERI -DARCH=cheri256
7962

8063
// BERI-NON-BERI: ld.lld: error: linking files compiled for BERI/CHERI and non-BERI/CHERI can result in surprising performance:
8164
// BERI-NON-BERI-NEXT: >>> {{.+}}cheri-elf-flags-err.s.tmp-{{.+}}-main.o: mips4 ([[ARCH]])
@@ -96,13 +79,6 @@ __start:
9679
# BERI-FLAGS-NEXT: EF_MIPS_CPIC (0x4)
9780
# BERI-FLAGS-NEXT: EF_MIPS_MACH_BERI (0xBE0000)
9881
# BERI-FLAGS-NEXT: ]
99-
# CHERI256-FLAGS: Machine: EM_MIPS (0x8)
100-
# CHERI256-FLAGS: Flags [
101-
# CHERI256-FLAGS-NEXT: EF_MIPS_ABI_CHERIABI (0xC000)
102-
# CHERI256-FLAGS-NEXT: EF_MIPS_ARCH_4 (0x30000000)
103-
# CHERI256-FLAGS-NEXT: EF_MIPS_CPIC (0x4)
104-
# CHERI256-FLAGS-NEXT: EF_MIPS_MACH_CHERI256 (0xC20000)
105-
# CHERI256-FLAGS-NEXT: ]
10682
# CHERI128-FLAGS: Machine: EM_MIPS (0x8)
10783
# CHERI128-FLAGS: Flags [
10884
# CHERI128-FLAGS-NEXT: EF_MIPS_ABI_CHERIABI (0xC000)
@@ -111,31 +87,16 @@ __start:
11187
# CHERI128-FLAGS-NEXT: EF_MIPS_MACH_CHERI128 (0xC10000)
11288
# CHERI128-FLAGS-NEXT: ]
11389

114-
# CHERI256-HYBRID-FLAGS: Machine: EM_MIPS (0x8)
115-
# CHERI256-HYBRID-FLAGS: Flags [
116-
# CHERI256-HYBRID-FLAGS-NEXT: EF_MIPS_ARCH_4 (0x30000000)
117-
# CHERI256-HYBRID-FLAGS-NEXT: EF_MIPS_CPIC (0x4)
118-
# CHERI256-HYBRID-FLAGS-NEXT: EF_MIPS_MACH_CHERI256 (0xC20000)
119-
# CHERI256-HYBRID-FLAGS-NEXT: ]
12090
# CHERI128-HYBRID-FLAGS: Machine: EM_MIPS (0x8)
12191
# CHERI128-HYBRID-FLAGS: Flags [
12292
# CHERI128-HYBRID-FLAGS-NEXT: EF_MIPS_ARCH_4 (0x30000000)
12393
# CHERI128-HYBRID-FLAGS-NEXT: EF_MIPS_CPIC (0x4)
12494
# CHERI128-HYBRID-FLAGS-NEXT: EF_MIPS_MACH_CHERI128 (0xC10000)
12595
# CHERI128-HYBRID-FLAGS-NEXT: ]
12696

127-
# CHERI256-vs-MIPS: {{.*}}/cheri-elf-flags-err.s.tmp-mips64.o: ABI 'n64' is incompatible with target ABI 'purecap'
12897
# CHERI128-vs-MIPS: {{.*}}/cheri-elf-flags-err.s.tmp-mips64.o: ABI 'n64' is incompatible with target ABI 'purecap'
129-
# CHERI256-vs-CHERI128: incompatible target ISA:
130-
# CHERI256-vs-CHERI128-NEXT: {{.+}}-cheri256-main.o: mips4 (cheri256)
131-
# CHERI256-vs-CHERI128-NEXT: {{.+}}-cheri128-lib.o: mips4 (cheri128)
132-
# CHERI128-vs-CHERI256: incompatible target ISA:
133-
# CHERI128-vs-CHERI256-NEXT: {{.+}}-cheri128-main.o: mips4 (cheri128)
134-
# CHERI128-vs-CHERI256-NEXT: {{.+}}-cheri256-lib.o: mips4 (cheri256)
135-
# CHERI256-vs-CHERI256-HYBRID: {{.*}}/cheri-elf-flags-err.s.tmp-cheri256-hybrid-lib.o: ABI 'n64' is incompatible with target ABI 'purecap'
13698
# CHERI128-vs-CHERI128-HYBRID: {{.*}}/cheri-elf-flags-err.s.tmp-cheri128-hybrid-lib.o: ABI 'n64' is incompatible with target ABI 'purecap'
13799

138100
# TODO: should those files actually link?
139-
# CHERI256-HYBRID-vs-MIPS: target ISA 'cheri256' is incompatible with 'mips64': {{.*}}/cheri-elf-flags-err.s.tmp-mips64.o
140101
# CHERI128-HYBRID-vs-MIPS: target ISA 'cheri128' is incompatible with 'mips64': {{.*}}/cheri-elf-flags-err.s.tmp-mips64.o
141102

lld/test/ELF/cheri/chericap-alignment.s

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri256 -target-abi purecap -position-independent -filetype=obj -defsym=FIRST=1 -o %t1.o %s
2-
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri256 -target-abi purecap -position-independent -filetype=obj -defsym=FIRST=0 -o %t2.o %s
1+
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri128 -target-abi purecap -position-independent -filetype=obj -defsym=FIRST=1 -o %t1.o %s
2+
# RUN: llvm-mc -triple=mips64-unknown-freebsd -mcpu=cheri128 -target-abi purecap -position-independent -filetype=obj -defsym=FIRST=0 -o %t2.o %s
33
# RUN: ld.lld %t1.o %t2.o -shared -o %t.so
44
# RUN: llvm-objdump --cap-relocs -s -t %t.so | FileCheck %s
55

@@ -20,11 +20,9 @@ cap:
2020

2121
# CHECK-LABEL: SYMBOL TABLE:
2222
# CHECK: 0000000000000000 *UND* 0000000000000000 foo
23-
# CHECK: 0000000000020400 g .data 0000000000000000 cap
24-
# ^----- Ensure that this is aligned to 0x20
23+
# CHECK: 00000000000203f0 g .data 0000000000000000 cap
24+
# ^----- Ensure that this is aligned to 0x10
2525

2626
# CHECK-LABEL: Contents of section .data:
2727
# CHECK-NEXT: 203e0 00000000 00001234 00000000 00000000
28-
# CHECK-NEXT: 203f0 00000000 00000000 00000000 00000000
29-
# CHECK-NEXT: 20400 00000000 00000000 cacacaca cacacaca
30-
# CHECK-NEXT: 20410 cacacaca cacacaca cacacaca cacacaca
28+
# CHECK-NEXT: 203f0 00000000 00000000 cacacaca cacacaca

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,9 +3547,6 @@ class LLVM_ABI TargetLoweringBase {
35473547
// Return true if the target has a capability set address instruction.
35483548
virtual bool hasCapabilitySetAddress() const { return false; }
35493549
MVT cheriCapabilityType() const { return CapType; }
3550-
bool cheriCapabilityTypeHasPreciseBounds() const {
3551-
return CapTypeHasPreciseBounds;
3552-
}
35533550
bool supportsUnalignedCapabilityMemOps() const {
35543551
return SupportsUnalignedCapabilityMemOps;
35553552
}
@@ -3985,10 +3982,6 @@ class LLVM_ABI TargetLoweringBase {
39853982
/// Should be one of c64/c128/c256
39863983
MVT CapType = MVT();
39873984

3988-
/// Whether the CHERI capability type supports precise bounds for any
3989-
/// allocation. Defaults to false for safety over efficiency.
3990-
bool CapTypeHasPreciseBounds = false;
3991-
39923985
/// Whether CHERI Capability loads/stores can be used with unaligned addresses
39933986
/// This makes it possible to do a tag-preserving copy even if the alignment
39943987
/// is not statically known to be at least capability aligned.

llvm/include/llvm/CodeGen/ValueTypes.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ def amdgpuBufferStridedPointer : ValueType<192, 240>;
352352
def aarch64mfp8 : ValueType<8, 241>; // 8-bit value in FPR (AArch64)
353353

354354
def c64 : VTCapability<64, !add(aarch64mfp8.Value, 1)>; // 64-bit capability value
355-
def c128 : VTCapability<128, !add(c64.Value, 1)>; // 128-bit capability value
356-
def c256 : VTCapability<256, !add(c128.Value, 1)>; // 256-bit capability value
355+
def c128 : VTCapability<128, !add(c64.Value, 1)>; // 128-bit capability value
357356

358357
// Pseudo valuetype mapped to the current capability pointer size.
359358
def cPTR : VTAny<247>;

llvm/include/llvm/CodeGenTypes/MachineValueType.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,6 @@ namespace llvm {
467467
return MVT::c64;
468468
case 128:
469469
return MVT::c128;
470-
case 256:
471-
return MVT::c256;
472470
}
473471
}
474472

llvm/lib/CodeGen/CheriBoundAllocas.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,12 @@ class CheriBoundAllocasImpl : public InstVisitor<CheriBoundAllocasImpl> {
189189

190190
// For imprecise capabilities, we need to increase the alignment for
191191
// on-stack allocations to ensure that we can create precise bounds.
192-
if (!TLI->cheriCapabilityTypeHasPreciseBounds()) {
193-
// If not a constant then definitely a DYNAMIC_STACKALLOC; alignment
194-
// requirements will be added later during legalisation.
195-
if (ConstantInt *CI = dyn_cast<ConstantInt>(ArraySize)) {
196-
uint64_t AllocaSize = DL.getTypeAllocSize(AllocationTy);
197-
AllocaSize *= CI->getValue().getLimitedValue();
198-
ForcedAlignment = TLI->getAlignmentForPreciseBounds(AllocaSize);
199-
}
192+
// If not a constant then definitely a DYNAMIC_STACKALLOC; alignment
193+
// requirements will be added later during legalisation.
194+
if (ConstantInt *CI = dyn_cast<ConstantInt>(ArraySize)) {
195+
uint64_t AllocaSize = DL.getTypeAllocSize(AllocationTy);
196+
AllocaSize *= CI->getValue().getLimitedValue();
197+
ForcedAlignment = TLI->getAlignmentForPreciseBounds(AllocaSize);
200198
}
201199
if (ForcedAlignment > AI->getAlign())
202200
AI->setAlignment(ForcedAlignment);

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,18 +1835,11 @@ void SelectionDAGLegalize::ExpandDYNAMIC_STACKALLOC(SDNode* Node,
18351835
SizeVT);
18361836

18371837
Tmp1 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, SizeVT, GetAddr, SP);
1838-
1839-
if (TLI.cheriCapabilityTypeHasPreciseBounds()) {
1840-
Tmp2 = Size;
1841-
Tmp3 = DAG.getConstant(-Alignment.value(), dl, SizeVT);
1842-
} else {
1843-
Tmp2 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, SizeVT, CRRL, Size);
1844-
Tmp3 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, SizeVT, CRAM, Size);
1845-
}
1838+
Tmp2 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, SizeVT, CRRL, Size);
1839+
Tmp3 = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, SizeVT, CRAM, Size);
18461840

18471841
Tmp1 = DAG.getNode(Opc, dl, SizeVT, Tmp1, Tmp2);
1848-
if (Alignment > StackAlign || !TLI.cheriCapabilityTypeHasPreciseBounds())
1849-
Tmp1 = DAG.getNode(ISD::AND, dl, SizeVT, Tmp1, Tmp3);
1842+
Tmp1 = DAG.getNode(ISD::AND, dl, SizeVT, Tmp1, Tmp3);
18501843

18511844
Tmp1 =
18521845
DAG.getNode(ISD::INTRINSIC_WO_CHAIN, dl, VT, SetAddr, SP, Tmp1);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8514,7 +8514,7 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, const SDLoc &dl,
85148514
// TODO: the frontend/optimization passes probably shouldn't emit
85158515
// must-preserve-tags for such small memcpys
85168516
auto CapTy = TLI.cheriCapabilityType();
8517-
if (CapTy.isValid() && !Op.isMemset()) {
8517+
if (DL.hasCheriCapabilities() && CapTy.isValid() && !Op.isMemset()) {
85188518
const uint64_t CapSize = CapTy.getStoreSize();
85198519
if (PreserveTags == PreserveCheriTags::Required && !ReachedLimit &&
85208520
Size >= CapSize && (!FoundLowering || !MemOps[0].isFatPointer())) {
@@ -8743,7 +8743,7 @@ static SDValue getMemmoveLoadsAndStores(
87438743
// TODO: the frontend probably shouldn't emit must-preserve-tags for such
87448744
// small memcpys
87458745
auto CapTy = TLI.cheriCapabilityType();
8746-
if (CapTy.isValid()) {
8746+
if (DL.hasCheriCapabilities() && CapTy.isValid()) {
87478747
const uint64_t CapSize = CapTy.getStoreSize();
87488748
if (PreserveTags == PreserveCheriTags::Required && !ReachedLimit &&
87498749
Size >= CapSize && (!FoundLowering || !MemOps[0].isFatPointer())) {

0 commit comments

Comments
 (0)