diff options
author | Itay Bookstein <ibookstein@gmail.com> | 2021-10-20 10:29:47 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-10-20 10:29:47 -0700 |
commit | 08ed216000b6503a4a4be52f18394d008d5fb8f4 (patch) | |
tree | ca6e548769b20dc1d85b84be27a7e1be101042da /llvm/lib/Object/ModuleSymbolTable.cpp | |
parent | 7562f3df89066ab92a816dc23005c45fd642bdf9 (diff) | |
download | llvm-08ed216000b6503a4a4be52f18394d008d5fb8f4.zip llvm-08ed216000b6503a4a4be52f18394d008d5fb8f4.tar.gz llvm-08ed216000b6503a4a4be52f18394d008d5fb8f4.tar.bz2 |
[IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove GlobalIndirectSymbol
As discussed in:
* https://reviews.llvm.org/D94166
* https://lists.llvm.org/pipermail/llvm-dev/2020-September/145031.html
The GlobalIndirectSymbol class lost most of its meaning in
https://reviews.llvm.org/D109792, which disambiguated getBaseObject
(now getAliaseeObject) between GlobalIFunc and everything else.
In addition, as long as GlobalIFunc is not a GlobalObject and
getAliaseeObject returns GlobalObjects, a GlobalAlias whose aliasee
is a GlobalIFunc cannot currently be modeled properly. Creating
aliases for GlobalIFuncs does happen in the wild (e.g. glibc). In addition,
calling getAliaseeObject on a GlobalIFunc will currently return nullptr,
which is undesirable because it should return the object itself for
non-aliases.
This patch refactors the GlobalIFunc class to inherit directly from
GlobalObject, and removes GlobalIndirectSymbol (while inlining the
relevant parts into GlobalAlias and GlobalIFunc). This allows for
calling getAliaseeObject() on a GlobalIFunc to return the GlobalIFunc
itself, making getAliaseeObject() more consistent and enabling
alias-to-ifunc to be properly modeled in the IR.
I exercised some judgement in the API clients of GlobalIndirectSymbol:
some were 'monomorphized' for GlobalAlias and GlobalIFunc, and
some remained shared (with the type adapted to become GlobalValue).
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D108872
Diffstat (limited to 'llvm/lib/Object/ModuleSymbolTable.cpp')
-rw-r--r-- | llvm/lib/Object/ModuleSymbolTable.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp b/llvm/lib/Object/ModuleSymbolTable.cpp index cbe9c69..954d1f0 100644 --- a/llvm/lib/Object/ModuleSymbolTable.cpp +++ b/llvm/lib/Object/ModuleSymbolTable.cpp @@ -204,8 +204,9 @@ uint32_t ModuleSymbolTable::getSymbolFlags(Symbol S) const { if (GVar->isConstant()) Res |= BasicSymbolRef::SF_Const; } - if (isa_and_nonnull<Function>(GV->getAliaseeObject()) || isa<GlobalIFunc>(GV)) - Res |= BasicSymbolRef::SF_Executable; + if (const GlobalObject *GO = GV->getAliaseeObject()) + if (isa<Function>(GO) || isa<GlobalIFunc>(GO)) + Res |= BasicSymbolRef::SF_Executable; if (isa<GlobalAlias>(GV)) Res |= BasicSymbolRef::SF_Indirect; if (GV->hasPrivateLinkage()) |