Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ 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: test/DebugInfo/X86/xray-split-dwarf-interaction.ll =================================================================== --- /dev/null +++ test/DebugInfo/X86/xray-split-dwarf-interaction.ll @@ -0,0 +1,74 @@ +; 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 +; 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 the +; .debug_types.dwo section. +; +; CHECK: xray_fn_idx,"awo",@progbits,_ZN1a1bEv,unique,1 +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 + +;