aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-02-01 11:18:47 +0100
committerNikita Popov <npopov@redhat.com>2023-02-14 08:23:37 +0100
commit2e9549db268645accb83ebf031fbb1de84b00ca9 (patch)
tree90329fe3747e20ee2439ca92c66bde719ff61cca
parentaf838c1b1c20c7b3b970e81039a1992857fe76bb (diff)
downloadllvm-2e9549db268645accb83ebf031fbb1de84b00ca9.zip
llvm-2e9549db268645accb83ebf031fbb1de84b00ca9.tar.gz
llvm-2e9549db268645accb83ebf031fbb1de84b00ca9.tar.bz2
[LangRef] Global variable declarations imply minimum size
Adjust the wording added in D78952 to say that global variable declarations (and interposable definitions) do imply a minimum size (and alignment) on the global. They just don't imply a maximum size. We rely on these semantics in at least two places: * Global dereferenceability: https://github.com/llvm/llvm-project/blob/2153544865a9733b06579823814c981f735e4201/llvm/lib/IR/Value.cpp#L907 * Global inbounds GEP: https://github.com/llvm/llvm-project/blob/2153544865a9733b06579823814c981f735e4201/llvm/lib/IR/ConstantFold.cpp#L2283 Differential Revision: https://reviews.llvm.org/D143057
-rw-r--r--llvm/docs/LangRef.rst9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 16e2029..cd51a42 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -721,12 +721,11 @@ limits the alignment to the given value. Optimizers are not allowed to
impose a stronger alignment on these variables. The maximum alignment
is ``1 << 32``.
-For global variables declarations, as well as definitions that may be
+For global variable declarations, as well as definitions that may be
replaced at link time (``linkonce``, ``weak``, ``extern_weak`` and ``common``
-linkage types), LLVM makes no assumptions about the allocation size of the
-variables, except that they may not overlap. The alignment of a global variable
-declaration or replaceable definition must not be greater than the alignment of
-the definition it resolves to.
+linkage types), the allocation size and alignment of the definition it resolves
+to must be greater than or equal to that of the declaration or replaceable
+definition, otherwise the behavior is undefined.
Globals can also have a :ref:`DLL storage class <dllstorageclass>`,
an optional :ref:`runtime preemption specifier <runtime_preemption_model>`,