aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/IRSymtab.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2021-09-23 09:23:35 -0700
committerFangrui Song <i@maskray.me>2021-09-23 09:23:35 -0700
commit1a6e1ee42a6af255d45e3fd2fe87021dd31f79bb (patch)
treef41b18f2f78eafd1f7048dad9c5501bcdadfa03b /llvm/lib/Object/IRSymtab.cpp
parentbcb6b97cde84b6acd67d5551302683234c09337c (diff)
downloadllvm-1a6e1ee42a6af255d45e3fd2fe87021dd31f79bb.zip
llvm-1a6e1ee42a6af255d45e3fd2fe87021dd31f79bb.tar.gz
llvm-1a6e1ee42a6af255d45e3fd2fe87021dd31f79bb.tar.bz2
Resolve {GlobalValue,GloalIndirectSymol}::getBaseObject confusion
While both GlobalAlias and GlobalIFunc are GlobalIndirectSymbol, their `getIndirectSymbol()` usage is quite different (GlobalIFunc's resolver is an entity different from GlobalIFunc itself). As discussed on https://lists.llvm.org/pipermail/llvm-dev/2020-September/144904.html ("[IR] Modelling of GlobalIFunc"), the name `getBaseObject` is confusing when used with GlobalIFunc. To resolve the confusion: * Move GloalIndirectSymol::getBaseObject to GlobalAlias:: (GlobalIFunc should use `getResolver` instead) * Change GlobalValue::getBaseObject not to inspect GlobalIFunc. Note: the function has 7 references. * Add GlobalIFunc::getResolverFunction to peel off potential ConstantExpr indirection (`strlen` in `test/LTO/Resolution/X86/ifunc.ll`) Note: GlobalIFunc::getResolver (like GlobalAlias::getAliasee which does not peel off ConstantExpr indirection) is kept to be used by ValueEnumerator. Reviewed By: ibookstein Differential Revision: https://reviews.llvm.org/D109792
Diffstat (limited to 'llvm/lib/Object/IRSymtab.cpp')
-rw-r--r--llvm/lib/Object/IRSymtab.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp
index 746b008..9208f90 100644
--- a/llvm/lib/Object/IRSymtab.cpp
+++ b/llvm/lib/Object/IRSymtab.cpp
@@ -284,9 +284,13 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
}
const GlobalObject *Base = GV->getBaseObject();
- if (!Base)
- return make_error<StringError>("Unable to determine comdat of alias!",
- inconvertibleErrorCode());
+ if (!Base) {
+ if (isa<GlobalIFunc>(GV))
+ Base = cast<GlobalIFunc>(GV)->getResolverFunction();
+ if (!Base)
+ return make_error<StringError>("Unable to determine comdat of alias!",
+ inconvertibleErrorCode());
+ }
if (const Comdat *C = Base->getComdat()) {
Expected<int> ComdatIndexOrErr = getComdatIndex(C, GV->getParent());
if (!ComdatIndexOrErr)