[PATCH] IR: Add COMDATs to the IR
rafael.espindola at gmail.com
Fri Jun 13 13:34:55 PDT 2014
>> 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.
* Logic for checking if something has only one use should also not be
affected by comdats.
* Other code walking all uses probably be surprised to find a comdat.
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.
More information about the llvm-commits