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

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 09:17:56 PDT 2017


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


More information about the llvm-commits mailing list