[PATCH] D159115: [clang-repl] Adapt to the recent dylib-related changes in ORC.
Vassil Vassilev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 29 12:20:56 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG196d8569d46d: [clang-repl] Adapt to the recent dylib-related changes in ORC. (authored by v.g.vassilev).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159115/new/
https://reviews.llvm.org/D159115
Files:
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/unittests/Interpreter/InterpreterTest.cpp
Index: clang/unittests/Interpreter/InterpreterTest.cpp
===================================================================
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -234,10 +234,16 @@
}
std::string MangledName = MangleName(FD);
- auto Addr = cantFail(Interp->getSymbolAddress(MangledName));
- EXPECT_NE(0U, Addr.getValue());
+ auto Addr = Interp->getSymbolAddress(MangledName);
+ EXPECT_FALSE(!Addr);
+ EXPECT_NE(0U, Addr->getValue());
GlobalDecl GD(FD);
- EXPECT_EQ(Addr, cantFail(Interp->getSymbolAddress(GD)));
+ EXPECT_EQ(*Addr, cantFail(Interp->getSymbolAddress(GD)));
+ cantFail(
+ Interp->ParseAndExecute("extern \"C\" int printf(const char*,...);"));
+ Addr = Interp->getSymbolAddress("printf");
+ EXPECT_FALSE(!Addr);
+ EXPECT_EQ((unsigned long long)&printf, Addr->getValue());
}
static void *AllocateObject(TypeDecl *TD, Interpreter &Interp) {
Index: clang/lib/Interpreter/IncrementalExecutor.cpp
===================================================================
--- clang/lib/Interpreter/IncrementalExecutor.cpp
+++ clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -92,12 +92,19 @@
llvm::Expected<llvm::orc::ExecutorAddr>
IncrementalExecutor::getSymbolAddress(llvm::StringRef Name,
SymbolNameKind NameKind) const {
- auto Sym = (NameKind == LinkerName) ? Jit->lookupLinkerMangled(Name)
- : Jit->lookup(Name);
-
- if (!Sym)
- return Sym.takeError();
- return Sym;
+ using namespace llvm::orc;
+ auto SO = makeJITDylibSearchOrder({&Jit->getMainJITDylib(),
+ Jit->getPlatformJITDylib().get(),
+ Jit->getProcessSymbolsJITDylib().get()});
+
+ ExecutionSession &ES = Jit->getExecutionSession();
+
+ auto SymOrErr =
+ ES.lookup(SO, (NameKind == LinkerName) ? ES.intern(Name)
+ : Jit->mangleAndIntern(Name));
+ if (auto Err = SymOrErr.takeError())
+ return std::move(Err);
+ return SymOrErr->getAddress();
}
} // end namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159115.554456.patch
Type: text/x-patch
Size: 2152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230829/30c90f0f/attachment.bin>
More information about the cfe-commits
mailing list