llvm-project/llvm/lib/AsmParser
Leonard Chan a97f62837f [llvm][IR] Add dso_local_equivalent Constant
The `dso_local_equivalent` constant is a wrapper for functions that represents a
value which is functionally equivalent to the global passed to this. That is, if
this accepts a function, calling this constant should have the same effects as
calling the function directly. This could be a direct reference to the function,
the `@plt` modifier on X86/AArch64, a thunk, or anything that's equivalent to the
resolved function as a call target.

When lowered, the returned address must have a constant offset at link time from
some other symbol defined within the same binary. The address of this value is
also insignificant. The name is leveraged from `dso_local` where use of a function
or variable is resolved to a symbol in the same linkage unit.

In this patch:
- Addition of `dso_local_equivalent` and handling it
- Update Constant::needsRelocation() to strip constant inbound GEPs and take
  advantage of `dso_local_equivalent` for relative references

This is useful for the [Relative VTables C++ ABI](https://reviews.llvm.org/D72959)
which makes vtables readonly. This works by replacing the dynamic relocations for
function pointers in them with static relocations that represent the offset between
the vtable and virtual functions. If a function is externally defined,
`dso_local_equivalent` can be used as a generic wrapper for the function to still
allow for this static offset calculation to be done.

See [RFC](http://lists.llvm.org/pipermail/llvm-dev/2020-August/144469.html) for more details.

Differential Revision: https://reviews.llvm.org/D77248
2020-11-19 10:26:17 -08:00
..
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
LLLexer.cpp [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
LLLexer.h LLLexer.h - reduce SourceMgr.h include to SMLoc.h. NFC 2020-04-24 13:27:56 +01:00
LLParser.cpp [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
LLParser.h [NFC] [LLParser] Renaming LLParser routines to comply LLVM coding style 2020-10-28 08:55:27 +05:30
LLToken.h [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
Parser.cpp Infer alignment of unmarked loads in IR/bitcode parsing. 2020-05-14 13:03:50 -07:00