From: Erich Keane Date: Tue, 22 Aug 2017 15:30:43 +0000 (+0000) Subject: Emit section information for extern variables X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93fb9f24a3376a097377d2bd4f673e51077bf150;p=llvm Emit section information for extern variables Update IR generated to retain section information for external declarations. This is related to https://reviews.llvm.org/D36487 Patch By: eandrews Differential Revision: https://reviews.llvm.org/D36712 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311459 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LangRef.rst b/docs/LangRef.rst index bfc4d90263d..7fa2ec1c588 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -579,7 +579,9 @@ Global variables in other translation units can also be declared, in which case they don't have an initializer. Either global variable definitions or declarations may have an explicit section -to be placed in and may have an optional explicit alignment specified. +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 +variable declaration and its definition the resulting behavior is undefined. A variable may be defined as a global ``constant``, which indicates that the contents of the variable will **never** be modified (enabling better @@ -622,6 +624,12 @@ target supports it, it will emit globals to the section specified. Additionally, the global can placed in a comdat if the target has the necessary support. +External declarations may have an explicit section specified. Section +information is retained in LLVM IR for targets that make use of this +information. Attaching section information to an external declaration is an +assertion that its definition is located in the specified section. If the +definition is located in a different section, the behavior is undefined. + By default, global initializers are optimized by assuming that global variables defined within the module are not modified from their initial values before the start of the global initializer. This is