diff --git a/include/llvm/Transforms/Utils/ModuleUtils.h b/include/llvm/Transforms/Utils/ModuleUtils.h index e9793fe4b66..4b9bc829381 100644 --- a/include/llvm/Transforms/Utils/ModuleUtils.h +++ b/include/llvm/Transforms/Utils/ModuleUtils.h @@ -85,7 +85,8 @@ void filterDeadComdatFunctions( Module &M, SmallVectorImpl &DeadComdatFunctions); /// \brief Produce a unique identifier for this module by taking the MD5 sum of -/// the names of the module's strong external symbols. +/// the names of the module's strong external symbols that are not comdat +/// members. /// /// This identifier is normally guaranteed to be unique, or the program would /// fail to link due to multiply defined symbols. diff --git a/lib/Transforms/Utils/ModuleUtils.cpp b/lib/Transforms/Utils/ModuleUtils.cpp index 2ef3d6336ae..ba4b7f3cc26 100644 --- a/lib/Transforms/Utils/ModuleUtils.cpp +++ b/lib/Transforms/Utils/ModuleUtils.cpp @@ -243,7 +243,7 @@ std::string llvm::getUniqueModuleId(Module *M) { bool ExportsSymbols = false; auto AddGlobal = [&](GlobalValue &GV) { if (GV.isDeclaration() || GV.getName().startswith("llvm.") || - !GV.hasExternalLinkage()) + !GV.hasExternalLinkage() || GV.hasComdat()) return; ExportsSymbols = true; Md5.update(GV.getName()); diff --git a/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll b/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll index d555ab0c1f6..48f2900da36 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll +++ b/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll @@ -13,4 +13,6 @@ $al = comdat any @al = external unnamed_addr alias i8*, getelementptr inbounds ({ [1 x i8*] }, { [1 x i8*] }* @anon, i32 0, i32 0, i32 1) +@foo = global i32 1 + !0 = !{i64 8, !"?AVA@@"} diff --git a/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll b/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll index 718013e39b3..41b5bba79ad 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll +++ b/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll @@ -21,4 +21,10 @@ define internal void @f() { ret void } +$h = comdat any +; CHECK: define void @h() comdat +define void @h() comdat { + ret void +} + !0 = !{i32 0, !"typeid"}