[llvm] [RISCV] Create mapping symbols with non-unique names (PR #99903)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 10:12:38 PDT 2024
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/99903
Similar to #99836 for AArch64.
Non-unique names save .strtab space and match GNU assembler.
>From 0a153c7267aa5fa07ce156fcf8156e4dc49527aa Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Mon, 22 Jul 2024 10:12:28 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
.../lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp | 4 +---
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h | 1 -
llvm/test/MC/RISCV/mapping-across-sections.s | 10 +++++-----
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
index 87c5a756e0258..0100e0614d619 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