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

Follow-up for D74006.
This commit is contained in:
Fangrui Song 2020-02-14 21:02:26 -08:00
parent 8bc790f9e6
commit 895cad1a13
6 changed files with 16 additions and 22 deletions

View File

@ -288,9 +288,6 @@ public:
// 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);

View File

@ -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());

View File

@ -14,7 +14,7 @@
define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
; CHECK: .section .text.foo,"ax",@progbits
ret i32 0
; CHECK: .section xray_instr_map,"awo",@progbits,foo,unique,1
; CHECK: .section xray_instr_map,"awo",@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",@progbits,bar,comdat
ret i32 1
; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,bar,unique,2
; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,bar{{$}}
}
; CHECK-OBJ: Section {

View File

@ -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",@progbits,foo,unique,1
; CHECK-LABEL: xray_instr_map,"awo",@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",@progbits,foo,unique,1
; CHECK-LABEL: xray_fn_idx,"awo",@progbits,foo{{$}}
; CHECK: .p2align 4
; CHECK-NEXT: .quad .Lxray_sleds_start0
; CHECK-NEXT: .quad .Lxray_sleds_end0

View File

@ -5,14 +5,14 @@
define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
; CHECK: .section .text.foo,"ax",@progbits
ret i32 0
; CHECK: .section xray_instr_map,"awo",@progbits,foo,unique,1
; CHECK: .section xray_instr_map,"awo",@progbits,foo{{$}}
}
$bar = comdat any
define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
; CHECK: .section .text.bar,"axG",@progbits,bar,comdat
ret i32 1
; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,bar,unique,2
; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,bar{{$}}
}
; CHECK-OBJ: section xray_instr_map:

View File

@ -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",@progbits,_ZN1a1bEv,unique,1
; CHECK-ASM: xray_fn_idx,"awo",@progbits,_ZN1a1bEv{{$}}
;
; CHECK-ELF-DAG: [[FSECT:[0-9]+]]] .text._ZN1a1bEv PROGBITS
; CHECK-ELF-DAG: [{{.*}}] .debug_types.dwo PROGBITS