Index: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2785,7 +2785,7 @@ MCSection *InstMap = nullptr; MCSection *FnSledIndex = nullptr; if (MF->getSubtarget().getTargetTriple().isOSBinFormatELF()) { - auto Associated = dyn_cast(PrevSection->getBeginSymbol()); + auto Associated = dyn_cast(CurrentFnSym); assert(Associated != nullptr); auto Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER; std::string GroupName; Index: llvm/trunk/test/CodeGen/Mips/xray-section-group.ll =================================================================== --- llvm/trunk/test/CodeGen/Mips/xray-section-group.ll +++ llvm/trunk/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",@progbits ret i32 0 -; CHECK: .section xray_instr_map,"awo",@progbits,.text.foo,unique,1 +; CHECK: .section xray_instr_map,"awo",@progbits,foo,unique,1 } ; CHECK-OBJ: Section { @@ -24,7 +24,7 @@ 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,.text.bar,unique,2 +; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,bar,unique,2 } ; CHECK-OBJ: Section { Index: llvm/trunk/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll =================================================================== --- llvm/trunk/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll +++ llvm/trunk/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll @@ -22,7 +22,7 @@ ; CHECK-NEXT: nop ; CHECK-NEXT: mtlr 0 } -; CHECK-LABEL: xray_instr_map,"awo",@progbits,.text,unique,1 +; CHECK-LABEL: xray_instr_map,"awo",@progbits,foo,unique,1 ; CHECK: .Lxray_sleds_start0: ; CHECK-NEXT: .quad .Ltmp0 ; CHECK-NEXT: .quad foo @@ -37,7 +37,7 @@ ; CHECK-NEXT: .byte 0x00 ; CHECK-NEXT: .space 13 ; CHECK-NEXT: .Lxray_sleds_end0: -; CHECK-LABEL: xray_fn_idx,"awo",@progbits,.text,unique,1 +; CHECK-LABEL: xray_fn_idx,"awo",@progbits,foo,unique,1 ; CHECK: .p2align 4 ; CHECK-NEXT: .quad .Lxray_sleds_start0 ; CHECK-NEXT: .quad .Lxray_sleds_end0 Index: llvm/trunk/test/CodeGen/X86/xray-section-group.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/xray-section-group.ll +++ llvm/trunk/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",@progbits ret i32 0 -; CHECK: .section xray_instr_map,"awo",@progbits,.text.foo,unique,1 +; CHECK: .section xray_instr_map,"awo",@progbits,foo,unique,1 } $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,.text.bar,unique,2 +; CHECK: .section xray_instr_map,"aGwo",@progbits,bar,comdat,bar,unique,2 } ; CHECK-OBJ: section xray_instr_map: Index: llvm/trunk/test/DebugInfo/X86/xray-split-dwarf-interaction.ll =================================================================== --- llvm/trunk/test/DebugInfo/X86/xray-split-dwarf-interaction.ll +++ llvm/trunk/test/DebugInfo/X86/xray-split-dwarf-interaction.ll @@ -0,0 +1,84 @@ +; RUN: %llc_dwarf -split-dwarf-file=input.dwo -O3 \ +; RUN: -function-sections -data-sections \ +; RUN: -relocation-model=pic -filetype=asm \ +; RUN: -generate-type-units -debug-compile -o - %s | \ +; RUN: FileCheck %s --check-prefix=CHECK-ASM +; RUN: %llc_dwarf -split-dwarf-file=input.dwo -O3 \ +; RUN: -function-sections -data-sections \ +; RUN: -relocation-model=pic -filetype=obj \ +; RUN: -generate-type-units -debug-compile -o - %s | \ +; RUN: llvm-readelf -sections | \ +; RUN: FileCheck %s --check-prefix=CHECK-ELF +; Created from `clang++ -fxray-instrument -gsplit-dwarf -fdebug-types-section +; -ffunction-sections -fdata-sections -emit-llvm -S input.cc`: +; input.cc: +; +; class a { +; int b(); +; }; +; int a::b() { +; for (;;) +; ; +; } +; +; In this test we want to make sure that the xray_instr_map section for +; `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-ELF-DAG: [[FSECT:[0-9]+]]] .text._ZN1a1bEv PROGBITS +; CHECK-ELF-DAG: [{{.*}}] .debug_types.dwo PROGBITS +; CHECK-ELF-DAG: [{{.*}}] xray_instr_map PROGBITS {{.*}} {{.*}} {{.*}} {{.*}} WAL [[FSECT]] +target triple = "x86_64-pc-linux" + +%class.a = type { i8 } + +; Function Attrs: nounwind readnone uwtable +define i32 @_ZN1a1bEv(%class.a* nocapture readnone) local_unnamed_addr #0 align 2 !dbg !8 { + tail call void @llvm.dbg.value(metadata %class.a* %0, metadata !17, metadata !DIExpression()), !dbg !19 + br label %2, !dbg !20 + +;