[windows-itanium] Propagate DLL storage class to Initialisation Guard Variables
authorBen Dunbobbin <Ben.Dunbobbin@sony.com>
Thu, 24 Nov 2022 00:12:11 +0000 (00:12 +0000)
committerBen Dunbobbin <Ben.Dunbobbin@sony.com>
Thu, 24 Nov 2022 00:23:17 +0000 (00:23 +0000)
commit437ccf5af9c2aec915a68a164a95d506fbac2324
tree3741e8589685df4984e8571c2f1a986e3fbfe92e
parent30275821f1cacd855c7f9246351242223bed9d29
[windows-itanium] Propagate DLL storage class to Initialisation Guard Variables

Initialisation Guard Variables should take their DLL storage class
from the guarded variable. Otherwise, there will be a link error if
the compiler inlines a reference to the guard variable into another
module but that guard variable is not exported from the defining
module.

This is required for platforms such as PlayStation and
windows-itanium, that are aiming for source compatibility with MSVC
w.r.t. dllimport/export annotations, given Clang's existing design
which allows for inlining of a dllimport function as long as all the
variables/functions referenced are also marked dllimport.

A similar change exists for the MSVC ABI:
https://reviews.llvm.org/D4136.

I have added a run test for windows-itanium for this issue to the
build recipe: https://reviews.llvm.org/D88124.

Differential Revision: https://reviews.llvm.org/D138463
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGenCXX/windows-itanium-init-guard.cpp [new file with mode: 0644]