IR: Allow comdats to be applied to globals with internal linkage
authorDavid Majnemer <david.majnemer@gmail.com>
Sun, 13 Jul 2014 04:56:11 +0000 (04:56 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sun, 13 Jul 2014 04:56:11 +0000 (04:56 +0000)
Our verifier check for checking if a global has local linkage was too
strict.  Forbid private linkage but permit local linkage.

Object file formats permit this and forbidding it prevents elimination
of unused, internal, vftables under the MSVC ABI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212900 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Verifier.cpp
test/Feature/comdat.ll
test/Verifier/comdat2.ll

index 314bad36b15524151e44128bec34e624c8def798..ec7ae3a77a739d4cc8899f6416450531a6a6a3e1 100644 (file)
@@ -605,11 +605,10 @@ void Verifier::visitComdat(const Comdat &C) {
     Assert1(GV,
             "comdat selection kind requires a global value with the same name",
             &C);
-  // The Module is invalid if the GlobalValue has local linkage.  Allowing
-  // otherwise opens us up to seeing the underling global value get renamed if
-  // collisions occur.
+  // The Module is invalid if the GlobalValue has private linkage.  Entities
+  // with private linkage don't have entries in the symbol table.
   if (GV)
-    Assert1(!GV->hasLocalLinkage(), "comdat global value has local linkage",
+    Assert1(!GV->hasPrivateLinkage(), "comdat global value has private linkage",
             GV);
 }
 
index 05fb87c648ee2693c5a77ffc40c5f37ba33391e6..1e878bb71cd19e75bc9d6dfcf56f59f24f44ba19 100644 (file)
@@ -16,3 +16,6 @@ define void @f() comdat $f {
   ret void
 }
 ; CHECK: define void @f() comdat $f
+
+$i = comdat largest
+@i = internal global i32 0, comdat $i
index 23b6cee09502f506af58924ff2df836ed53a7b40..d78030c12af819ae4f74621909f622294a7a39bc 100644 (file)
@@ -2,4 +2,4 @@
 
 $v = comdat any
 @v = private global i32 0, comdat $v
-; CHECK: comdat global value has local linkage
+; CHECK: comdat global value has private linkage