[patch] Change the .ll syntax for comdats and add a syntactic sugar

David Majnemer david.majnemer at gmail.com
Mon Jan 5 21:25:51 PST 2015


It seems wrong to make it 'comdat $foo global i32 42' instead of 'global
i32 42, comdat $foo'.  We seem to usually follow the convention that we
comma delimitate optional things like alignment. More importantly, I'd like
comdat and section to be near each other because they are very related.

To be honest, I don't really like the idea of providing two ways to do it
but if we must can we at least support 'comdat $foo', 'comdat(any)',
'comdat(largest)' etc? Special casing 'comdat any' seems wrong.

On Mon, Jan 5, 2015 at 7:51 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

> > On 2015 Jan 5, at 11:34, Rafael EspĂ­ndola <rafael.espindola at gmail.com>
> wrote:
> >
> > In order to make comdats always explicit in the IR, we decided to make
> > the syntax a bit more compact for the case o a GlobalObject in a
> > comdat with the same name.
> >
> > Just dropping the $name causes problems for
> >
> > @foo = globabl i32 0, comdat
> > $bar = comdat ...
> >
> > and
> >
> > declare void @foo() comdat
> > $bar = comdat ...
> >
> > so the attached patch changes the syntax to
> >
> > @foo = comdat $foo global i32 0
> >
> > and
> >
> > declare comdat $foo void @foo
> >
> > and as a syntactic sugar
> >
> > $foo = comdat ...
> > @foo = comdat global ...
> >
> > is now equivalent to
> >
> > $foo = comdat ...
> > @foo = comdat $foo global ...
> >
> > and
> >
> > $foo = comdat ...
> > declare comdat void @foo(...
> >
> > is now equivalent to
> >
> > $foo = comdat ...
> > declare comdat $foo void @foo(...
>
> This SGTM.
>
> > It would be possible to take this one step further and make
> >
> > @foo = comdat global ...
> >
> > equivalent to
> >
> > $foo = comdat any
> > @foo = comdat $foo global ...
> >
> > but it is not clear if that is worth it. It would require rejecting
> things like
> >
> > $foo = comdat largest
> > @foo = comdat global...
>
> I think this behaviour would be confusing.
>
> > Maybe as an independent patch we could make all
> >
> > $foo = comdat any
> >
> > optional instead?
>
> Sounds reasonable to me...
>
> >
> > Cheers,
> > Rafael
> > <llvm.patch><clang.patch>
>
> (Haven't had a chance to look at the patches, will do tomorrow if no one
> beats me to it.)
>
>
>
>
> _______________________________________________
> 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/20150105/6a632d85/attachment.html>


More information about the llvm-commits mailing list