[llvm] 55a7be5 - [AArch64, ELF] Use getCurrentSection().first in changeSection

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 23:14:22 PDT 2024


Author: Fangrui Song
Date: 2024-07-18T23:14:16-07:00
New Revision: 55a7be55a5fcf1c0837d62660157a45f8a52eb4f

URL: https://github.com/llvm/llvm-project/commit/55a7be55a5fcf1c0837d62660157a45f8a52eb4f
DIFF: https://github.com/llvm/llvm-project/commit/55a7be55a5fcf1c0837d62660157a45f8a52eb4f.diff

LOG: [AArch64,ELF] Use getCurrentSection().first in changeSection

Similar to the NVPTX change 4ae23bcca144b542f16d45acc8f270e156e2fa4e.
And improve the tests.

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
    llvm/test/MC/AArch64/mapping-across-sections.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
index 7dba22c066dcd..bfeca4bd5a92d 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -187,7 +187,7 @@ class AArch64ELFStreamer : public MCELFStreamer {
     // We have to keep track of the mapping symbol state of any sections we
     // use. Each one should start off as EMS_None, which is provided as the
     // default constructor by DenseMap::lookup.
-    LastMappingSymbols[getPreviousSection().first] = LastEMS;
+    LastMappingSymbols[getCurrentSection().first] = LastEMS;
     LastEMS = LastMappingSymbols.lookup(Section);
 
     MCELFStreamer::changeSection(Section, Subsection);

diff  --git a/llvm/test/MC/AArch64/mapping-across-sections.s b/llvm/test/MC/AArch64/mapping-across-sections.s
index 053deb760dcfd..6bb5a8811b57d 100644
--- a/llvm/test/MC/AArch64/mapping-across-sections.s
+++ b/llvm/test/MC/AArch64/mapping-across-sections.s
@@ -1,28 +1,40 @@
-// RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj < %s | llvm-objdump -t - | FileCheck %s
-
-        .text
-        add w0, w0, w0
-
-// .wibble should *not* inherit .text's mapping symbol. It's a completely 
diff erent section.
-        .section .wibble
-        add w0, w0, w0
-
-// A setion should be able to start with a $d
-        .section .starts_data
-        .word 42
-
-// Changing back to .text should not emit a redundant $x
-        .text
-        add w0, w0, w0
-
-// With all those constraints, we want:
-//   + .text to have $x at 0 and no others
-//   + .wibble to have $x at 0
-//   + .starts_data to have $d at 0
-
-
-// CHECK:      0000000000000000 l .text        0000000000000000 $x
-// CHECK-NEXT: 0000000000000000 l .wibble      0000000000000000 $x
-// CHECK-NEXT: 0000000000000000 l .starts_data 0000000000000000 $d
-// CHECK-NOT: ${{[adtx]}}
-
+// RUN: llvm-mc -triple=aarch64 -filetype=obj %s | llvm-objdump -t - | FileCheck %s
+
+.section .text1,"ax"
+add w0, w0, w0
+
+.text
+add w0, w0, w0
+.word 42
+
+.pushsection .data,"aw"
+.word 42
+.popsection
+
+.text
+add w1, w1, w1
+
+.section .text1,"ax"
+add w1, w1, w1
+
+.text
+.word 42
+
+.section .rodata,"a"
+.word 42
+add w0, w0, w0
+
+.ident "clang"
+.section ".note.GNU-stack","", at progbits
+
+// CHECK:      SYMBOL TABLE:
+// CHECK-NEXT: 0000000000000000 l       .text1 0000000000000000 $x.0
+// CHECK-NEXT: 0000000000000000 l       .text  0000000000000000 $x.1
+// CHECK-NEXT: 0000000000000004 l       .text  0000000000000000 $d.2
+// CHECK-NEXT: 0000000000000000 l       .data  0000000000000000 $d.3
+// CHECK-NEXT: 0000000000000008 l       .text  0000000000000000 $x.4
+// CHECK-NEXT: 000000000000000c l       .text  0000000000000000 $d.5
+// CHECK-NEXT: 0000000000000000 l       .rodata        0000000000000000 $d.6
+// CHECK-NEXT: 0000000000000004 l       .rodata        0000000000000000 $x.7
+// CHECK-NEXT: 0000000000000000 l       .comment       0000000000000000 $d.8
+// CHECK-NOT:  {{.}}


        


More information about the llvm-commits mailing list