summaryrefslogtreecommitdiffstats
path: root/llvm/docs
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-03-07 15:45:40 +0000
committerDuncan Sands <baldrick@free.fr>2009-03-07 15:45:40 +0000
commit12da8ce3d2b9c365b2e204fcf2b4002177fc6b8b (patch)
tree023775b45b2c7ece7e0bb33e31414f4fc7b6efa2 /llvm/docs
parentc61149d79656faa7822c32d34f36726e623bf704 (diff)
downloadbcm5719-llvm-12da8ce3d2b9c365b2e204fcf2b4002177fc6b8b.tar.gz
bcm5719-llvm-12da8ce3d2b9c365b2e204fcf2b4002177fc6b8b.zip
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions, except that they indicate that the global will only be overridden by an *equivalent* global. In C, a function with weak linkage can be overridden by a function which behaves completely differently. This means that IP passes have to skip weak functions, since any deductions made from the function definition might be wrong, since the definition could be replaced by something completely different at link time. This is not allowed in C++, thanks to the ODR (One-Definition-Rule): if a function is replaced by another at link-time, then the new function must be the same as the original function. If a language knows that a function or other global can only be overridden by an equivalent global, it can give it the weak_odr linkage type, and the optimizers will understand that it is alright to make deductions based on the function body. The code generators on the other hand map weak and weak_odr linkage to the same thing. llvm-svn: 66339
Diffstat (limited to 'llvm/docs')
-rw-r--r--llvm/docs/LangRef.html21
-rw-r--r--llvm/docs/ProgrammersManual.html11
2 files changed, 24 insertions, 8 deletions
diff --git a/llvm/docs/LangRef.html b/llvm/docs/LangRef.html
index 83ea026c6b7..0985cbd61e6 100644
--- a/llvm/docs/LangRef.html
+++ b/llvm/docs/LangRef.html
@@ -545,11 +545,26 @@ All Global Variables and Functions have one of the following types of linkage:
</dd>
<dt><tt><b><a name="linkage_externweak">extern_weak</a></b></tt>: </dt>
+
<dd>The semantics of this linkage follow the ELF object file model: the
symbol is weak until linked, if not linked, the symbol becomes null instead
of being an undefined reference.
</dd>
+ <dt><tt><b><a name="linkage_linkonce">linkonce_odr</a></b></tt>: </dt>
+ <dt><tt><b><a name="linkage_common">common_odr</a></b></tt>: </dt>
+ <dt><tt><b><a name="linkage_weak">weak_odr</a></b></tt>: </dt>
+ <dt><tt><b><a name="linkage_externweak">extern_weak_odr</a></b></tt>: </dt>
+ <dd>Some languages allow inequivalent globals to be merged, such as two
+ functions with different semantics. Other languages, such as <tt>C++</tt>,
+ ensure that only equivalent globals are ever merged (the "one definition
+ rule" - <tt>odr</tt>). Such languages can use the <tt>linkonce_odr</tt>,
+ <tt>common_odr</tt>, <tt>weak_odr</tt> and <tt>extern_weak_odr</tt> linkage
+ types to indicate that the global will only be merged with equivalent
+ globals. These linkage types are otherwise the same as their
+ non-<tt>odr</tt> versions.
+ </dd>
+
<dt><tt><b><a name="linkage_external">externally visible</a></b></tt>:</dt>
<dd>If none of the above identifiers are used, the global is externally
@@ -592,9 +607,9 @@ external (i.e., lacking any linkage declarations), they are accessible
outside of the current module.</p>
<p>It is illegal for a function <i>declaration</i>
to have any linkage type other than "externally visible", <tt>dllimport</tt>,
-or <tt>extern_weak</tt>.</p>
-<p>Aliases can have only <tt>external</tt>, <tt>internal</tt> and <tt>weak</tt>
-linkages.</p>
+<tt>extern_weak</tt> or <tt>extern_weak_odr</tt>.</p>
+<p>Aliases can have only <tt>external</tt>, <tt>internal</tt>, <tt>weak</tt>
+or <tt>weak_odr</tt> linkages.</p>
</div>
<!-- ======================================================================= -->
diff --git a/llvm/docs/ProgrammersManual.html b/llvm/docs/ProgrammersManual.html
index 289a5690249..cf46a97e688 100644
--- a/llvm/docs/ProgrammersManual.html
+++ b/llvm/docs/ProgrammersManual.html
@@ -3322,11 +3322,12 @@ never change at runtime).</p>
<p>Create a new global variable of the specified type. If
<tt>isConstant</tt> is true then the global variable will be marked as
unchanging for the program. The Linkage parameter specifies the type of
- linkage (internal, external, weak, linkonce, appending) for the variable. If
- the linkage is InternalLinkage, WeakLinkage, or LinkOnceLinkage,&nbsp; then
- the resultant global variable will have internal linkage. AppendingLinkage
- concatenates together all instances (in different translation units) of the
- variable into a single variable but is only applicable to arrays. &nbsp;See
+ linkage (internal, external, weak, linkonce, appending) for the variable.
+ If the linkage is InternalLinkage, WeakAnyLinkage, WeakODRLinkage,
+ LinkOnceAnyLinkage or LinkOnceODRLinkage,&nbsp; then the resultant
+ global variable will have internal linkage. AppendingLinkage concatenates
+ together all instances (in different translation units) of the variable
+ into a single variable but is only applicable to arrays. &nbsp;See
the <a href="LangRef.html#modulestructure">LLVM Language Reference</a> for
further details on linkage types. Optionally an initializer, a name, and the
module to put the variable into may be specified for the global variable as
OpenPOWER on IntegriCloud