[llvm] r212900 - IR: Allow comdats to be applied to globals with internal linkage

David Majnemer david.majnemer at gmail.com
Sat Jul 12 21:56:12 PDT 2014


Author: majnemer
Date: Sat Jul 12 23:56:11 2014
New Revision: 212900

URL: http://llvm.org/viewvc/llvm-project?rev=212900&view=rev
Log:
IR: Allow comdats to be applied to globals with internal linkage

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.

Modified:
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/test/Feature/comdat.ll
    llvm/trunk/test/Verifier/comdat2.ll

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=212900&r1=212899&r2=212900&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sat Jul 12 23:56:11 2014
@@ -605,11 +605,10 @@ void Verifier::visitComdat(const Comdat
     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);
 }
 

Modified: llvm/trunk/test/Feature/comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/comdat.ll?rev=212900&r1=212899&r2=212900&view=diff
==============================================================================
--- llvm/trunk/test/Feature/comdat.ll (original)
+++ llvm/trunk/test/Feature/comdat.ll Sat Jul 12 23:56:11 2014
@@ -16,3 +16,6 @@ define void @f() comdat $f {
   ret void
 }
 ; CHECK: define void @f() comdat $f
+
+$i = comdat largest
+ at i = internal global i32 0, comdat $i

Modified: llvm/trunk/test/Verifier/comdat2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/comdat2.ll?rev=212900&r1=212899&r2=212900&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/comdat2.ll (original)
+++ llvm/trunk/test/Verifier/comdat2.ll Sat Jul 12 23:56:11 2014
@@ -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





More information about the llvm-commits mailing list