[llvm] f9c349f - [RISCV] Create mapping symbols with non-unique names
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 23:07:30 PDT 2024
Author: Fangrui Song
Date: 2024-07-22T23:07:27-07:00
New Revision: f9c349fd4c9cd0e921bed9a5f02b15ff82a2f248
URL: https://github.com/llvm/llvm-project/commit/f9c349fd4c9cd0e921bed9a5f02b15ff82a2f248
DIFF: https://github.com/llvm/llvm-project/commit/f9c349fd4c9cd0e921bed9a5f02b15ff82a2f248.diff
LOG: [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: https://github.com/llvm/llvm-project/pull/99903
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
llvm/test/MC/RISCV/mapping-across-sections.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index 3ac81fd2ddb00..2c2aa8af8955c 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
@@ -132,7 +132,6 @@ void RISCVTargetELFStreamer::emitDirectiveVariantCC(MCSymbol &Symbol) {
void RISCVELFStreamer::reset() {
static_cast<RISCVTargetStreamer *>(getTargetStreamer())->reset();
MCELFStreamer::reset();
- MappingSymbolCounter = 0;
LastMappingSymbols.clear();
LastEMS = EMS_None;
}
@@ -152,8 +151,7 @@ void RISCVELFStreamer::emitInstructionsMappingSymbol() {
}
void RISCVELFStreamer::emitMappingSymbol(StringRef Name) {
- auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
- Name + "." + Twine(MappingSymbolCounter++)));
+ auto *Symbol = cast<MCSymbolELF>(getContext().createLocalSymbol(Name));
emitLabel(Symbol);
Symbol->setType(ELF::STT_NOTYPE);
Symbol->setBinding(ELF::STB_LOCAL);
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
index 40c6b5ac3dcc8..b06760859483d 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
@@ -22,7 +22,6 @@ class RISCVELFStreamer : public MCELFStreamer {
enum ElfMappingSymbol { EMS_None, EMS_Instructions, EMS_Data };
- int64_t MappingSymbolCounter = 0;
DenseMap<const MCSection *, ElfMappingSymbol> LastMappingSymbols;
ElfMappingSymbol LastEMS = EMS_None;
diff --git a/llvm/test/MC/RISCV/mapping-across-sections.s b/llvm/test/MC/RISCV/mapping-across-sections.s
index 700e86a0eb70e..11b05a616bdcf 100644
--- a/llvm/test/MC/RISCV/mapping-across-sections.s
+++ b/llvm/test/MC/RISCV/mapping-across-sections.s
@@ -1,5 +1,5 @@
-# RUN: llvm-mc -triple=riscv32 -filetype=obj < %s | llvm-readelf -Ss - | FileCheck %s
-# RUN: llvm-mc -triple=riscv64 -filetype=obj < %s | llvm-readelf -Ss - | FileCheck %s
+# RUN: llvm-mc -triple=riscv32 -filetype=obj %s | llvm-readelf -Ss - | FileCheck %s
+# RUN: llvm-mc -triple=riscv64 -filetype=obj %s | llvm-readelf -Ss - | FileCheck %s
.text
nop
@@ -28,6 +28,6 @@
# CHECK: [[#STARTS_DATA:]]] .starts_data
# CHECK: Value Size Type Bind Vis Ndx Name
-# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#TEXT]] $x
-# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#WIBBLE]] $x
-# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#STARTS_DATA]] $d
+# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#TEXT]] $x{{$}}
+# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#WIBBLE]] $x{{$}}
+# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT [[#STARTS_DATA]] $d{{$}}
More information about the llvm-commits
mailing list