[PATCH] D54774: [GlobalOpt] Optimize comdat dynamic initializers on Windows

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 26 13:18:56 PST 2018


efriedma added a comment.

Global metadata pointing to what, exactly?  The global variables?

The comdat key in global_ctors provides some sort of guarantee that the global variable definitions in that comdat are "strong", in some sense: if the comdat were discarded, the ctor would also be discarded.  Do we really need any additional guarantee from the frontend?



================
Comment at: llvm/lib/Transforms/Utils/Evaluator.cpp:131
+static bool canUpdateGlobal(GlobalVariable *GV, GlobalVariable *ComdatGV) {
+  return GV == ComdatGV || GV->hasUniqueInitializer();
+}
----------------
Actually, if we have a ComdatGV, isn't it illegal to update globals where hasUniqueInitializer() is true?  The constructor could be discarded.  For example, something like this:

    void foo();
    struct S { S() { foo(); } static S s; };
    inline S S::s;
    S *ss = &S::s;
    int x;
    void foo(){ x++; }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54774/new/

https://reviews.llvm.org/D54774





More information about the llvm-commits mailing list