Skip to content

Commit f9c349f

Browse files
authored
[RISCV] Create mapping symbols with non-unique names
Similar to #99836 for AArch64. Non-unique names save .strtab space and match GNU assembler. Pull Request: #99903
1 parent 2114947 commit f9c349f

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ void RISCVTargetELFStreamer::emitDirectiveVariantCC(MCSymbol &Symbol) {
132132
void RISCVELFStreamer::reset() {
133133
static_cast<RISCVTargetStreamer *>(getTargetStreamer())->reset();
134134
MCELFStreamer::reset();
135-
MappingSymbolCounter = 0;
136135
LastMappingSymbols.clear();
137136
LastEMS = EMS_None;
138137
}
@@ -152,8 +151,7 @@ void RISCVELFStreamer::emitInstructionsMappingSymbol() {
152151
}
153152

154153
void RISCVELFStreamer::emitMappingSymbol(StringRef Name) {
155-
auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
156-
Name + "." + Twine(MappingSymbolCounter++)));
154+
auto *Symbol = cast<MCSymbolELF>(getContext().createLocalSymbol(Name));
157155
emitLabel(Symbol);
158156
Symbol->setType(ELF::STT_NOTYPE);
159157
Symbol->setBinding(ELF::STB_LOCAL);

llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class RISCVELFStreamer : public MCELFStreamer {
2222

2323
enum ElfMappingSymbol { EMS_None, EMS_Instructions, EMS_Data };
2424

25-
int64_t MappingSymbolCounter = 0;
2625
DenseMap<const MCSection *, ElfMappingSymbol> LastMappingSymbols;
2726
ElfMappingSymbol LastEMS = EMS_None;
2827

llvm/test/MC/RISCV/mapping-across-sections.s

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# RUN: llvm-mc -triple=riscv32 -filetype=obj < %s | llvm-readelf -Ss - | FileCheck %s
2-
# RUN: llvm-mc -triple=riscv64 -filetype=obj < %s | llvm-readelf -Ss - | FileCheck %s
1+
# RUN: llvm-mc -triple=riscv32 -filetype=obj %s | llvm-readelf -Ss - | FileCheck %s
2+
# RUN: llvm-mc -triple=riscv64 -filetype=obj %s | llvm-readelf -Ss - | FileCheck %s
33

44
.text
55
nop
@@ -28,6 +28,6 @@
2828
# CHECK: [[#STARTS_DATA:]]] .starts_data
2929

3030
# CHECK: Value Size Type Bind Vis Ndx Name
31-
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#TEXT]] $x
32-
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#WIBBLE]] $x
33-
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#STARTS_DATA]] $d
31+
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#TEXT]] $x{{$}}
32+
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#WIBBLE]] $x{{$}}
33+
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#STARTS_DATA]] $d{{$}}

0 commit comments

Comments
 (0)