[PATCH] D125278: [GlobalOpt] Relax the check for ctor priorities
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 9 17:43:32 PDT 2022
alexander-shaposhnikov added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/CtorUtils.cpp:159
continue;
}
}
----------------
rnk wrote:
> It looks to me that we attempt to fold any and all constructors, and we don't stop after we fail to evaluate one of them. I think stopping on the first one that fails would be sound. Effectively, it is "as if" the first constructors ran before the first constructor which cannot be folded.
>
> This is, however, quite unsatisfying since it would prevent folding `gv3` in my linked example, but that's kind of the point.
Oh, right.
To preserve the current behavior for the case when all the constructors in llvm.global_ctors have the same priority
we can do the following:
1/ llvm.global_ctors "splits" into groups by priority (in a "stable" manner)
2/ The groups are evaluated in order (according their priorities) and within a given group the evaluation works as before
3/ If we have fully evaluated & committed group_1, group_2, ... , group_n and can't fully evaluate group_{n+ 1} - then we stop (do not attempt to process group_{n + 2}, group_{n + 3} ... since the state is unknown).
Does this sound reasonable / have I missed something ?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125278/new/
https://reviews.llvm.org/D125278
More information about the llvm-commits
mailing list