[PATCH] D78952: [LangRef] Describe linkage types, allocation size of declarations for global variables

Matthias Schiffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 12:22:56 PDT 2020


NeoRaider created this revision.
NeoRaider added reviewers: jdoerfert, efriedma.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Linkage type was only referenced for functions, not for global variables.

      

Clarify that LLVM doesn't make assumption about the allocation size when no definitive initializer for a global variable is known.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78952

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -272,8 +272,8 @@
     visible, meaning that it participates in linkage and can be used to
     resolve external symbol references.
 
-It is illegal for a function *declaration* to have any linkage type
-other than ``external`` or ``extern_weak``.
+It is illegal for a global variable or function *declaration* to have any
+linkage type other than ``external`` or ``extern_weak``.
 
 .. _callingconv:
 
@@ -615,6 +615,8 @@
 Global variables in other translation units can also be declared, in which
 case they don't have an initializer.
 
+Global variables can optionally specify a :ref:`linkage type <linkage>`.
+
 Either global variable definitions or declarations may have an explicit section
 to be placed in and may have an optional explicit alignment specified. If there
 is a mismatch between the explicit or inferred section information for the
@@ -686,6 +688,11 @@
 iterate over them as an array, alignment padding would break this
 iteration. The maximum alignment is ``1 << 29``.
 
+For global variables *declarations*, as well as definitions that may be
+replaced at link time (``linkonce``, ``weak``, ``extern_weak`` and ``common``
+linkage types), LLVM makes no assumptions whatsoever regarding the allocation
+size of the variable.
+
 Globals can also have a :ref:`DLL storage class <dllstorageclass>`,
 an optional :ref:`runtime preemption specifier <runtime_preemption_model>`,
 an optional :ref:`global attributes <glattrs>` and


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78952.260401.patch
Type: text/x-patch
Size: 1598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/473b1ac7/attachment.bin>


More information about the llvm-commits mailing list