[PATCH] D136877: [ORC][JITLink] Do not claim dead symbols

Jonas Hahnfeld via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 12:31:58 PDT 2022


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

For this to work, only claim or externalize weak symbols post-prune
because the pruning phase also propagates liveness from blocks to
symbols. This fixes JIT codegen of code involving exceptions without
also registering the .eh_frame because the `DW.ref.__gxx_personality_v0`
would be dead-stripped and claimed at the same time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136877

Files:
  llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp


Index: llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
+++ llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
@@ -329,7 +329,7 @@
   Error modifyPassConfig(LinkGraph &LG, PassConfiguration &Config) override {
     // Add passes to mark duplicate defs as should-discard, and to walk the
     // link graph to build the symbol dependence graph.
-    Config.PrePrunePasses.push_back([this](LinkGraph &G) {
+    Config.PostPrunePasses.push_back([this](LinkGraph &G) {
       return claimOrExternalizeWeakAndCommonSymbols(G);
     });
 
@@ -426,7 +426,8 @@
     std::vector<std::pair<SymbolStringPtr, Symbol *>> NameToSym;
 
     auto ProcessSymbol = [&](Symbol *Sym) {
-      if (Sym->hasName() && Sym->getLinkage() == Linkage::Weak &&
+      if (Sym->isLive() && Sym->hasName() &&
+          Sym->getLinkage() == Linkage::Weak &&
           Sym->getScope() != Scope::Local) {
         auto Name = ES.intern(Sym->getName());
         if (!MR->getSymbols().count(ES.intern(Sym->getName()))) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136877.471260.patch
Type: text/x-patch
Size: 1117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221027/601b26bb/attachment.bin>


More information about the llvm-commits mailing list