When storing pointers in struct/class constructor clang often generates IR like this:
define internal void @_GLOBAL__sub_I_main.cpp() { %1 = load i64, i64* bitcast (%struct.A** @gA to i64*), align 8 store i64 %1, i64* bitcast (%struct.S* @s to i64*), align 8 ret void }
which corresponds to following C++ code:
extern A *gA; struct S { A* _a; } SObj(gA);
With D43077 it is now possible to import variables from different TU when using ThinLTO,
so it would be nice to optimize such static ctors out.