[PATCH] D130449: [JITLink] Introduce WeakExternal linkage type.

Sunho Kim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 24 18:47:23 PDT 2022


sunho created this revision.
sunho added reviewers: lhames, sgallagher.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
sunho requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Introduces WeakExternal linkage type to JITLink that looks up external definition before trying to use definition in current linkgraph.

In COFF, there is a notion of weak external symbol. The exact behaviour is defined as follwing in the spec: "If a definition of external symbol is linked, then an external reference to the symbol is resolved normally. If a definition of external symbol is not linked, then all references to the weak external for external symbol refer to stub symbol instead."

An aspect where it's inaccurate to use current Weak jitlink linkage type is that it does not eagerly looks for external definition, but everyone defines it blindly and the one defined earlier is used. So, in the testcase added in this patch, it will not look for definition in strong_def.yaml, thus linkgraph of strong_def.yaml will not even be emitted. WeakExternal linkage type gives a priority to external definition which solves this issue.


https://reviews.llvm.org/D130449

Files:
  llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
  llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
  llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
  llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.cpp
  llvm/test/ExecutionEngine/JITLink/X86/COFF_weak_external.s
  llvm/test/ExecutionEngine/JITLink/X86/COFF_weak_external_multiple_defs.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130449.447166.patch
Type: text/x-patch
Size: 8719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220725/a3ab2a53/attachment.bin>


More information about the llvm-commits mailing list