[PATCH] IR: Add COMDATs to the IR

Nick Lewycky nlewycky at google.com
Mon Jun 16 14:10:51 PDT 2014


On 13 June 2014 13:34, Rafael Espíndola <rafael.espindola at gmail.com> wrote:

> >> Rafael Ávila de Espíndola wrote:
> >>> Why do you need it to be a Value? This says that a Comdat has a type,
> which seems wrong.
> >> It is a `Value` so that it can participate in things like use lists.
> >>
> >> As an example why this is useful:
> >> If we want to drop a symbol in a COMDAT group, we need to prove we
> don't need any of the symbols in that group.  Iterating over users of the
> COMDAT is a straightforward way of doing this.
> >>
> >> I could recreate this functionality just for COMDATs but it seemed like
> the right way to go.
> >
> > We had problems in the past with a Class being too generic
> > (GlobalAlias being the most recent one), so I would suggest making it
> > specific.All you need to is add a "Use*" to the comdat class, no?
>
> Now that I think of it, a comdat having Uses is probably undesirable
> in itself. Some of the potential issues that come to mind:
>
> * RAUW should not change what is in a comdat.
>

I don't follow. Why shouldn't it?


> * Logic for checking if something has only one use should also not be
> affected by comdats.
>

The GV uses the comdat group, not the other way around?

* Other code walking all uses probably be surprised to find a comdat.
>

Well sure, it's a new IR extension. This happens to not come up in practice
because you need to iterate the list of comdats in the module, or else grab
a section and ask it for its comdat group. You could get there by accident
(I think the section stores its comdat group as an operand) but that never
comes up.

It looks comdats should keep track of what GVs are in them with some
> other mechanism. The simple option of just building this information
> when needed might be sufficient. I think the only cases where we would
> need it is
>
> * Some optimization to drop unused comdats if all their members can be
> dropped.
> * The linker.
>
> Both of these will be looking at the entire module, so they should be
> able to build the set of global values in each comdat as needed.
>

Sure, but why? You're proposing that we reimplement functionality from
Value because we don't need part of the functionality in Value. We want the
value naming and its symbol table, and I'm pretty sure we want the use
lists or equivalent functionality. We don't want a Type, but we can choose
"i8" and move on?

Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140616/ebf4e9e4/attachment.html>


More information about the llvm-commits mailing list