common globals may also not be marked constant.
authorChris Lattner <sabre@nondot.org>
Wed, 5 Aug 2009 05:41:44 +0000 (05:41 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 5 Aug 2009 05:41:44 +0000 (05:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78169 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.html
lib/VMCore/Verifier.cpp

index 52ec97888d168c1734bfbba4e94b986f8e25fd8b..9ef7cce419f5d03592efb89d806c116593e17d99 100644 (file)
@@ -564,9 +564,10 @@ define i32 @main() {                                              <i>; i32()* </
       global scope.
       Symbols with "<tt>common</tt>" linkage are merged in the same way as
       <tt>weak symbols</tt>, and they may not be deleted if unreferenced.
-      Further, <tt>common</tt> symbols may not have an explicit section, and
-      must have a zero initializer.  Functions and aliases may not have common
-      linkage.</dd>
+      <tt>common</tt> symbols may not have an explicit section,
+      must have a zero initializer, and may not be marked '<a 
+      href="#globalvars"><tt>constant</tt></a>'.  Functions and aliases may not
+      have common linkage.</dd>
 
 
   <dt><tt><b><a name="linkage_appending">appending</a></b></tt>: </dt>
index f50299bdc0cf843bcb71a43f6f26a4b0423983e0..9ca048838e4f163e0d9ba9115825b14ff3add5f1 100644 (file)
@@ -378,11 +378,14 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) {
             "Global variable initializer type does not match global "
             "variable type!", &GV);
 
-    // If the global has common linkage, it must have a zero initializer.
-    if (GV.hasCommonLinkage())
+    // If the global has common linkage, it must have a zero initializer and
+    // cannot be constant.
+    if (GV.hasCommonLinkage()) {
       Assert1(GV.getInitializer()->isNullValue(),
               "'common' global must have a zero initializer!", &GV);
-    
+      Assert1(!GV.isConstant(), "'common' global may not be marked constant!",
+              &GV);
+    }
     
     // Verify that any metadata used in a global initializer points only to
     // other globals.