Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -568,7 +568,7 @@ *CurModule, ArrayTy, false, GlobalVariable::PrivateLinkage, Constant::getNullValue(ArrayTy), "__sancov_gen_"); - if (TargetTriple.supportsCOMDAT()) + if (TargetTriple.supportsCOMDAT() && !F.isInterposable()) if (auto Comdat = GetOrCreateFunctionComdat(F, TargetTriple, CurModuleUniqueId)) Array->setComdat(Comdat); Index: llvm/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll =================================================================== --- /dev/null +++ llvm/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll @@ -0,0 +1,38 @@ +; Test that interposable symbols do not get put in comdats. +; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard -S | FileCheck %s +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @Vanilla() { +entry: + ret void +} + +define linkonce void @LinkOnce() { +entry: + ret void +} + +define weak void @Weak() { +entry: + ret void +} + +declare extern_weak void @ExternWeak() + +define linkonce_odr void @LinkOnceOdr() { +entry: + ret void +} + +define weak_odr void @WeakOdr() { +entry: + ret void +} + +; CHECK: define void @Vanilla() comdat { +; CHECK: define linkonce void @LinkOnce() { +; CHECK: define weak void @Weak() { +; CHECK: declare extern_weak void @ExternWeak() +; CHECK: define linkonce_odr void @LinkOnceOdr() comdat { +; CHECK: define weak_odr void @WeakOdr() comdat {