[Clang] Support a user-defined __dso_handle
authorAndrew Savonichev <andrew.savonichev@gmail.com>
Mon, 24 May 2021 10:29:59 +0000 (13:29 +0300)
committerAndrew Savonichev <andrew.savonichev@gmail.com>
Mon, 7 Jun 2021 09:54:08 +0000 (12:54 +0300)
commitb31f41e78b2722785f3df1da0d77dfcd68125d15
tree33901e9bef01b3ad0481ca3c7415a39831a58031
parent23c2f2e6b24d80d3472dca897feac10e9c34c51f
[Clang] Support a user-defined __dso_handle

This fixes PR49198: Wrong usage of __dso_handle in user code leads to
a compiler crash.

When Init is an address of the global itself, we need to track it
across RAUW. Otherwise the initializer can be destroyed if the global
is replaced.

Differential Revision: https://reviews.llvm.org/D101156
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/dso-handle-custom.cpp [new file with mode: 0644]