<div dir="ltr">Why can't we have unnamed globals in @llvm.used?  I just tried to create some unnamed globals in Clang to implement pragma init_seg, but this verifier check rejected my IR.  I can name them, but there is no reason to.  They will have private linkage, and they will go in an explicit section similar to .init_array, which will be found later either by the CRT or some other external code.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 11, 2013 at 6:18 AM, Rafael Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Tue Jun 11 08:18:13 2013<br>
New Revision: 183743<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=183743&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=183743&view=rev</a><br>
Log:<br>
Require members of llvm.used to be named.<br>
<br>
The effect of llvm.used is to introduce an invisible reference, so this seems<br>
a reasonable restriction. It will be used to provide an easy ordering of<br>
the entries in llvm.used.<br>
<br>
Modified:<br>
    llvm/trunk/docs/LangRef.rst<br>
    llvm/trunk/lib/IR/Verifier.cpp<br>
<br>
Modified: llvm/trunk/docs/LangRef.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=183743&r1=183742&r2=183743&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=183743&r1=183742&r2=183743&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/docs/LangRef.rst (original)<br>
+++ llvm/trunk/docs/LangRef.rst Tue Jun 11 08:18:13 2013<br>
@@ -2932,8 +2932,8 @@ The '``llvm.used``' Global Variable<br>
<br>
 The ``@llvm.used`` global is an array which has<br>
 :ref:`appending linkage <linkage_appending>`. This array contains a list of<br>
-pointers to global variables, functions and aliases which may optionally have a<br>
-pointer cast formed of bitcast or getelementptr. For example, a legal<br>
+pointers to named global variables, functions and aliases which may optionally<br>
+have a pointer cast formed of bitcast or getelementptr. For example, a legal<br>
 use of it is:<br>
<br>
 .. code-block:: llvm<br>
@@ -2948,11 +2948,11 @@ use of it is:<br>
<br>
 If a symbol appears in the ``@llvm.used`` list, then the compiler, assembler,<br>
 and linker are required to treat the symbol as if there is a reference to the<br>
-symbol that it cannot see. For example, if a variable has internal linkage and<br>
-no references other than that from the ``@llvm.used`` list, it cannot be<br>
-deleted. This is commonly used to represent references from inline asms and<br>
-other things the compiler cannot "see", and corresponds to<br>
-"``attribute((used))``" in GNU C.<br>
+symbol that it cannot see (which is why they have to be named). For example, if<br>
+a variable has internal linkage and no references other than that from the<br>
+``@llvm.used`` list, it cannot be deleted. This is commonly used to represent<br>
+references from inline asms and other things the compiler cannot "see", and<br>
+corresponds to "``attribute((used))``" in GNU C.<br>
<br>
 On some targets, the code generator must emit a directive to the<br>
 assembler or object file to prevent the assembler and linker from<br>
<br>
Modified: llvm/trunk/lib/IR/Verifier.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=183743&r1=183742&r2=183743&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=183743&r1=183742&r2=183743&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/IR/Verifier.cpp (original)<br>
+++ llvm/trunk/lib/IR/Verifier.cpp Tue Jun 11 08:18:13 2013<br>
@@ -467,6 +467,7 @@ void Verifier::visitGlobalVariable(Globa<br>
           Assert1(<br>
               isa<GlobalVariable>(V) || isa<Function>(V) || isa<GlobalAlias>(V),<br>
               "invalid llvm.used member", V);<br>
+          Assert1(V->hasName(), "members of llvm.used must be named", V);<br>
         }<br>
       }<br>
     }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>