[llvm] r315026 - ModuleUtils: Stop using comdat members to generate unique module ids.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 14:54:53 PDT 2017
Author: pcc
Date: Thu Oct 5 14:54:53 2017
New Revision: 315026
URL: http://llvm.org/viewvc/llvm-project?rev=315026&view=rev
Log:
ModuleUtils: Stop using comdat members to generate unique module ids.
It is possible for two modules to define the same set of external
symbols without causing a duplicate symbol error at link time,
as long as each of the symbols is a comdat member. So we cannot
use them as part of a unique id for the module.
Differential Revision: https://reviews.llvm.org/D38602
Modified:
llvm/trunk/include/llvm/Transforms/Utils/ModuleUtils.h
llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp
llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
Modified: llvm/trunk/include/llvm/Transforms/Utils/ModuleUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/ModuleUtils.h?rev=315026&r1=315025&r2=315026&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/ModuleUtils.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/ModuleUtils.h Thu Oct 5 14:54:53 2017
@@ -85,7 +85,8 @@ void filterDeadComdatFunctions(
Module &M, SmallVectorImpl<Function *> &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.
Modified: llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp?rev=315026&r1=315025&r2=315026&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ModuleUtils.cpp Thu Oct 5 14:54:53 2017
@@ -243,7 +243,7 @@ std::string llvm::getUniqueModuleId(Modu
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());
Modified: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll?rev=315026&r1=315025&r2=315026&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll (original)
+++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/filter-alias.ll Thu Oct 5 14:54:53 2017
@@ -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)
+ at foo = global i32 1
+
!0 = !{i64 8, !"?AVA@@"}
Modified: llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll?rev=315026&r1=315025&r2=315026&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll (original)
+++ llvm/trunk/test/Transforms/ThinLTOBitcodeWriter/unsplittable.ll Thu Oct 5 14:54:53 2017
@@ -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"}
More information about the llvm-commits
mailing list