diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -1040,8 +1040,9 @@ if (const MCSymbol *Group = ElfSec.getGroup()) { auto *S = static_cast(PseudoProbeSection); auto Flags = S->getFlags() | ELF::SHF_GROUP; - return Ctx->getELFSection(S->getName(), S->getType(), Flags, - S->getEntrySize(), Group->getName()); + return Ctx->getELFSection(S->getName() + "." + Group->getName(), + S->getType(), Flags, S->getEntrySize(), + Group->getName()); } } return PseudoProbeSection; diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll @@ -6,6 +6,7 @@ ; RUN: FileCheck %s < %t1 --check-prefix=CHECK-ASM ; RUN: llc %t -function-sections -filetype=obj -o %t2 ; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ +; RUN: llvm-readelf -g %t2 | FileCheck %s --check-prefix=CHECK-ELF ; RUN: llvm-mc %t1 -filetype=obj -o %t3 ; RUN: llvm-objdump --section-headers %t3 | FileCheck %s --check-prefix=CHECK-OBJ @@ -16,7 +17,10 @@ @a = dso_local global i32 0, align 4 -define void @foo(i32 %x) !dbg !3 { +$foo = comdat any +$foo2 = comdat any + +define void @foo(i32 %x) comdat !dbg !3 { bb0: %cmp = icmp eq i32 %x, 0 ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID:]], i64 1, i32 0, i64 -1), !dbg ![[#FAKELINE:]] @@ -49,7 +53,7 @@ declare void @bar(i32 %x) -define internal void @foo2(void (i32)* %f) !dbg !4 { +define internal void @foo2(void (i32)* %f) comdat !dbg !4 { entry: ; CHECK-IL: call void @llvm.pseudoprobe(i64 [[#GUID2:]], i64 1, i32 0, i64 -1) ; CHECK-MIR: PSEUDO_PROBE [[#GUID2:]], 1, 0, 0 @@ -97,9 +101,27 @@ ; CHECK-ASM-NEXT: .ascii "foo2" ; CHECK-OBJ-COUNT-2: .pseudo_probe_desc -; CHECK-OBJ: .pseudo_probe +; CHECK-OBH-COUNT-2: .pseudo_probe ; CHECK-OBJ-NOT: .rela.pseudo_probe +; CHECK-ELF: COMDAT group section [ 3] `.group' [foo] contains 3 sections: +; CHECK-ELF-NEXT: [Index] Name +; CHECK-ELF-NEXT: [ 4] .text.foo +; CHECK-ELF-NEXT: [ 5] .rela.text.foo +; CHECK-ELF-NEXT: [ 17] .pseudo_probe.foo +; CHECK-ELF: COMDAT group section [ 6] `.group' [foo2] contains 3 sections: +; CHECK-ELF-NEXT: [Index] Name +; CHECK-ELF-NEXT: [ 7] .text.foo2 +; CHECK-ELF-NEXT: [ 8] .rela.text.foo2 +; CHECK-ELF-NEXT: [ 18] .pseudo_probe.foo2 +; CHECK-ELF: COMDAT group section [ 10] `.group' [.pseudo_probe_desc_foo] contains 1 sections: +; CHECK-ELF-NEXT: [Index] Name +; CHECK-ELF-NEXT: [ 11] .pseudo_probe_desc + +; CHECK-ELF: COMDAT group section [ 12] `.group' [.pseudo_probe_desc_foo2] contains 1 sections: +; CHECK-ELF-NEXT: [Index] Name +; CHECK-ELF-NEXT: [ 13] .pseudo_probe_desc + ; Check the generation of .pseudo_probe_desc section with CFG encoding. ; CHECK-CFG: .section .pseudo_probe_desc,"",@progbits ; CHECK-CFG-NEXT: .quad [[#GUID:]]