From cd81f5df27c9a47561be1b9a4059ca3a5dcace4c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 5 Aug 2009 05:41:44 +0000 Subject: [PATCH] common globals may also not be marked constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78169 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.html | 7 ++++--- lib/VMCore/Verifier.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/LangRef.html b/docs/LangRef.html index 52ec97888d1..9ef7cce419f 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -564,9 +564,10 @@ define i32 @main() { ; i32()* common" linkage are merged in the same way as weak symbols, and they may not be deleted if unreferenced. - Further, common symbols may not have an explicit section, and - must have a zero initializer. Functions and aliases may not have common - linkage. + common symbols may not have an explicit section, + must have a zero initializer, and may not be marked 'constant'. Functions and aliases may not + have common linkage.
appending:
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index f50299bdc0c..9ca048838e4 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -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.