[PATCH] D108872: [IR] Refactor GlobalIFunc to inherit from GlobalObject, Remove GlobalIndirectSymbol

Itay Bookstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 28 09:15:26 PDT 2021


ibookstein created this revision.
ibookstein added reviewers: DmitryPolukhin, tejohnson, dexonsmith.
Herald added a reviewer: deadalnix.
Herald added subscribers: ormris, jdoerfert, hiraditya.
ibookstein requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

As discussed in:

- https://reviews.llvm.org/D94166
- https://lists.llvm.org/pipermail/llvm-dev/2020-September/145031.html

The current behavior of GlobalValue::getBaseObject is inconsistent.
For example, calling getBaseObject on a GlobalAlias whose Aliasee
is a GlobalIFunc will return nullptr, whilst calling getBaseObject on
the GlobalIFunc itself will return the resolver. Because of that, it is
also the case that for GlobalIFunc, GI->getBaseObject()->getType() is
not necessarily equal to GI->getType() (the type of the resolver will
often not be equal to the type of the IFunc itself).

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 getBaseObject() on a GlobalIFunc to return the GlobalIFunc
itself, making getBaseObject() more consistent.

I exercised some judgement in the API clients of GlobalIndirectSymbol:
some were 'monomorphized' for GlobalIFunc and GlobalIFunc, and
some remained shared (with the type adapted to become GlobalValue).

This is the initial patch intended to be able to base a a discussion on.
It passes all the tests, but a few decisions I made along the way felt
a bit dubious (such as the introduction of GlobalValue::getRootObject).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108872

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/AsmParser/LLParser.h
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/GlobalAlias.h
  llvm/include/llvm/IR/GlobalIFunc.h
  llvm/include/llvm/IR/GlobalIndirectSymbol.h
  llvm/include/llvm/IR/GlobalObject.h
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Value.h
  llvm/include/llvm/Transforms/Utils/ValueMapper.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Globals.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/Utils/SplitModule.cpp
  llvm/lib/Transforms/Utils/ValueMapper.cpp
  llvm/unittests/IR/ConstantsTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108872.369267.patch
Type: text/x-patch
Size: 56762 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210828/2f486b32/attachment-0001.bin>


More information about the llvm-commits mailing list