[PATCH] D33202: [LTO] Use GlobalValue::getComdat which knows how to handle ifuncs

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 11:10:25 PDT 2017


On Mon, May 15, 2017 at 9:17 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Teresa Johnson via Phabricator via llvm-commits
> <llvm-commits at lists.llvm.org> writes:
>
> > tejohnson created this revision.
> > Herald added subscribers: inglorion, mehdi_amini.
> >
> > The Value::getComdat interface (invoked by GlobalValue::getComdat) knows
> > how to handle ifuncs. Use this instead of getting the base object and
> > invoking getComdat on it. This was causing LTO to warn about
> > "Unable to determine comdat of alias!" for an ifunc.
>
>
> >
> > https://reviews.llvm.org/D33202
> >
> > Files:
> >   lib/Object/IRSymtab.cpp
> >   test/LTO/Resolution/X86/ifunc.ll
> >
> >
> > Index: test/LTO/Resolution/X86/ifunc.ll
> > ===================================================================
> > --- /dev/null
> > +++ test/LTO/Resolution/X86/ifunc.ll
> > @@ -0,0 +1,15 @@
> > +; RUN: opt -module-summary -o %t.bc %s
> > +; RUN: llvm-lto2 run %t.bc -r %t.bc,foo,pl -o %t2
> > +; RUN: llvm-nm %t2.0 | FileCheck %s
> > +; CHECK: T foo
> > +; CHECK: t foo_ifunc
> > +
> > +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> > +target triple = "x86_64-unknown-linux-gnu"
> > +
> > + at foo = ifunc i32 (i32), i64 ()* @foo_ifunc
> > +
> > +define internal i64 @foo_ifunc() {
> > +entry:
> > +  ret i64 0
> > +}
> > Index: lib/Object/IRSymtab.cpp
> > ===================================================================
> > --- lib/Object/IRSymtab.cpp
> > +++ lib/Object/IRSymtab.cpp
> > @@ -188,11 +188,7 @@
> >      Uncommon().CommonAlign = GV->getAlignment();
> >    }
> >
> > -  const GlobalObject *Base = GV->getBaseObject();
> > -  if (!Base)
> > -    return make_error<StringError>("Unable to determine comdat of
> alias!",
> > -                                   inconvertibleErrorCode());
> > -  if (const Comdat *C = Base->getComdat()) {
> > +  if (const Comdat *C = GV->getComdat()) {
> >      auto P = ComdatMap.insert(std::make_pair(C, Comdats.size()));
> >      Sym.ComdatIndex = P.first->second;
>
> I think you have to fix GlobalValue::getBaseObject instead. The only
> thing wrong with the above code is the error message. If there is any
> GlobalIndirectSymbol for which we cannot find the base, we should
> conservatively error.
>
> Cheers,
> Rafael
>

Done. Uploading new patch and will change description.
Thanks,
Teresa

-- 
Teresa Johnson |  Software Engineer |  tejohnson at google.com |  408-460-2413
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170515/da5f3d35/attachment.html>


More information about the llvm-commits mailing list