[llvm] 895cad1 - [AsmPrinter][XRay] Omit unique ID for xray_instr_map and xray_fn_idx

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 21:10:56 PST 2020


Author: Fangrui Song
Date: 2020-02-14T21:10:46-08:00
New Revision: 895cad1a133a9ec5fc3ebc042491aa78256d797f

URL: https://github.com/llvm/llvm-project/commit/895cad1a133a9ec5fc3ebc042491aa78256d797f
DIFF: https://github.com/llvm/llvm-project/commit/895cad1a133a9ec5fc3ebc042491aa78256d797f.diff

LOG: [AsmPrinter][XRay] Omit unique ID for xray_instr_map and xray_fn_idx

Follow-up for D74006.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/AsmPrinter.h
    llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/test/CodeGen/Mips/xray-section-group.ll
    llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
    llvm/test/CodeGen/X86/xray-section-group.ll
    llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index dce2324a2b44..41dc5c4fd81d 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -288,9 +288,6 @@ class AsmPrinter : public MachineFunctionPass {
   // All the sleds to be emitted.
   SmallVector<XRayFunctionEntry, 4> Sleds;
 
-  // A unique ID used for ELF sections associated with a particular function.
-  unsigned XRayFnUniqueID = 0;
-
   // Helper function to record a given XRay sled.
   void recordSled(MCSymbol *Sled, const MachineInstr &MI, SledKind Kind,
                   uint8_t Version = 0);

diff  --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 4b5d8d4cc141..7c95ba5d3f52 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3185,22 +3185,19 @@ void AsmPrinter::emitXRayTable() {
   MCSection *InstMap = nullptr;
   MCSection *FnSledIndex = nullptr;
   if (MF->getSubtarget().getTargetTriple().isOSBinFormatELF()) {
-    auto LinkedToSym = dyn_cast<MCSymbolELF>(CurrentFnSym);
-    assert(LinkedToSym != nullptr);
+    auto LinkedToSym = cast<MCSymbolELF>(CurrentFnSym);
     auto Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER;
-    std::string GroupName;
+    StringRef GroupName;
     if (F.hasComdat()) {
       Flags |= ELF::SHF_GROUP;
-      GroupName = std::string(F.getComdat()->getName());
+      GroupName = F.getComdat()->getName();
     }
-
-    auto UniqueID = ++XRayFnUniqueID;
-    InstMap =
-        OutContext.getELFSection("xray_instr_map", ELF::SHT_PROGBITS, Flags, 0,
-                                 GroupName, UniqueID, LinkedToSym);
-    FnSledIndex =
-        OutContext.getELFSection("xray_fn_idx", ELF::SHT_PROGBITS, Flags, 0,
-                                 GroupName, UniqueID, LinkedToSym);
+    InstMap = OutContext.getELFSection("xray_instr_map", ELF::SHT_PROGBITS,
+                                       Flags, 0, GroupName,
+                                       MCSection::NonUniqueID, LinkedToSym);
+    FnSledIndex = OutContext.getELFSection("xray_fn_idx", ELF::SHT_PROGBITS,
+                                           Flags, 0, GroupName,
+                                           MCSection::NonUniqueID, LinkedToSym);
   } else if (MF->getSubtarget().getTargetTriple().isOSBinFormatMachO()) {
     InstMap = OutContext.getMachOSection("__DATA", "xray_instr_map", 0,
                                          SectionKind::getReadOnlyWithRel());

diff  --git a/llvm/test/CodeGen/Mips/xray-section-group.ll b/llvm/test/CodeGen/Mips/xray-section-group.ll
index 5a123325c04f..5ae4ba832420 100644
--- a/llvm/test/CodeGen/Mips/xray-section-group.ll
+++ b/llvm/test/CodeGen/Mips/xray-section-group.ll
@@ -14,7 +14,7 @@
 define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
 ; CHECK: .section .text.foo,"ax", at progbits
   ret i32 0
-; CHECK: .section xray_instr_map,"awo", at progbits,foo,unique,1
+; CHECK: .section xray_instr_map,"awo", at progbits,foo{{$}}
 }
 
 ; CHECK-OBJ: Section {
@@ -24,7 +24,7 @@ $bar = comdat any
 define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
 ; CHECK: .section .text.bar,"axG", at progbits,bar,comdat
   ret i32 1
-; CHECK: .section xray_instr_map,"aGwo", at progbits,bar,comdat,bar,unique,2
+; CHECK: .section xray_instr_map,"aGwo", at progbits,bar,comdat,bar{{$}}
 }
 
 ; CHECK-OBJ: Section {

diff  --git a/llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll b/llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
index 875c1775216b..91beadca97ac 100644
--- a/llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
+++ b/llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
@@ -22,7 +22,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
 ; CHECK-NEXT:         nop
 ; CHECK-NEXT:         mtlr 0
 }
-; CHECK-LABEL: xray_instr_map,"awo", at progbits,foo,unique,1
+; CHECK-LABEL: xray_instr_map,"awo", at progbits,foo{{$}}
 ; CHECK:      .Lxray_sleds_start0:
 ; CHECK-NEXT:         .quad   .Ltmp0
 ; CHECK-NEXT:         .quad   foo
@@ -37,7 +37,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
 ; CHECK-NEXT:         .byte   0x00
 ; CHECK-NEXT:         .space  13
 ; CHECK-NEXT: .Lxray_sleds_end0:
-; CHECK-LABEL: xray_fn_idx,"awo", at progbits,foo,unique,1
+; CHECK-LABEL: xray_fn_idx,"awo", at progbits,foo{{$}}
 ; CHECK:              .p2align        4
 ; CHECK-NEXT:         .quad   .Lxray_sleds_start0
 ; CHECK-NEXT:         .quad   .Lxray_sleds_end0

diff  --git a/llvm/test/CodeGen/X86/xray-section-group.ll b/llvm/test/CodeGen/X86/xray-section-group.ll
index 831e6bac8b9a..cd742a6b38d0 100644
--- a/llvm/test/CodeGen/X86/xray-section-group.ll
+++ b/llvm/test/CodeGen/X86/xray-section-group.ll
@@ -5,14 +5,14 @@
 define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
 ; CHECK: .section .text.foo,"ax", at progbits
   ret i32 0
-; CHECK: .section xray_instr_map,"awo", at progbits,foo,unique,1
+; CHECK: .section xray_instr_map,"awo", at progbits,foo{{$}}
 }
 
 $bar = comdat any
 define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
 ; CHECK: .section .text.bar,"axG", at progbits,bar,comdat
   ret i32 1
-; CHECK: .section xray_instr_map,"aGwo", at progbits,bar,comdat,bar,unique,2
+; CHECK: .section xray_instr_map,"aGwo", at progbits,bar,comdat,bar{{$}}
 }
 
 ; CHECK-OBJ:      section xray_instr_map:

diff  --git a/llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll b/llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
index 558073a9801c..dd3f4d8a5152 100644
--- a/llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
+++ b/llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
@@ -25,7 +25,7 @@
 ; `a::b()` is actually associated with the function's symbol instead of the
 ; .debug_types.dwo section.
 ;
-; CHECK-ASM: xray_fn_idx,"awo", at progbits,_ZN1a1bEv,unique,1
+; CHECK-ASM: xray_fn_idx,"awo", at progbits,_ZN1a1bEv{{$}}
 ;
 ; CHECK-ELF-DAG: [[FSECT:[0-9]+]]] .text._ZN1a1bEv PROGBITS
 ; CHECK-ELF-DAG: [{{.*}}] .debug_types.dwo PROGBITS


        


More information about the llvm-commits mailing list