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

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 26 12:46:43 PST 2018


rnk marked an inline comment as done.
rnk added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/CtorUtils.cpp:116
+  bool AssumeComdatInitializers =
+      Triple(M.getTargetTriple()).isWindowsMSVCEnvironment();
+
----------------
rjmccall wrote:
> efriedma wrote:
> > If the IR doesn't have enough information to distinguish between the Microsoft and Itanium ABI cases, we should extend the IR to contain more information.  Checking the triple means we're depending on semantic guarantees which are not documented in LangRef, and many not apply to non-C++ languages.
> I agree with Eli.  This is clearly a frontend-originated guarantee, not a target-wide guarantee, and should be reflected in the IR.
For platforms with comdats, I wanted to push this same idea through the Itanium C++ ABI. It completely eliminates the need for guard variables for initializers of variables with vague linkage, although only if they are hidden, so other DSOs don't try to initialize them.

What do you think of some kind of global named metadata node for this? This is such a complicated guarantee to express, I've tried and failed to write it down concisely three times. `!llvm.assume_comdat_ctors`? `!llvm.comdat_initializers = !{i32 0, i32 1}`? I like "comdat_initializers".


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

https://reviews.llvm.org/D54774





More information about the llvm-commits mailing list