llvm-project/llvm/lib/IR
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
..
AbstractCallSite.cpp Remove getNumUses() comparisons (NFC) 2020-05-02 11:05:19 +02:00
AsmWriter.cpp [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
AttributeImpl.h Reapply "OpaquePtr: Add type to sret attribute" 2020-10-16 11:05:02 -04:00
Attributes.cpp Revert "[IR] add fn attr for no_stack_protector; prevent inlining on mismatch" 2020-11-17 17:27:14 -08:00
AutoUpgrade.cpp [llvm][mlir] Promote the experimental reduction intrinsics to be first class intrinsics. 2020-10-07 10:36:44 -07:00
BasicBlock.cpp [IR] Use llvm::is_contained in BasicBlock::removePredecessor (NFC) 2020-11-15 21:15:31 -08:00
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
Comdat.cpp
ConstantFold.cpp [SVE] Take constant fold fast path for splatted vscale vectors 2020-11-17 12:45:31 -08:00
ConstantFold.h Remove "mask" operand from shufflevector. 2020-03-31 13:08:59 -07:00
ConstantRange.cpp [ConstantRange] Introduce getMinSignedBits() method 2020-09-22 21:37:30 +03:00
Constants.cpp [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
ConstantsContext.h [IR] Add classof methods to ConstantExpr subclasses. 2020-07-01 11:56:12 -07:00
Core.cpp [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
DIBuilder.cpp [DebugInfo] Expose Fortran array debug info attributes through DIBuilder. 2020-10-28 13:13:35 -07:00
DataLayout.cpp [SVE] Make ElementCount members private 2020-08-28 14:43:53 +01:00
DebugInfo.cpp [Instruction] Add dropLocation and updateLocationAfterHoist helpers 2020-09-24 15:00:04 -07:00
DebugInfoMetadata.cpp [DebugInfo] Support for DW_TAG_generic_subrange 2020-10-29 01:34:15 +05:30
DebugLoc.cpp Pass DebugLoc::appendInlinedAt DebugLoc arg by const reference not value. 2020-07-01 16:38:51 +01:00
DiagnosticHandler.cpp
DiagnosticInfo.cpp Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM" 2020-11-14 13:12:38 +03:00
DiagnosticPrinter.cpp
Dominators.cpp [DomTree] Make assert more precise 2020-10-22 22:40:06 +02:00
FPEnv.cpp Fix some clang-tidy namespace closing comments warnings. NFC. 2020-06-26 09:58:21 +01:00
Function.cpp [VE] Support vld intrinsics 2020-11-13 07:34:42 +09:00
GVMaterializer.cpp
Globals.cpp [X86][ELF] Prefer lowering MC_GlobalAddress operands to .Lfoo$local for STV_DEFAULT only 2020-08-14 00:09:15 +01:00
IRBuilder.cpp [RS4GC] NFC. Preparatory refactoring to make GC parseable memcpy 2020-10-21 12:38:20 -07:00
IRPrintingPasses.cpp IRPrintingPasses.h - simplify unnecessary header with forward declarations. NFC. 2020-07-27 14:51:28 +01:00
InlineAsm.cpp
Instruction.cpp [IR] Merge metadata manipulation code into Value 2020-10-23 11:08:26 +07:00
Instructions.cpp [IR] ShuffleVectorInst::isIdentityWithPadding - bail on non-fixed-type vector shuffles. 2020-11-17 16:16:51 +00:00
IntrinsicInst.cpp [VP][NFC] Rename to HANDLE_VP_TO_OPC 2020-11-16 10:24:18 +01:00
LLVMContext.cpp Introduce a "gc-live" bundle for the gc arguments of a statepoint 2020-06-03 15:00:24 -07:00
LLVMContextImpl.cpp IR: Clarify ownership of ConstantDataSequentials, NFC 2020-10-26 18:47:25 -04:00
LLVMContextImpl.h [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
LLVMRemarkStreamer.cpp Avoid including FileSystem.h from MemoryBuffer.h 2020-02-29 12:30:23 -08:00
LegacyPassManager.cpp Reland No.3: Add new hidden option -print-changed which only reports changes to IR 2020-10-01 17:39:13 +00:00
MDBuilder.cpp Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM" 2020-11-14 13:12:38 +03:00
Mangler.cpp fix symbol printing on windows 2020-10-15 17:14:55 -04:00
Metadata.cpp [IRGen] Add !annotation metadata for auto-init stores. 2020-11-16 10:37:02 +00:00
MetadataImpl.h
Module.cpp [PGO] Improve the working set size heuristics under the partial sample PGO. 2020-06-01 10:29:23 -07:00
ModuleSummaryIndex.cpp [ThinLTO] Compile time improvement to propagateAttributes 2020-07-31 10:54:02 -07:00
Operator.cpp Fix some clang-tidy namespace closing comments warnings. NFC. 2020-06-26 09:58:21 +01:00
OptBisect.cpp
Pass.cpp [Pass] Ensure we don't include PassSupport.h or PassAnalysisSupport.h directly 2020-04-26 12:58:20 +01:00
PassInstrumentation.cpp [Debugify] Skip debugifying on special/immutable passes 2020-11-16 20:39:46 -08:00
PassManager.cpp Revert rG5dd566b7c7b78bd- "PassManager.h - remove unnecessary Function.h/Module.h includes. NFCI." 2020-07-24 13:02:33 +01:00
PassRegistry.cpp [Pass] Ensure we don't include PassSupport.h or PassAnalysisSupport.h directly 2020-04-26 12:58:20 +01:00
PassTimingInfo.cpp [NewPM][PassInstrumentation] Add PreservedAnalyses parameter to AfterPass* callbacks 2020-08-21 16:10:42 +07:00
ProfileSummary.cpp ProfileSummary.cpp - use auto const& iterator in for-range loop to avoid copies. NFCI. 2020-09-21 16:54:26 +01:00
SafepointIRVerifier.cpp Fix some clang-tidy namespace closing comments warnings. NFC. 2020-06-26 09:58:21 +01:00
Statepoint.cpp [Statepoint] Start the process of removing old interfaces 2020-06-03 20:00:52 -07:00
StructuralHash.cpp (Expensive) Check for Loop, SCC and Region pass return status 2020-08-28 07:56:35 +02:00
SymbolTableListTraitsImpl.h [IR] Lazily number instructions for local dominance queries 2020-02-18 14:44:24 -08:00
Type.cpp [SVE] Make ElementCount members private 2020-08-28 14:43:53 +01:00
TypeFinder.cpp
Use.cpp [IR] Simplify Use::swap. NFCI. 2020-07-21 12:15:12 +01:00
User.cpp [NFC] Edit the comment in User::replaceUsesOfWith 2020-07-29 10:02:04 +08:00
Value.cpp [IR] Merge metadata manipulation code into Value 2020-10-23 11:08:26 +07:00
ValueSymbolTable.cpp NFC: Clean up the implementation of StringPool a bit, and remove dependence on some "implicitly MallocAllocator" based methods on StringMapEntry. This allows reducing the #includes in StringMapEntry.h. 2020-04-12 16:37:17 -07:00
Verifier.cpp Revert "[IR] add fn attr for no_stack_protector; prevent inlining on mismatch" 2020-11-17 17:27:14 -08:00