[LLVMdev] [RFC] Section Declarations in LLVM IR
Reid Kleckner
rnk at google.com
Tue Apr 1 14:14:59 PDT 2014
On Tue, Mar 11, 2014 at 12:17 PM, Rafael EspĂndola <
rafael.espindola at gmail.com> wrote:
> > I think LLVM needs new IR to represent these semantics properly.
>
Cool! This proposal makes a lot of sense to me.
> > - Sections have linkage, all Values inside of a section must agree with
> the
> > section's linkage.
>
> This seems way too restrictive and I don't think it maps to what
> object files actually do. We should be able to for example do
>
> $foo = section "bar", ..... comdat "zed", select_largest, etc
>
> @baz = private ... section $foo
> @bah = linkonce_odr alias baz, offset 4
>
> This fully general I think. In particular, the above example
> represents a section name bar, in a comdat represented by the symbol
> zed. The contents of the section is that of @baz and the only visible
> symbol in the section is bah, which is at offset 4.
>
I like this proposal. Any reason to use an explicit offset rather than
allow GEPs into aliases?
> The following is how I imagine MS RTTI would look like if we had this IR
> > construct:
> >
> > $.vdata_for_type = pick_largest read
> > @my_rtti_for_type = pick_largest unnamed_addr constant %rtti_ptr_ty
> > @rtti_complete_object_locator, section $.vdata_for_type, align 4
> > @vftable_for_type = pick_largest unnamed_addr constant [1 x i8*] [i8*
> > bitcast (void (%struct.S*)* @"\01?fun at S@@UAEXXZ" to i8*)], section
> > $.vdata_for_type, align 4
>
> Part of the problem is that it seems that the order is important. We
> really should not require that at the llvm IR level. The above global
> values could be output in any order.
Yeah, let's not rely on order of the IR.
----
+The linkage must be one of ``appending``, ``linkonce_odr``, ``linkonce``.
+
+#. All values inside of a section must have ``external`` linkage if the
section has
+ ``appending``.
It's kind of cute to use appending here, but why not just let 'external'
mean the same as 'appending' for sections? Then we can say something
simple like "the linkage of all symbols in a section must be private,
internal, or the linkage of the section."
+#. All values inside of a section must have ``linkonce_odr`` linkage if the
+ section has ``linkonce_odr``.
+
+#. All values inside of a section must have ``linkonce`` linkage if the
+ section has ``linkonce``.
Sounds like we're going to drop some of these restrictions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140401/570729df/attachment.html>
More information about the llvm-dev
mailing list