[PATCH 1/3] Add new keyword externally_initialized to LLVM.

Sean Silva silvas at purdue.edu
Fri Feb 1 15:01:59 PST 2013


+By default, LLVM optimizes global initializers by assuming that global
+variables defined within the module are not modified from their
+initial values before the start of the global initializer.

Is this assumption documented anywhere else in LangRef?

If not, then this creates a normative specification about the
semantics of globals in LLVM IR. I'm not saying whether that is good
or bad, but is it intentional? If so, I would rather add this
specification in a separate patch fixing the omission (it is
essentially fixing a documentation bug (unspecified aspect of the
language); no need to confuse that change with adding a new language
feature).

Also, almost all uses of "LLVM" in this document refer to the
language/IR/"VM", rather than "the LLVM libraries/project" [1]; I
think this distinction is important to uphold (admittedly, it probably
ought to be clarified). I would thus prefer avoiding a phrase like
"LLVM optimizes", and opt for something more neutral like "Global
initializers may assume that ...". Note how other parts of this
section merely say that what they specify "enables better
optimization" (or something like that). A less neutral rationale can
also be added (see r174007 for an example).

[1] e.g. in the first paragraph "LLVM is a Static Single Assignment
(SSA) based representation that provides type safety, low-level
operations, flexibility, and the capability of representing ‘all’
high-level languages cleanly. It is the common code representation
used throughout all phases of the LLVM compilation strategy."

-- Sean Silva




More information about the llvm-commits mailing list