[all-commits] [llvm/llvm-project] bd7f4c: [C++20][Modules] Elide unused guard variables in I...
Iain Sandoe via All-commits
all-commits at lists.llvm.org
Sun Dec 18 01:17:11 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bd7f4c561f5e2385ebe5500a044efe0de30cccaa
https://github.com/llvm/llvm-project/commit/bd7f4c561f5e2385ebe5500a044efe0de30cccaa
Author: Iain Sandoe <iain at sandoe.co.uk>
Date: 2022-12-18 (Sun, 18 Dec 2022)
Changed paths:
M clang/lib/CodeGen/CGDeclCXX.cpp
A clang/test/CodeGenCXX/module-initializer-guard-elision.cpp
Log Message:
-----------
[C++20][Modules] Elide unused guard variables in Itanium ABI module initializers.
For the Itanium ABI, we emit an initializer for each module. This is responsible
for handling initialization of global vars. Relates to P1874R1.
The initializer has a known mangling and is automatically called from any TU that
imports a module. Since, at present, the importer has no way to determine that an
imported module does not require an initializer, we generate the initializer for
all cases (even when it is empty).
Initializers must be run once, with the ordering guaranteed by the import graph
and this is ensured in the current code by addition of a guard variable.
In the case that a module has no requirement for global initializers, and also does
not import any other modules, we can elide the guard variable.
Differential Revision: https://reviews.llvm.org/D134589
More information about the All-commits
mailing list