[PATCH] D74361: [Clang] Undef attribute for global variables
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 2 06:38:40 PST 2020
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added inline comments.
================
Comment at: clang/include/clang/Basic/AttrDocs.td:4365
+The ``loader_uninitialized`` attribute can be placed on global variables to
+indicate that the variable does not need to be zero initialised by the loader.
+This is useful for variables that are always written to before use where the
----------------
initialised -> initialized
================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:7436
+ case ParsedAttr::AT_LoaderUninitialized:
+ handleLoaderUninitializedAttr(S, D, AL);
+ break;
----------------
If you don't need any custom semantic checking, you can remove that function and instead call `handleSimpleAttribute<LoaderUninitializedAttr>(S, D, AL);`
================
Comment at: clang/test/CodeGenCXX/attr-loader-uninitialized.cpp:14
+// CHECK: @tentative = global i32 undef
+int tentative [[clang::loader_uninitialized]];
+
----------------
What should happen with redeclarations? e.g., in C:
```
int a;
int foo() { return a; }
int a __attribute__((loader_uninitialized));
```
(This would be a useful test case to add.)
Also, I'd like to see a test case where the attributed global is an array.
================
Comment at: clang/test/Sema/attr-loader-uninitialized.cpp:19
+
+} __attribute__((loader_uninitialized)); // expected-warning {{'loader_uninitialized' attribute only applies to global variables}}
----------------
I'd also like to see a test demonstrating it doesn't accept any arguments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74361/new/
https://reviews.llvm.org/D74361
More information about the cfe-commits
mailing list