[llvm] f136e5e - Re-apply "[llvm-jitlink] Don't demote unreferenced definitions in -harness mode"

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 13:23:31 PDT 2020


Author: Lang Hames
Date: 2020-08-13T13:23:17-07:00
New Revision: f136e5ecfb335c61a23f09187150f363919df11a

URL: https://github.com/llvm/llvm-project/commit/f136e5ecfb335c61a23f09187150f363919df11a
DIFF: https://github.com/llvm/llvm-project/commit/f136e5ecfb335c61a23f09187150f363919df11a.diff

LOG: Re-apply "[llvm-jitlink] Don't demote unreferenced definitions in -harness mode"

This reapplies commit e137b550587a85b0d9c9c539edc79de0122b6946 with
fixes for the broken test case: Non-global symbols should only be
skipped after checking that they're not referenced by the harness.

Added: 
    

Modified: 
    llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 8e651d903a3b..ff9579bbf5b8 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -187,7 +187,7 @@ static Error applyHarnessPromotions(Session &S, LinkGraph &G) {
 
   // If this graph is part of the test then promote any symbols referenced by
   // the harness to default scope, remove all symbols that clash with harness
-  // definitions, demote all other definitions.
+  // definitions.
   std::vector<Symbol *> DefinitionsToRemove;
   for (auto *Sym : G.defined_symbols()) {
 
@@ -219,10 +219,6 @@ static Error applyHarnessPromotions(Session &S, LinkGraph &G) {
     } else if (S.HarnessDefinitions.count(Sym->getName())) {
       LLVM_DEBUG(dbgs() << "  Externalizing " << Sym->getName() << "\n");
       DefinitionsToRemove.push_back(Sym);
-    } else {
-      LLVM_DEBUG(dbgs() << "  Demoting " << Sym->getName() << "\n");
-      Sym->setScope(Scope::Local);
-      Sym->setLive(false);
     }
   }
 
@@ -521,7 +517,7 @@ Error LLVMJITLinkObjectLinkingLayer::add(JITDylib &JD,
       return SymFlagsOrErr.takeError();
 
     // Skip symbols not defined in this object file.
-    if (*SymFlagsOrErr & object::BasicSymbolRef::SF_Undefined)
+    if ((*SymFlagsOrErr & object::BasicSymbolRef::SF_Undefined))
       continue;
 
     auto Name = Sym.getName();
@@ -551,10 +547,9 @@ Error LLVMJITLinkObjectLinkingLayer::add(JITDylib &JD,
         *SymFlags &= ~JITSymbolFlags::Exported;
     } else if (S.HarnessExternals.count(*Name)) {
       *SymFlags |= JITSymbolFlags::Exported;
-    } else {
-      // Skip symbols that aren't in the HarnessExternals set.
+    } else if (S.HarnessDefinitions.count(*Name) ||
+               !(*SymFlagsOrErr & object::BasicSymbolRef::SF_Global))
       continue;
-    }
 
     auto InternedName = S.ES.intern(*Name);
     SymbolFlags[InternedName] = std::move(*SymFlags);


        


More information about the llvm-commits mailing list