diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -460,7 +460,7 @@ // assumed it. if (TM.getTargetTriple().isOSBinFormatELF() && GlobalObject::isExternalLinkage(GV.getLinkage()) && GV.isDSOLocal() && - !GV.isDeclaration() && !isa(GV)) + !GV.isDeclaration() && !isa(GV) && !GV.hasComdat()) return getSymbolWithGlobalValueBase(&GV, "$local"); return TM.getSymbol(&GV); } diff --git a/llvm/test/CodeGen/X86/semantic-interposition-comdat.ll b/llvm/test/CodeGen/X86/semantic-interposition-comdat.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/X86/semantic-interposition-comdat.ll @@ -0,0 +1,23 @@ +; RUN: llc -mtriple x86_64-unknown-linux-gnu %s -o - | FileCheck %s + +$comdat_func = comdat any + +; CHECK-LABEL: func2: +; CHECK-NEXT: .Lfunc2$local + +declare void @func() + +define hidden void @func2() { +entry: + call void @func() + ret void +} + +; CHECK: comdat_func: +; CHECK-NOT: .Lcomdat_func$local + +define hidden void @comdat_func() comdat { +entry: + call void @func() + ret void +}