[llvm] e137b55 - [llvm-jitlink] Don't demote unreferenced definitions in -harness mode.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 11:19:48 PDT 2020
Author: Lang Hames
Date: 2020-08-13T11:19:35-07:00
New Revision: e137b550587a85b0d9c9c539edc79de0122b6946
URL: https://github.com/llvm/llvm-project/commit/e137b550587a85b0d9c9c539edc79de0122b6946
DIFF: https://github.com/llvm/llvm-project/commit/e137b550587a85b0d9c9c539edc79de0122b6946.diff
LOG: [llvm-jitlink] Don't demote unreferenced definitions in -harness mode.
Demoting unreferenced externals is unsafe if multiple interdependent test
objects are used, including objects loaded from archives.
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..49424bf97746 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,8 @@ 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) ||
+ !(*SymFlagsOrErr & object::BasicSymbolRef::SF_Global))
continue;
auto Name = Sym.getName();
@@ -551,10 +548,8 @@ 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))
continue;
- }
auto InternedName = S.ES.intern(*Name);
SymbolFlags[InternedName] = std::move(*SymFlags);
More information about the llvm-commits
mailing list