Clarify that GlobalVariables definitions must have an initializer.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 29 Oct 2013 13:44:11 +0000 (13:44 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 29 Oct 2013 13:44:11 +0000 (13:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193609 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LangRef.rst
include/llvm/IR/GlobalVariable.h

index 6bf141e39c8061553e0dfdb7b22b091635ad5403..965858c3f926f0167fae1bfb2f2f0210d5a06098 100644 (file)
@@ -445,9 +445,13 @@ Global Variables
 ----------------
 
 Global variables define regions of memory allocated at compilation time
-instead of run-time. Global variables may optionally be initialized, may
-have an explicit section to be placed in, and may have an optional
-explicit alignment specified.
+instead of run-time.
+
+Global variables definitions must be initialized, may have an explicit section
+to be placed in, and may have an optional explicit alignment specified.
+
+Global variables in other translation units can also be declared, in which
+case they don't have an initializer.
 
 A variable may be defined as ``thread_local``, which means that it will
 not be shared by threads (each thread will have a separated copy of the
@@ -529,6 +533,12 @@ with an initializer, section, and alignment:
 
     @G = addrspace(5) constant float 1.0, section "foo", align 4
 
+The following example just declares a global variable
+
+.. code-block:: llvm
+
+   @G = external global i32
+
 The following example defines a thread-local global with the
 ``initialexec`` TLS model:
 
index bfed50786ea0bf4395e8aa991d35909226ddb039..660092df3dee0b798a226c0877c576048c9fc94e 100644 (file)
@@ -84,9 +84,7 @@ public:
   /// Provide fast operand accessors
   DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
 
-  /// hasInitializer - Unless a global variable isExternal(), it has an
-  /// initializer.  The initializer for the global variable/constant is held by
-  /// Initializer if an initializer is specified.
+  /// Definitions have initializers, declarations don't.
   ///
   inline bool hasInitializer() const { return !isDeclaration(); }