[PATCH] D74361: [Clang] Uninitialize attribute on global variables
Jon Chesterfield via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 15:00:57 PST 2020
JonChesterfield created this revision.
JonChesterfield added reviewers: kcc, rjmccall, rsmith, glider, vitalybuka, pcc, eugenis, vlad.tsyrklevich, jdoerfert, gregrodgers.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
[Clang] Uninitialize attribute on global variables
Extends D54604 <https://reviews.llvm.org/D54604> to permit [[uninitialized]] on global and static variables
Initializing global variables is very cheap on hosted implementations. The
C semantics of zero initializing globals work very well there. It is not
necessarily cheap on freestanding implementations. Where there is no loader
available, code must be emitted near the start point to write the appropriate
values into memory.
At present, external variables can be declared in C++ and definitions provided
in assembly (or IR) to achive this effect. This patch removes a restriction on
the existing attribute in order to remove this reason for writing assembly for
performance sensitive freestanding implementations.
A close analogue in tree is LDS memory for amdgcn, where the kernel is
responsible for initializing the memory after it starts executing on the gpu.
Uninitalized variables in LDS are observably cheaper than zero initialized.
Patch follows the cuda __shared__ variable implementation which also produces
undef global variables, and reuses the [[uninitialized]] attribute from auto
variable initialisation. I think the existing docs are still appropriate.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74361
Files:
clang/include/clang/Basic/Attr.td
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/CodeGenCXX/attribute_uninitialized.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/attr-uninitialized.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74361.243681.patch
Type: text/x-patch
Size: 6291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200210/09f56666/attachment-0001.bin>
More information about the cfe-commits
mailing list