Skip to content

Commit 36dc399

Browse files
MaskRayyuxuanchen1997
authored andcommitted
[RISCV] Create mapping symbols with non-unique names
Summary: Similar to #99836 for AArch64. Non-unique names save .strtab space and match GNU assembler. Pull Request: #99903 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251462
1 parent 9e60447 commit 36dc399

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

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

+1-3
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

-1
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

+5-5
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)