[all-commits] [llvm/llvm-project] a97f62: [llvm][IR] Add dso_local_equivalent Constant
Leonard Chan via All-commits
all-commits at lists.llvm.org
Thu Nov 19 10:27:09 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: a97f62837f59620a60b3ed9f29568440c7d0553a
https://github.com/llvm/llvm-project/commit/a97f62837f59620a60b3ed9f29568440c7d0553a
Author: Leonard Chan <leonardchan at google.com>
Date: 2020-11-19 (Thu, 19 Nov 2020)
Changed paths:
M llvm/docs/LangRef.rst
M llvm/include/llvm/Analysis/ConstantFolding.h
M llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
M llvm/include/llvm/IR/Constants.h
M llvm/include/llvm/IR/Value.def
M llvm/include/llvm/Target/TargetLoweringObjectFile.h
M llvm/lib/Analysis/ConstantFolding.cpp
M llvm/lib/AsmParser/LLLexer.cpp
M llvm/lib/AsmParser/LLParser.cpp
M llvm/lib/AsmParser/LLToken.h
M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
M llvm/lib/IR/AsmWriter.cpp
M llvm/lib/IR/Constants.cpp
M llvm/lib/IR/Core.cpp
M llvm/lib/IR/LLVMContextImpl.h
A llvm/test/CodeGen/X86/dso_local_equivalent.ll
M llvm/test/CodeGen/X86/relptr-rodata.ll
Log Message:
-----------
[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
More information about the All-commits
mailing list