diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-29 13:44:11 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-10-29 13:44:11 +0000 |
commit | 1313a223ed2e8d41b6a13d3738123042b5573b88 (patch) | |
tree | e81c14439139e91868828cfd8d252acdc8f58098 | |
parent | 45d2e6492c48d41267f2d7576028422554c9875e (diff) | |
download | llvm-1313a223ed2e8d41b6a13d3738123042b5573b88.tar.gz llvm-1313a223ed2e8d41b6a13d3738123042b5573b88.tar.bz2 llvm-1313a223ed2e8d41b6a13d3738123042b5573b88.tar.xz |
Clarify that GlobalVariables definitions must have an initializer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193609 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | docs/LangRef.rst | 16 | ||||
-rw-r--r-- | include/llvm/IR/GlobalVariable.h | 4 |
2 files changed, 14 insertions, 6 deletions
diff --git a/docs/LangRef.rst b/docs/LangRef.rst index 6bf141e39c..965858c3f9 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -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: diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h index bfed50786e..660092df3d 100644 --- a/include/llvm/IR/GlobalVariable.h +++ b/include/llvm/IR/GlobalVariable.h @@ -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(); } |