Skip to content

Commit d2e741e

Browse files
committed
[CHERI] Reuse the $local function symbol for landing pads
There is no need to define our own non-preemptible local symbol since upstream now has the $local non-preemptible symbol. Since the latest merge it also includes my upstreamed fixes to always have the right type and size attributes, so it is safe to use here.
1 parent c9efae8 commit d2e741e

File tree

11 files changed

+59
-79
lines changed

11 files changed

+59
-79
lines changed

lld/test/ELF/cheri/exception-table.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
// RUN: llvm-readobj -r %t-riscv64.o | FileCheck %s --check-prefix=RV64-OBJ-RELOCS
55
/// Should have two relocations against a local alias for _Z4testll
66
// MIPS-OBJ-RELOCS: Section ({{.+}}) .rela.gcc_except_table {
7-
// MIPS-OBJ-RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z4testll$eh_alias
8-
// MIPS-OBJ-RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z4testll$eh_alias
7+
// MIPS-OBJ-RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z4testll$local
8+
// MIPS-OBJ-RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z4testll$local
99
// MIPS-OBJ-RELOCS-NEXT: }
1010
// RV64-OBJ-RELOCS: Section ({{.+}}) .rela.gcc_except_table {
1111
// RV64-OBJ-RELOCS-NEXT: R_RISCV_ADD32 - 0x0
1212
// RV64-OBJ-RELOCS-NEXT: R_RISCV_SUB32 - 0x0
1313
// RV64-OBJ-RELOCS-NEXT: R_RISCV_ADD32 - 0x0
1414
// RV64-OBJ-RELOCS-NEXT: R_RISCV_SUB32 - 0x0
15-
// RV64-OBJ-RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z4testll$eh_alias
15+
// RV64-OBJ-RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z4testll$local
1616
// RV64-OBJ-RELOCS-NEXT: R_RISCV_ADD32 - 0x0
1717
// RV64-OBJ-RELOCS-NEXT: R_RISCV_SUB32 - 0x0
1818
// RV64-OBJ-RELOCS-NEXT: R_RISCV_ADD32 - 0x0
1919
// RV64-OBJ-RELOCS-NEXT: R_RISCV_SUB32 - 0x0
20-
// RV64-OBJ-RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z4testll$eh_alias
20+
// RV64-OBJ-RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z4testll$local
2121
// RV64-OBJ-RELOCS-NEXT: R_RISCV_ADD32 - 0x0
2222
// RV64-OBJ-RELOCS-NEXT: R_RISCV_SUB32 - 0x0
2323
// RV64-OBJ-RELOCS-NEXT: R_RISCV_ADD32 - 0x0
@@ -73,16 +73,16 @@
7373

7474
/// Local relocations for exception handling:
7575
// MIPS-RELOCS-NEXT: CHERI __cap_relocs [
76-
// MIPS-RELOCS-NEXT: 0x02{{.+}} Base: 0x1{{.+}} (.L_Z4testll$eh_alias+132) Length: 164 Perms: Function
77-
// MIPS-RELOCS-NEXT: 0x02{{.+}} Base: 0x1{{.+}} (.L_Z4testll$eh_alias+100) Length: 164 Perms: Function
76+
// MIPS-RELOCS-NEXT: 0x02{{.+}} Base: 0x1{{.+}} (.L_Z4testll$local+132) Length: 164 Perms: Function
77+
// MIPS-RELOCS-NEXT: 0x02{{.+}} Base: 0x1{{.+}} (.L_Z4testll$local+100) Length: 164 Perms: Function
7878
// MIPS-RELOCS-NEXT: ]
7979

8080
/// Should also emit __cap_relocs for RISC-V:
8181
// RUN: ld.lld -shared %t-riscv64.o -o %t.so
8282
// RUN: llvm-readelf -r --cap-relocs %t.so | FileCheck %s --check-prefixes=RV64-RELOCS
8383
// RV64-RELOCS: CHERI __cap_relocs [
84-
// RV64-RELOCS-NEXT: 0x002{{.+}} Base: 0x1{{.+}} (.L_Z4testll$eh_alias+96) Length: 120 Perms: Function
85-
// RV64-RELOCS-NEXT: 0x002{{.+}} Base: 0x1{{.+}} (.L_Z4testll$eh_alias+72) Length: 120 Perms: Function
84+
// RV64-RELOCS-NEXT: 0x002{{.+}} Base: 0x1{{.+}} (.L_Z4testll$local+96) Length: 120 Perms: Function
85+
// RV64-RELOCS-NEXT: 0x002{{.+}} Base: 0x1{{.+}} (.L_Z4testll$local+72) Length: 120 Perms: Function
8686
// RV64-RELOCS-NEXT: ]
8787

