[llvm] r290537 - Test the different scenarios of GlobalDCE and comdats more

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 09:52:45 PST 2017


On Thu, Jan 5, 2017 at 9:49 AM Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Chandler Carruth via llvm-commits <llvm-commits at lists.llvm.org> writes:
> > For example, it seemed like a bug that GlobalDCE didn't consider comdat
> > participation of ifuncs. Specifically it seemed like an accident because
> > testing didn't really cover that case. But in fact, ifuncs specifically
> > cannot participate in a comdat despite having that API. The new test
> > case covers this and explicitly documents that DCE gets to fire here
> > even though there are comdats involved.
>
> I think your first impression was correct and you found a bug.
>
> Given just
>
> $test5_c = comdat any
> @test5_if = linkonce_odr ifunc void (), void ()* @test5_f
> define linkonce_odr void @test5_f() comdat($test5_c) {
>   ret void
> }
>
> llc produces
>
>         .weak   test5_if
>         .type   test5_if, at function
>         .type   test5_if, at gnu_indirect_function
> test5_if = test5_f
>
> which both gas and MC map to test5_f and test5_if having the same
> section and that section being in a comdat:
>
> COMDAT group section [    3] `.group' [test5_c] contains 1 sections:
>    [Index]    Name
>    [    4]   .text.test5_f
>
> Symbol table '.symtab' contains 6 entries:
>    Num:    Value          Size Type    Bind   Vis      Ndx Name
>      0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
>      1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS test.ll
>      2: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT    3 test5_c
>      3: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
>      4: 0000000000000000     1 FUNC    WEAK   DEFAULT    4 test5_f
>      5: 0000000000000000     1 IFUNC   WEAK   DEFAULT    4 test5_if
>
> So if this comdat is not selected, the linker will treat test5_f and
> test5_if as undefined.
>

I mean, that does indeed make sense. It seemed very odd for aliases to be
in comdats but not ifuncs. However:
https://github.com/llvm-project/llvm-project/blob/master/llvm/lib/IR/Globals.cpp#L157-L159

Makes it clear that LLVM doesn't (yet) support this at all. =/ Maybe file a
PR where this makes a difference and assign it to the folks who added ifunc
support? The test case should get updated when the code above does.

-Chandler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170105/addba397/attachment.html>


More information about the llvm-commits mailing list