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.
The two opcode cases are both doing the same checks (is it a global variable with a definitive initializer), but the checking is structured differently. Suggest structuring the checks the same way for both opcodes.