[llvm] r183743 - Require members of llvm.used to be named.

Reid Kleckner rnk at google.com
Wed Jul 16 17:10:53 PDT 2014


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.


On Tue, Jun 11, 2013 at 6:18 AM, Rafael Espindola <
rafael.espindola at gmail.com> wrote:

> Author: rafael
> Date: Tue Jun 11 08:18:13 2013
> New Revision: 183743
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183743&view=rev
> Log:
> Require members of llvm.used to be named.
>
> The effect of llvm.used is to introduce an invisible reference, so this
> seems
> a reasonable restriction. It will be used to provide an easy ordering of
> the entries in llvm.used.
>
> Modified:
>     llvm/trunk/docs/LangRef.rst
>     llvm/trunk/lib/IR/Verifier.cpp
>
> Modified: llvm/trunk/docs/LangRef.rst
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.rst?rev=183743&r1=183742&r2=183743&view=diff
>
> ==============================================================================
> --- llvm/trunk/docs/LangRef.rst (original)
> +++ llvm/trunk/docs/LangRef.rst Tue Jun 11 08:18:13 2013
> @@ -2932,8 +2932,8 @@ The '``llvm.used``' Global Variable
>
>  The ``@llvm.used`` global is an array which has
>  :ref:`appending linkage <linkage_appending>`. This array contains a list
> of
> -pointers to global variables, functions and aliases which may optionally
> have a
> -pointer cast formed of bitcast or getelementptr. For example, a legal
> +pointers to named global variables, functions and aliases which may
> optionally
> +have a pointer cast formed of bitcast or getelementptr. For example, a
> legal
>  use of it is:
>
>  .. code-block:: llvm
> @@ -2948,11 +2948,11 @@ use of it is:
>
>  If a symbol appears in the ``@llvm.used`` list, then the compiler,
> assembler,
>  and linker are required to treat the symbol as if there is a reference to
> the
> -symbol that it cannot see. For example, if a variable has internal
> linkage and
> -no references other than that from the ``@llvm.used`` list, it cannot be
> -deleted. This is commonly used to represent references from inline asms
> and
> -other things the compiler cannot "see", and corresponds to
> -"``attribute((used))``" in GNU C.
> +symbol that it cannot see (which is why they have to be named). For
> example, if
> +a variable has internal linkage and no references other than that from the
> +``@llvm.used`` list, it cannot be deleted. This is commonly used to
> represent
> +references from inline asms and other things the compiler cannot "see",
> and
> +corresponds to "``attribute((used))``" in GNU C.
>
>  On some targets, the code generator must emit a directive to the
>  assembler or object file to prevent the assembler and linker from
>
> Modified: llvm/trunk/lib/IR/Verifier.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=183743&r1=183742&r2=183743&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Verifier.cpp (original)
> +++ llvm/trunk/lib/IR/Verifier.cpp Tue Jun 11 08:18:13 2013
> @@ -467,6 +467,7 @@ void Verifier::visitGlobalVariable(Globa
>            Assert1(
>                isa<GlobalVariable>(V) || isa<Function>(V) ||
> isa<GlobalAlias>(V),
>                "invalid llvm.used member", V);
> +          Assert1(V->hasName(), "members of llvm.used must be named", V);
>          }
>        }
>      }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140716/5359456a/attachment.html>


More information about the llvm-commits mailing list