8888
long external_fn(long arg);

llvm/include/llvm/CodeGen/AsmPrinter.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,8 @@ class AsmPrinter : public MachineFunctionPass {
199199
protected:
200200
MCSymbol *CurrentFnBegin = nullptr;
201201

202-
/// The symbol used to represent the start of the current function for the
203-
/// purpose of exception handling for pure-capability CHERI targets.
204-
MCSymbol *CurrentFnBeginForEH = nullptr;
205-
206202
/// For dso_local functions, the current $local alias for the function.
203+
/// Also used for exception handling for pure-capability CHERI targets.
207204
MCSymbol *CurrentFnBeginLocal = nullptr;
208205

209206
/// A vector of all debug/EH info emitters we should use. This vector
@@ -329,7 +326,10 @@ class AsmPrinter : public MachineFunctionPass {
329326
/// Similar to getSymbol() but preferred for references. On ELF, this uses a
330327
/// local symbol if a reference to GV is guaranteed to be resolved to the
331328
/// definition in the same module.
332-
MCSymbol *getSymbolPreferLocal(const GlobalValue &GV) const;
329+
/// If \p Force is set to true, return a local alias if possible even if the
330+
/// normal heuristics say it is not beneficial.
331+
MCSymbol *getSymbolPreferLocal(const GlobalValue &GV,
332+
bool Force = false) const;
333333

334334
bool doesDwarfUseRelocationsAcrossSections() const {
335335
return DwarfUsesRelocationsAcrossSections;

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

+10-28
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,8 @@ MCSymbol *AsmPrinter::getSymbol(const GlobalValue *GV) const {
646646
return TM.getSymbol(GV);
647647
}
648648

649-
MCSymbol *AsmPrinter::getSymbolPreferLocal(const GlobalValue &GV) const {
649+
MCSymbol *AsmPrinter::getSymbolPreferLocal(const GlobalValue &GV,
650+
bool Force) const {
650651
// On ELF, use .Lfoo$local if GV is a non-interposable GlobalObject with an
651652
// exact definion (intersection of GlobalValue::hasExactDefinition() and
652653
// !isInterposable()). These linkages include: external, appending, internal,
@@ -656,8 +657,8 @@ MCSymbol *AsmPrinter::getSymbolPreferLocal(const GlobalValue &GV) const {
656657
// assumed it.
657658
if (TM.getTargetTriple().isOSBinFormatELF() && GV.canBenefitFromLocalAlias()) {
658659
const Module &M = *GV.getParent();
659-
if (TM.getRelocationModel() != Reloc::Static &&
660-
M.getPIELevel() == PIELevel::Default && GV.isDSOLocal())
660+
if (Force || (TM.getRelocationModel() != Reloc::Static &&
661+
M.getPIELevel() == PIELevel::Default && GV.isDSOLocal()))
661662
return getSymbolWithGlobalValueBase(&GV, "$local");
662663
}
663664
return TM.getSymbol(&GV);
@@ -1008,22 +1009,9 @@ void AsmPrinter::emitFunctionHeader() {
10081009
if (MAI->useAssignmentForEHBegin()) {
10091010
MCSymbol *CurPos = OutContext.createTempSymbol();
10101011
OutStreamer->emitLabel(CurPos);
1011-
if (CurrentFnBeginForEH) {
1012-
OutStreamer->emitAssignment(
1013-
CurrentFnBeginForEH, MCSymbolRefExpr::create(CurPos, OutContext));
1014-
if (MAI->hasDotTypeDotSizeDirective())
1015-
OutStreamer->emitSymbolAttribute(CurrentFnBeginForEH,
1016-
MCSA_ELF_TypeFunction);
1017-
}
10181012
OutStreamer->emitAssignment(CurrentFnBegin,
10191013
MCSymbolRefExpr::create(CurPos, OutContext));
10201014
} else {
1021-
if (CurrentFnBeginForEH) {
1022-
OutStreamer->emitLabel(CurrentFnBeginForEH);
1023-
if (MAI->hasDotTypeDotSizeDirective())
1024-
OutStreamer->emitSymbolAttribute(CurrentFnBeginForEH,
1025-
MCSA_ELF_TypeFunction);
1026-
}
10271015
OutStreamer->emitLabel(CurrentFnBegin);
10281016
}
10291017
}
@@ -1063,6 +1051,8 @@ void AsmPrinter::emitFunctionHeader() {
10631051
}
10641052
}
10651053

1054+
static bool needFuncLabelsForEH(const MachineFunction &MF);
1055+
10661056
/// EmitFunctionEntryLabel - Emit the label that is the entrypoint for the
10671057
/// function. This can be overridden by targets as required to do custom stuff.
10681058
void AsmPrinter::emitFunctionEntryLabel() {
@@ -1077,7 +1067,10 @@ void AsmPrinter::emitFunctionEntryLabel() {
10771067
OutStreamer->emitLabel(CurrentFnSym);
10781068

10791069
if (TM.getTargetTriple().isOSBinFormatELF()) {
1080-
MCSymbol *Sym = getSymbolPreferLocal(MF->getFunction());
1070+
// For CHERI purecap exception handling, we always have to use a local
1071+
// alias even if the function is not dso_local.
1072+
bool ForceLocal = MAI->isCheriPurecapABI() && needFuncLabelsForEH(*MF);
1073+
MCSymbol *Sym = getSymbolPreferLocal(MF->getFunction(), ForceLocal);
10811074
if (Sym != CurrentFnSym) {
10821075
cast<MCSymbolELF>(Sym)->setType(ELF::STT_FUNC);
10831076
CurrentFnBeginLocal = Sym;
@@ -1850,8 +1843,6 @@ void AsmPrinter::emitFunctionBody() {
18501843
MCSymbolRefExpr::create(CurrentFnEnd, OutContext),
18511844
MCSymbolRefExpr::create(CurrentFnSymForSize, OutContext), OutContext);
18521845
OutStreamer->emitELFSize(CurrentFnSym, SizeExp);
1853-
if (CurrentFnBeginForEH)
1854-
OutStreamer->emitELFSize(CurrentFnBeginForEH, SizeExp);
18551846
if (CurrentFnBeginLocal)
18561847
OutStreamer->emitELFSize(CurrentFnBeginLocal, SizeExp);
18571848
}
@@ -2430,7 +2421,6 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
24302421

24312422
CurrentFnSymForSize = CurrentFnSym;
24322423
CurrentFnBegin = nullptr;
2433-
CurrentFnBeginForEH = nullptr;
24342424
CurrentFnBeginLocal = nullptr;
24352425
CurrentSectionBeginSym = nullptr;
24362426
MBBSectionRanges.clear();
@@ -2444,14 +2434,6 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
24442434
CurrentFnBegin = createTempSymbol("func_begin");
24452435
if (NeedsLocalForSize)
24462436
CurrentFnSymForSize = CurrentFnBegin;
2447-
// In the pure-capability ABI we have to create dynamic relocations for the
2448-
// landing pads. To avoid creating an (unnecessary and incorrect) dynamic
2449-
// relocation with a non-zero addend, we need to ensure that the target
2450-
// symbol is non-preemptible by creating a local alias for the function.
2451-
// See https://github.com/CTSRD-CHERI/llvm-project/issues/512.
2452-
// TODO: could probably omit this for !F.isInterposable()?
2453-
if (MAI->isCheriPurecapABI() && needFuncLabelsForEH(MF))
2454-
CurrentFnBeginForEH = getSymbolWithGlobalValueBase(&F, "$eh_alias");
24552437
}
24562438

24572439
ORE = &getAnalysis<MachineOptimizationRemarkEmitterPass>().getORE();

llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ void AsmPrinter::emitCallSiteCheriCapability(const MCSymbol *Hi,
236236
// this would result in EmitCheriCapability() creating a relocation against
237237
// section plus offset rather than function + offset. We need the right
238238
// bounds and permissions info and need to use a non-preemptible alias.
239-
assert(CurrentFnBeginForEH && "Missing local function entry alias for EH!");
240-
OutStreamer->EmitCheriCapability(CurrentFnBeginForEH, DiffToStart,
239+
assert(CurrentFnBeginLocal && "Missing local function entry alias for EH!");
240+
OutStreamer->EmitCheriCapability(CurrentFnBeginLocal, DiffToStart,
241241
TLOF.getCheriCapabilitySize(TM));
242242
}
243243

llvm/lib/Target/Mips/MipsAsmPrinter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ void MipsAsmPrinter::emitFunctionEntryLabel() {
428428
TS.emitDirectiveSetNoMips16();
429429

430430
TS.emitDirectiveEnt(*CurrentFnSym);
431-
OutStreamer->emitLabel(CurrentFnSym);
431+
AsmPrinter::emitFunctionEntryLabel();
432432
}
433433

434434
/// EmitFunctionBodyStart - Targets can override this to emit stuff before

llvm/test/CodeGen/CHERI-Generic/Inputs/landingpad-non-preemptible.ll

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; RUN: llc @PURECAP_HARDFLOAT_ARGS@ < %s -o - | FileCheck %s
2-
; RUN: llc @PURECAP_HARDFLOAT_ARGS@ < %s -o - -filetype=obj | llvm-readobj --relocs --symbols - | FileCheck %s --check-prefix=RELOCS
1+
; RUN: llc @PURECAP_HARDFLOAT_ARGS@ --relocation-model=pic < %s -o - | FileCheck %s
2+
; RUN: llc @PURECAP_HARDFLOAT_ARGS@ --relocation-model=pic < %s -o - -filetype=obj | llvm-readobj --relocs --symbols - | FileCheck %s --check-prefix=RELOCS
33
; Capabilities for exception landing pads were using preemptible relocations such as
44
; .chericap foo + .Ltmp - .Lfunc_begin instead of using a local alias.
55
; https://github.com/CTSRD-CHERI/llvm-project/issues/512
@@ -58,7 +58,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
5858
; UTC_ARGS: --disable
5959
; CHECK: .Lfunc_end0:
6060
; CHECK-NEXT: .size _Z8do_catchv, .Lfunc_end0-_Z8do_catchv
61-
; CHECK-NEXT: .size .L_Z8do_catchv$eh_alias, .Lfunc_end0-_Z8do_catchv
61+
; CHECK-NEXT: .size .L_Z8do_catchv$local, .Lfunc_end0-_Z8do_catchv
6262

6363
; CHECK: GCC_except_table0:
6464
; CHECK-NEXT: .Lexception0:
@@ -76,7 +76,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
7676
; Note: RISC-V uses DW_EH_PE_udata4, so the 0xc marker uses 4 bytes instead of 1
7777
; CHECK-NEXT: [[SMALL_CS_DIRECTIVE:(\.byte)|(\.word)]] 12 # (landing pad is a capability)
7878
; Note: the following line should not be using _Z8do_catchv, but a local alias
79-
; CHECK-NEXT: .chericap .L_Z8do_catchv$eh_alias + .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
79+
; CHECK-NEXT: .chericap .L_Z8do_catchv$local + .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
8080
; CHECK-NEXT: .byte 3 # On action: 2
8181
; CHECK-NEXT: [[CS_DIRECTIVE]] .Ltmp1-.Lfunc_begin0 # >> Call Site 2 <<
8282
; CHECK-NEXT: [[CS_DIRECTIVE]] .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
@@ -103,13 +103,13 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
103103

104104
; RELOCS-LABEL: Relocations [
105105
; RELOCS-LABEL: Section ({{.+}}) .rela.gcc_except_table {
106-
@IF-MIPS@; RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z8do_catchv$eh_alias 0x4C
106+
@IF-MIPS@; RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z8do_catchv$local 0x4C
107107
@IF-MIPS@; RELOCS-NEXT: R_MIPS_PC32/R_MIPS_NONE/R_MIPS_NONE .L_ZTIi.DW.stub 0x0
108108
@IF-RISCV@; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
109109
@IF-RISCV@; RELOCS-NEXT: R_RISCV_SUB32 - 0x0
110110
@IF-RISCV@; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
111111
@IF-RISCV@; RELOCS-NEXT: R_RISCV_SUB32 - 0x0
112-
@IF-RISCV@; RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z8do_catchv$eh_alias 0x34
112+
@IF-RISCV@; RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z8do_catchv$local 0x34
113113
@IF-RISCV@; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
114114
@IF-RISCV@; RELOCS-NEXT: R_RISCV_SUB32 - 0x0
115115
@IF-RISCV@; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
@@ -119,7 +119,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
119119

120120
; The local alias should have the same type and non-zero size as the real function:
121121
; RELOCS: Symbol {
122-
; RELOCS-LABEL: Name: .L_Z8do_catchv$eh_alias (
122+
; RELOCS-LABEL: Name: .L_Z8do_catchv$local (
123123
; RELOCS-NEXT: Value: 0x0
124124
; RELOCS-NEXT: Size: [[FN_SIZE:[1-9][0-9]*]]
125125
; RELOCS-NEXT: Binding: Local (0x0)

llvm/test/CodeGen/CHERI-Generic/MIPS/landingpad-non-preemptible.ll

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
22
; DO NOT EDIT -- This file was generated from test/CodeGen/CHERI-Generic/Inputs/landingpad-non-preemptible.ll
3-
; RUN: llc -mtriple=mips64 -mcpu=cheri128 -mattr=+cheri128 --relocation-model=pic -target-abi purecap < %s -o - | FileCheck %s
4-
; RUN: llc -mtriple=mips64 -mcpu=cheri128 -mattr=+cheri128 --relocation-model=pic -target-abi purecap < %s -o - -filetype=obj | llvm-readobj --relocs --symbols - | FileCheck %s --check-prefix=RELOCS
3+
; RUN: llc -mtriple=mips64 -mcpu=cheri128 -mattr=+cheri128 --relocation-model=pic -target-abi purecap --relocation-model=pic < %s -o - | FileCheck %s
4+
; RUN: llc -mtriple=mips64 -mcpu=cheri128 -mattr=+cheri128 --relocation-model=pic -target-abi purecap --relocation-model=pic < %s -o - -filetype=obj | llvm-readobj --relocs --symbols - | FileCheck %s --check-prefix=RELOCS
55
; Capabilities for exception landing pads were using preemptible relocations such as
66
; .chericap foo + .Ltmp - .Lfunc_begin instead of using a local alias.
77
; https://github.com/CTSRD-CHERI/llvm-project/issues/512
@@ -111,7 +111,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
111111
; UTC_ARGS: --disable
112112
; CHECK: .Lfunc_end0:
113113
; CHECK-NEXT: .size _Z8do_catchv, .Lfunc_end0-_Z8do_catchv
114-
; CHECK-NEXT: .size .L_Z8do_catchv$eh_alias, .Lfunc_end0-_Z8do_catchv
114+
; CHECK-NEXT: .size .L_Z8do_catchv$local, .Lfunc_end0-_Z8do_catchv
115115

116116
; CHECK: GCC_except_table0:
117117
; CHECK-NEXT: .Lexception0:
@@ -128,7 +128,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
128128
; Note: RISC-V uses DW_EH_PE_udata4, so the 0xc marker uses 4 bytes instead of 1
129129
; CHECK-NEXT: [[SMALL_CS_DIRECTIVE:(\.byte)|(\.word)]] 12 # (landing pad is a capability)
130130
; Note: the following line should not be using _Z8do_catchv, but a local alias
131-
; CHECK-NEXT: .chericap .L_Z8do_catchv$eh_alias + .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
131+
; CHECK-NEXT: .chericap .L_Z8do_catchv$local + .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
132132
; CHECK-NEXT: .byte 3 # On action: 2
133133
; CHECK-NEXT: [[CS_DIRECTIVE]] .Ltmp1-.Lfunc_begin0 # >> Call Site 2 <<
134134
; CHECK-NEXT: [[CS_DIRECTIVE]] .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
@@ -155,13 +155,13 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
155155

156156
; RELOCS-LABEL: Relocations [
157157
; RELOCS-LABEL: Section ({{.+}}) .rela.gcc_except_table {
158-
; RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z8do_catchv$eh_alias 0x4C
158+
; RELOCS-NEXT: R_MIPS_CHERI_CAPABILITY/R_MIPS_NONE/R_MIPS_NONE .L_Z8do_catchv$local 0x4C
159159
; RELOCS-NEXT: R_MIPS_PC32/R_MIPS_NONE/R_MIPS_NONE .L_ZTIi.DW.stub 0x0
160160
; RELOCS-NEXT: }
161161

162162
; The local alias should have the same type and non-zero size as the real function:
163163
; RELOCS: Symbol {
164-
; RELOCS-LABEL: Name: .L_Z8do_catchv$eh_alias (
164+
; RELOCS-LABEL: Name: .L_Z8do_catchv$local (
165165
; RELOCS-NEXT: Value: 0x0
166166
; RELOCS-NEXT: Size: [[FN_SIZE:[1-9][0-9]*]]
167167
; RELOCS-NEXT: Binding: Local (0x0)

llvm/test/CodeGen/CHERI-Generic/RISCV32/landingpad-non-preemptible.ll

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
22
; DO NOT EDIT -- This file was generated from test/CodeGen/CHERI-Generic/Inputs/landingpad-non-preemptible.ll
3-
; RUN: llc -mtriple=riscv32 --relocation-model=pic -target-abi il32pc64f -mattr=+xcheri,+cap-mode,+f < %s -o - | FileCheck %s
4-
; RUN: llc -mtriple=riscv32 --relocation-model=pic -target-abi il32pc64f -mattr=+xcheri,+cap-mode,+f < %s -o - -filetype=obj | llvm-readobj --relocs --symbols - | FileCheck %s --check-prefix=RELOCS
3+
; RUN: llc -mtriple=riscv32 --relocation-model=pic -target-abi il32pc64f -mattr=+xcheri,+cap-mode,+f --relocation-model=pic < %s -o - | FileCheck %s
4+
; RUN: llc -mtriple=riscv32 --relocation-model=pic -target-abi il32pc64f -mattr=+xcheri,+cap-mode,+f --relocation-model=pic < %s -o - -filetype=obj | llvm-readobj --relocs --symbols - | FileCheck %s --check-prefix=RELOCS
55
; Capabilities for exception landing pads were using preemptible relocations such as
66
; .chericap foo + .Ltmp - .Lfunc_begin instead of using a local alias.
77
; https://github.com/CTSRD-CHERI/llvm-project/issues/512
@@ -95,7 +95,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
9595
; UTC_ARGS: --disable
9696
; CHECK: .Lfunc_end0:
9797
; CHECK-NEXT: .size _Z8do_catchv, .Lfunc_end0-_Z8do_catchv
98-
; CHECK-NEXT: .size .L_Z8do_catchv$eh_alias, .Lfunc_end0-_Z8do_catchv
98+
; CHECK-NEXT: .size .L_Z8do_catchv$local, .Lfunc_end0-_Z8do_catchv
9999

100100
; CHECK: GCC_except_table0:
101101
; CHECK-NEXT: .Lexception0:
@@ -112,7 +112,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
112112
; Note: RISC-V uses DW_EH_PE_udata4, so the 0xc marker uses 4 bytes instead of 1
113113
; CHECK-NEXT: [[SMALL_CS_DIRECTIVE:(\.byte)|(\.word)]] 12 # (landing pad is a capability)
114114
; Note: the following line should not be using _Z8do_catchv, but a local alias
115-
; CHECK-NEXT: .chericap .L_Z8do_catchv$eh_alias + .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
115+
; CHECK-NEXT: .chericap .L_Z8do_catchv$local + .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2
116116
; CHECK-NEXT: .byte 3 # On action: 2
117117
; CHECK-NEXT: [[CS_DIRECTIVE]] .Ltmp1-.Lfunc_begin0 # >> Call Site 2 <<
118118
; CHECK-NEXT: [[CS_DIRECTIVE]] .Lfunc_end0-.Ltmp1 # Call between .Ltmp1 and .Lfunc_end0
@@ -143,7 +143,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
143143
; RELOCS-NEXT: R_RISCV_SUB32 - 0x0
144144
; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
145145
; RELOCS-NEXT: R_RISCV_SUB32 - 0x0
146-
; RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z8do_catchv$eh_alias 0x34
146+
; RELOCS-NEXT: R_RISCV_CHERI_CAPABILITY .L_Z8do_catchv$local 0x34
147147
; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
148148
; RELOCS-NEXT: R_RISCV_SUB32 - 0x0
149149
; RELOCS-NEXT: R_RISCV_ADD32 - 0x0
@@ -153,7 +153,7 @@ declare dso_local void @__cxa_end_catch() local_unnamed_addr addrspace(200)
153153

154154
; The local alias should have the same type and non-zero size as the real function:
155155
; RELOCS: Symbol {
156-
; RELOCS-LABEL: Name: .L_Z8do_catchv$eh_alias (
156+
; RELOCS-LABEL: Name: .L_Z8do_catchv$local (
157157
; RELOCS-NEXT: Value: 0x0
158158
; RELOCS-NEXT: Size: [[FN_SIZE:[1-9][0-9]*]]
159159
; RELOCS-NEXT: Binding: Local (0x0)

0 commit comments

Comments
 (0)