[PATCH] D42612: [GlobalOpt] Improve common case efficiency of static global initializer evaluation

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 21:22:17 PST 2018


aemerson added a comment.

In https://reviews.llvm.org/D42612#992814, @Gerolf wrote:

> This is very close now. Could you add an explicit examples  (eg show the IR) showing which initialization remain slow (Complex) and which are fast now? This should also address the spirit of Adrian's question I think.
>
> Thanks
> Gerolf


Sure I'll a detailed comment, this is a tricky thing to get right, and testing is awkward because we rely on LLVM statically evaluating the initializers in order to trigger this code.



================
Comment at: lib/Transforms/IPO/GlobalOpt.cpp:2301
+
+  auto ValidateOrCommitCache = [&](GlobalVariable *GV, bool ForceCommit) {
+    Constant *Init = GV->getInitializer();
----------------
Gerolf wrote:
> I admit it still hurts my eye to see back to back checks for CurrentGV and ForceCommit. How about this: I think in your final instance of the lambda it can be guaranteed that CurrentGV != null. So there could be a bool parameter 'bool Update'(instead of ForceCommit) and pass GV !=CurrentGV to Update, while on the final call Update is passed true.
Fair point. I'll make that change.


Repository:
  rL LLVM

https://reviews.llvm.org/D42612





More information about the llvm-commits mailing list