-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[ARM] Create mapping symbols with non-unique names #99906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ARM] Create mapping symbols with non-unique names #99906
Conversation
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-backend-arm @llvm/pr-subscribers-debuginfo Author: Fangrui Song (MaskRay) ChangesSimilar to #99836 for AArch64. Non-unique names save .strtab space and match GNU assembler. Full diff: https://github.com/llvm/llvm-project/pull/99906.diff 12 Files Affected:
diff --git a/lld/test/ELF/arm-cmse-implib.s b/lld/test/ELF/arm-cmse-implib.s
index 581bff9dd8536..60a68b0226c3d 100644
--- a/lld/test/ELF/arm-cmse-implib.s
+++ b/lld/test/ELF/arm-cmse-implib.s
@@ -53,8 +53,8 @@ secure_entry:
// CHECK1-NEXT: Num: Value Size Type Bind Vis Ndx Name
// CHECK1-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
// CHECK1-NEXT: 1: 00020000 0 NOTYPE LOCAL DEFAULT 2 $t
-// CHECK1-NEXT: 2: 00008000 0 NOTYPE LOCAL DEFAULT 1 $t.0
-// CHECK1-NEXT: 3: 00008004 0 NOTYPE LOCAL DEFAULT 1 $t.0
+// CHECK1-NEXT: 2: 00008000 0 NOTYPE LOCAL DEFAULT 1 $t
+// CHECK1-NEXT: 3: 00008004 0 NOTYPE LOCAL DEFAULT 1 $t
// CHECK1-NEXT: 4: 00008001 2 FUNC GLOBAL DEFAULT 1 secure_entry
// CHECK1-NEXT: 5: 00020001 8 FUNC GLOBAL DEFAULT 2 foo
// CHECK1-NEXT: 6: 00008005 2 FUNC GLOBAL DEFAULT 1 __acle_se_foo
@@ -82,8 +82,8 @@ secure_entry:
// CHECK2-NEXT: Num: Value Size Type Bind Vis Ndx Name
// CHECK2-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
// CHECK2-NEXT: 1: 00020000 0 NOTYPE LOCAL DEFAULT 2 $t
-// CHECK2-NEXT: 2: 00008000 0 NOTYPE LOCAL DEFAULT 1 $t.0
-// CHECK2-NEXT: 3: 00008004 0 NOTYPE LOCAL DEFAULT 1 $t.0
+// CHECK2-NEXT: 2: 00008000 0 NOTYPE LOCAL DEFAULT 1 $t
+// CHECK2-NEXT: 3: 00008004 0 NOTYPE LOCAL DEFAULT 1 $t
// CHECK2-NEXT: 4: 00008001 2 FUNC GLOBAL DEFAULT 1 secure_entry
// CHECK2-NEXT: 5: 00020011 8 FUNC WEAK DEFAULT 2 baz
// CHECK2-NEXT: 6: 00008005 2 FUNC GLOBAL DEFAULT 1 __acle_se_baz
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index 649e6dc039830..5009215ae5e72 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -670,8 +670,7 @@ class ARMELFStreamer : public MCELFStreamer {
}
void 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);
@@ -679,8 +678,7 @@ class ARMELFStreamer : public MCELFStreamer {
}
void emitMappingSymbol(StringRef Name, MCDataFragment &F, uint64_t Offset) {
- auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
- Name + "." + Twine(MappingSymbolCounter++)));
+ auto *Symbol = cast<MCSymbolELF>(getContext().createLocalSymbol(Name));
emitLabelAtPos(Symbol, SMLoc(), F, Offset);
Symbol->setType(ELF::STT_NOTYPE);
Symbol->setBinding(ELF::STB_LOCAL);
diff --git a/llvm/test/DebugInfo/Symbolize/ELF/arm-mapping-symbol.s b/llvm/test/DebugInfo/Symbolize/ELF/arm-mapping-symbol.s
index 6e17ef29ae577..c810bc54ca62b 100644
--- a/llvm/test/DebugInfo/Symbolize/ELF/arm-mapping-symbol.s
+++ b/llvm/test/DebugInfo/Symbolize/ELF/arm-mapping-symbol.s
@@ -7,17 +7,17 @@
## addresses.
# RUN: llvm-nm --special-syms %t | FileCheck %s -check-prefix MAPPING_A
-# MAPPING_A: 00000004 t $a.1
-# MAPPING_A-NEXT: 00000000 t $d.0
-# MAPPING_A-NEXT: 00000008 t $d.2
+# MAPPING_A: 00000004 t $a
+# MAPPING_A-NEXT: 00000000 t $d
+# MAPPING_A-NEXT: 00000008 t $d
# MAPPING_A-NEXT: 00000000 T foo
# RUN: llvm-mc -filetype=obj -triple=thumbv7-none-linux %s -o %tthumb
# RUN: llvm-nm --special-syms %tthumb | FileCheck %s -check-prefix MAPPING_T
-# MAPPING_T: 00000000 t $d.0
-# MAPPING_T-NEXT: 00000006 t $d.2
-# MAPPING_T-NEXT: 00000004 t $t.1
+# MAPPING_T: 00000000 t $d
+# MAPPING_T-NEXT: 00000006 t $d
+# MAPPING_T-NEXT: 00000004 t $t
# MAPPING_T-NEXT: 00000000 T foo
# RUN: llvm-symbolizer --obj=%t 4 8 | FileCheck %s -check-prefix SYMBOL
diff --git a/llvm/test/MC/ARM/CheckDataSymbol.s b/llvm/test/MC/ARM/CheckDataSymbol.s
index 14ea92a943a1e..ec421f51395af 100644
--- a/llvm/test/MC/ARM/CheckDataSymbol.s
+++ b/llvm/test/MC/ARM/CheckDataSymbol.s
@@ -1,7 +1,7 @@
# RUN: llvm-mc -filetype=obj -assemble \
# RUN: -triple=arm-arm-none-eabi -mcpu=cortex-a9 %s -o - \
# RUN: | llvm-readobj -S --symbols - | FileCheck %s
-# CHECK: Name: $d.1 ({{[1-9][0-9]+}})
+# CHECK: Name: $d
# CHECK-NEXT: Value: 0x4
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local (0x0)
diff --git a/llvm/test/MC/ARM/data-in-code.ll b/llvm/test/MC/ARM/data-in-code.ll
index 2e107f250e05d..b755c3bb5cad4 100644
--- a/llvm/test/MC/ARM/data-in-code.ll
+++ b/llvm/test/MC/ARM/data-in-code.ll
@@ -72,7 +72,7 @@ exit:
;; TMB-NEXT: Section: [[MIXED_SECT:[^ ]+]]
;; TMB: Symbol {
-;; TMB: Name: $d.1
+;; TMB: Name: $d
;; TMB-NEXT: Value: 0x{{[0-9A-F]+}}
;; TMB-NEXT: Size: 0
;; TMB-NEXT: Binding: Local
diff --git a/llvm/test/MC/ARM/directive-arm-thumb-alignment.s b/llvm/test/MC/ARM/directive-arm-thumb-alignment.s
index b90c76d2b121c..0e798f67b48aa 100644
--- a/llvm/test/MC/ARM/directive-arm-thumb-alignment.s
+++ b/llvm/test/MC/ARM/directive-arm-thumb-alignment.s
@@ -10,12 +10,12 @@
@ CHECK: Num: Value Size Type Bind Vis Ndx Name
@ CHECK-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
@ CHECK-NEXT: 1: 00000001 0 FUNC LOCAL DEFAULT 2 aligned_thumb
-@ CHECK-NEXT: 2: 00000000 0 NOTYPE LOCAL DEFAULT 2 $t.0
+@ CHECK-NEXT: 2: 00000000 0 NOTYPE LOCAL DEFAULT 2 $t
@ CHECK-NEXT: 3: 00000004 0 FUNC LOCAL DEFAULT 2 thumb_to_arm
-@ CHECK-NEXT: 4: 00000004 0 NOTYPE LOCAL DEFAULT 2 $a.1
-@ CHECK-NEXT: 5: 00000008 0 NOTYPE LOCAL DEFAULT 2 $d.2
+@ CHECK-NEXT: 4: 00000004 0 NOTYPE LOCAL DEFAULT 2 $a
+@ CHECK-NEXT: 5: 00000008 0 NOTYPE LOCAL DEFAULT 2 $d
@ CHECK-NEXT: 6: 0000000b 0 FUNC LOCAL DEFAULT 2 unaligned_arm_to_thumb
-@ CHECK-NEXT: 7: 0000000a 0 NOTYPE LOCAL DEFAULT 2 $t.3
+@ CHECK-NEXT: 7: 0000000a 0 NOTYPE LOCAL DEFAULT 2 $t
.thumb
diff --git a/llvm/test/MC/ARM/multi-section-mapping.s b/llvm/test/MC/ARM/multi-section-mapping.s
index 6107f262b0b8c..ed531306042aa 100644
--- a/llvm/test/MC/ARM/multi-section-mapping.s
+++ b/llvm/test/MC/ARM/multi-section-mapping.s
@@ -1,4 +1,4 @@
-@ RUN: llvm-mc -triple=armv7-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s
+@ RUN: llvm-mc -triple=armv7-linux-gnueabi -filetype=obj < %s | llvm-objdump -t - | FileCheck %s --match-full-lines
.text
add r0, r0, r0
@@ -42,10 +42,10 @@
@ + .starts_thumb to have $t at 0
@ + .starts_data to have $d at 0
-@ CHECK: 00000000 l .text 00000000 $a.0
-@ CHECK-NEXT: 00000000 l .wibble 00000000 $a.1
-@ CHECK-NEXT: 00000000 l .starts_thumb 00000000 $t.2
-@ CHECK-NEXT: 00000008 l .text 00000000 $t.3
-@ CHECK-NEXT: 0000000a l .text 00000000 $d.4
+@ CHECK: 00000000 l .text 00000000 $a
+@ CHECK-NEXT: 00000000 l .wibble 00000000 $a
+@ CHECK-NEXT: 00000000 l .starts_thumb 00000000 $t
+@ CHECK-NEXT: 00000008 l .text 00000000 $t
+@ CHECK-NEXT: 0000000a l .text 00000000 $d
@ CHECK-NOT: ${{[adt]}}
diff --git a/llvm/test/MC/ARM/thumb-function-address.s b/llvm/test/MC/ARM/thumb-function-address.s
index 753a049137bbf..d69dcb6724019 100644
--- a/llvm/test/MC/ARM/thumb-function-address.s
+++ b/llvm/test/MC/ARM/thumb-function-address.s
@@ -35,8 +35,8 @@ label:
@ CHECK-NEXT: 00000000 0 NOTYPE LOCAL DEFAULT UND
@ CHECK-NEXT: 00000001 0 FUNC LOCAL DEFAULT 2 func_label
@ CHECK-NEXT: 00000001 0 FUNC LOCAL DEFAULT 2 foo_impl
-@ CHECK-NEXT: 00000000 0 NOTYPE LOCAL DEFAULT 2 $t.0
+@ CHECK-NEXT: 00000000 0 NOTYPE LOCAL DEFAULT 2 $t
@ CHECK-NEXT: 00000003 0 FUNC LOCAL DEFAULT 2 foo_resolver
@ CHECK-NEXT: 00000003 0 IFUNC LOCAL DEFAULT 2 foo
@ CHECK-NEXT: 00000004 0 FUNC LOCAL DEFAULT 2 label
-@ CHECK-NEXT: 00000008 0 NOTYPE LOCAL DEFAULT 2 $a.1
+@ CHECK-NEXT: 00000008 0 NOTYPE LOCAL DEFAULT 2 $a
diff --git a/llvm/test/MC/ARM/thumb-types.s b/llvm/test/MC/ARM/thumb-types.s
index cb1b47e1fa7fb..b965cd8accf05 100644
--- a/llvm/test/MC/ARM/thumb-types.s
+++ b/llvm/test/MC/ARM/thumb-types.s
@@ -3,22 +3,22 @@
@ CHECK: Num: Value Size Type Bind Vis Ndx Name
@ CHECK-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
@ CHECK-NEXT: 1: 00000001 0 FUNC LOCAL DEFAULT 2 implicit_function
-@ CHECK-NEXT: 2: 00000000 0 NOTYPE LOCAL DEFAULT 2 $t.0
+@ CHECK-NEXT: 2: 00000000 0 NOTYPE LOCAL DEFAULT 2 $t
@ CHECK-NEXT: 3: 00000002 0 OBJECT LOCAL DEFAULT 2 implicit_data
-@ CHECK-NEXT: 4: 00000002 0 NOTYPE LOCAL DEFAULT 2 $d.1
+@ CHECK-NEXT: 4: 00000002 0 NOTYPE LOCAL DEFAULT 2 $d
@ CHECK-NEXT: 5: 00000008 0 FUNC LOCAL DEFAULT 2 arm_function
-@ CHECK-NEXT: 6: 00000008 0 NOTYPE LOCAL DEFAULT 2 $a.2
+@ CHECK-NEXT: 6: 00000008 0 NOTYPE LOCAL DEFAULT 2 $a
@ CHECK-NEXT: 7: 0000000c 0 NOTYPE LOCAL DEFAULT 2 untyped_text_label
-@ CHECK-NEXT: 8: 0000000c 0 NOTYPE LOCAL DEFAULT 2 $t.3
+@ CHECK-NEXT: 8: 0000000c 0 NOTYPE LOCAL DEFAULT 2 $t
@ CHECK-NEXT: 9: 0000000f 0 FUNC LOCAL DEFAULT 2 explicit_function
-@ CHECK-NEXT: 10: 00000010 0 NOTYPE LOCAL DEFAULT 2 $d.4
+@ CHECK-NEXT: 10: 00000010 0 NOTYPE LOCAL DEFAULT 2 $d
@ CHECK-NEXT: 11: 00000000 4 TLS LOCAL DEFAULT 5 tls
@ CHECK-NEXT: 12: 00000015 0 IFUNC LOCAL DEFAULT 2 indirect_function
-@ CHECK-NEXT: 13: 00000014 0 NOTYPE LOCAL DEFAULT 2 $t.5
+@ CHECK-NEXT: 13: 00000014 0 NOTYPE LOCAL DEFAULT 2 $t
@ CHECK-NEXT: 14: 00000000 0 NOTYPE LOCAL DEFAULT 4 untyped_data_label
-@ CHECK-NEXT: 15: 00000000 0 NOTYPE LOCAL DEFAULT 4 $t.6
+@ CHECK-NEXT: 15: 00000000 0 NOTYPE LOCAL DEFAULT 4 $t
@ CHECK-NEXT: 16: 00000002 0 OBJECT LOCAL DEFAULT 4 explicit_data
-@ CHECK-NEXT: 17: 00000002 0 NOTYPE LOCAL DEFAULT 4 $d.7
+@ CHECK-NEXT: 17: 00000002 0 NOTYPE LOCAL DEFAULT 4 $d
.syntax unified
diff --git a/llvm/test/MC/ARM/thumb_set.s b/llvm/test/MC/ARM/thumb_set.s
index 4bb7b599aaf11..836eb0b62e0fa 100644
--- a/llvm/test/MC/ARM/thumb_set.s
+++ b/llvm/test/MC/ARM/thumb_set.s
@@ -6,12 +6,12 @@
@ CHECK: Num: Value Size Type Bind Vis Ndx Name
@ CHECK-NEXT: 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
@ CHECK-NEXT: 1: 00000000 0 FUNC LOCAL DEFAULT 2 arm_func
-@ CHECK-NEXT: 2: 00000000 0 NOTYPE LOCAL DEFAULT 2 $a.0
+@ CHECK-NEXT: 2: 00000000 0 NOTYPE LOCAL DEFAULT 2 $a
@ CHECK-NEXT: 3: 00000001 0 FUNC LOCAL DEFAULT 2 alias_arm_func
@ CHECK-NEXT: 4: 00000001 0 FUNC LOCAL DEFAULT 2 alias_arm_func2
@ CHECK-NEXT: 5: 00000001 0 FUNC LOCAL DEFAULT 2 alias_arm_func3
@ CHECK-NEXT: 6: 00000005 0 FUNC LOCAL DEFAULT 2 thumb_func
-@ CHECK-NEXT: 7: 00000004 0 NOTYPE LOCAL DEFAULT 2 $t.1
+@ CHECK-NEXT: 7: 00000004 0 NOTYPE LOCAL DEFAULT 2 $t
@ CHECK-NEXT: 8: 00000005 0 FUNC LOCAL DEFAULT 2 alias_thumb_func
@ CHECK-NEXT: 9: 5eed1e55 0 FUNC LOCAL DEFAULT ABS seedless
@ CHECK-NEXT: 10: e665a1ad 0 FUNC LOCAL DEFAULT ABS eggsalad
diff --git a/llvm/test/MC/ELF/ARM/execute-only-section.s b/llvm/test/MC/ELF/ARM/execute-only-section.s
index 12020e030cc04..ac5e31f70dba0 100644
--- a/llvm/test/MC/ELF/ARM/execute-only-section.s
+++ b/llvm/test/MC/ELF/ARM/execute-only-section.s
@@ -18,7 +18,7 @@ foo:
// CHECK: Section {
-// CHECK: Name: .text (16)
+// CHECK: Name: .text
// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
// CHECK-NEXT: Flags [ (0x20000006)
// CHECK-NEXT: SHF_ALLOC (0x2)
@@ -29,7 +29,7 @@ foo:
// CHECK: }
// CHECK: Section {
-// CHECK: Name: .text (16)
+// CHECK: Name: .text
// CHECK-NEXT: Type: SHT_PROGBITS (0x1)
// CHECK-NEXT: Flags [ (0x20000006)
// CHECK-NEXT: SHF_ALLOC (0x2)
@@ -40,6 +40,6 @@ foo:
// CHECK: }
// CHECK: Symbol {
-// CHECK: Name: foo (22)
+// CHECK: Name: foo
// CHECK: Section: .text (0x3)
// CHECK: }
diff --git a/llvm/test/tools/llvm-objdump/multiple-symbols.s b/llvm/test/tools/llvm-objdump/multiple-symbols.s
index 24c169e32147b..1b13f099ae98c 100644
--- a/llvm/test/tools/llvm-objdump/multiple-symbols.s
+++ b/llvm/test/tools/llvm-objdump/multiple-symbols.s
@@ -26,13 +26,13 @@
@ HEAD: Disassembly of section .text:
@ HEAD-EMPTY:
-@ AMAP-NEXT: 00000000 <$a.0>:
+@ AMAP-NEXT: 00000000 <$a>:
@ AAAA-NEXT: 00000000 <aaaa>:
@ BBBB-NEXT: 00000000 <bbbb>:
@ AABB-NEXT: 0: e0800080 add r0, r0, r0, lsl #1
@ AABB-NEXT: 4: e12fff1e bx lr
@ BOTH-EMPTY:
-@ TMAP-NEXT: 00000008 <$t.1>:
+@ TMAP-NEXT: 00000008 <$t>:
@ CCCC-NEXT: 00000008 <cccc>:
@ DDDD-NEXT: 00000008 <dddd>:
@ CCDD-NEXT: 8: eb00 0080 add.w r0, r0, r0, lsl #2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with AArch64 I think MappingSymbolCounter can be removed as unused. Other than that looks good to me.
@@ -670,17 +670,15 @@ class ARMELFStreamer : public MCELFStreamer { | |||
} | |||
|
|||
void EmitMappingSymbol(StringRef Name) { | |||
auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol( | |||
Name + "." + Twine(MappingSymbolCounter++))); | |||
auto *Symbol = cast<MCSymbolELF>(getContext().createLocalSymbol(Name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these two functions are the only use of MappingSymbolCounter (similar to AArch64). Can it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed!
Created using spr 1.3.5-bogner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for the update.
Similar to llvm#99836 for AArch64. Non-unique names save .strtab space and match GNU assembler. Pull Request: llvm#99906 (cherry picked from commit 298a922)
Similar to llvm#99836 for AArch64. Non-unique names save .strtab space and match GNU assembler. Pull Request: llvm#99906 (cherry picked from commit 298a922)
Similar to #99836 for AArch64.
Non-unique names save .strtab space and match GNU assembler.