[PATCH] D126341: Order implicitly instantiated global variable's initializer by the reverse instantiation order
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 25 11:11:16 PDT 2022
rnk added a subscriber: alexander-shaposhnikov.
rnk added a comment.
I'm somewhat supportive of the goal here, but I think there are still some underlying issues.
First, why should these guarantees be limited to instantiations and not inline variables? Such as:
int f();
inline int gv1 = f();
inline int gv2 = gv1 + 1; // rely on previous
Second, LLVM doesn't guarantee that global_ctors at the same priority execute in order. See the langref: https://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable So, without a guarantee from LLVM, Clang can't rely on this behavior. LLVM relies on this lack of an ordering guarantee to power globalopt.
Last, what happens when the same global is implicitly instantiated in some other TU? Won't that disrupt the ordering?
+ at alexander-shaposhnikov, who is working on global opt changes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126341/new/
https://reviews.llvm.org/D126341
More information about the cfe-commits
mailing list