[C++20] [Modules] Don't generate global ctors/dtors for variables which are available...
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>
Mon, 9 Jan 2023 02:43:35 +0000 (10:43 +0800)
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>
Mon, 9 Jan 2023 02:48:43 +0000 (10:48 +0800)
commit08f957808e5f7e44b11d5e9015925955fe1e9d32
treef2296518f94db01d17e01f97015502f2c070b6d8
parentee1be282241b1253847e663af000f7082b7f03a3
[C++20] [Modules] Don't generate global ctors/dtors for variables which are available externally

Closes https://github.com/llvm/llvm-project/issues/59765.

Currently we will generate the global ctor/dtor for variables in
importing modules. It will cause multiple initialization/destructions.
It makes no sense. This patch tries to not generate global ctor/dtor for
variables which are available externally. Note that the variables in
header units and clang modules won't be available externally by default.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D140867
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm [new file with mode: 0644]