[clang] fe1f344 - [clang-repl] JITTargetAddress --> ExecutorAddr, NFC
Jun Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 15 18:47:35 PDT 2023
Author: Jun Zhang
Date: 2023-04-16T09:46:44+08:00
New Revision: fe1f34453d7ef2c0d5f308e0abdb185d6807cfa6
URL: https://github.com/llvm/llvm-project/commit/fe1f34453d7ef2c0d5f308e0abdb185d6807cfa6
DIFF: https://github.com/llvm/llvm-project/commit/fe1f34453d7ef2c0d5f308e0abdb185d6807cfa6.diff
LOG: [clang-repl] JITTargetAddress --> ExecutorAddr, NFC
Most of Orc and JITLink are movinng away from JITTargetAddress and
use ExecutorAddr instead.
Signed-off-by: Jun Zhang <jun at junz.org>
Differential Revision: https://reviews.llvm.org/D148434
Added:
Modified:
clang/include/clang/Interpreter/Interpreter.h
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/lib/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/Interpreter.cpp
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
clang/unittests/Interpreter/InterpreterTest.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Interpreter/Interpreter.h b/clang/include/clang/Interpreter/Interpreter.h
index b20d77e8ef853..b3d64458d777c 100644
--- a/clang/include/clang/Interpreter/Interpreter.h
+++ b/clang/include/clang/Interpreter/Interpreter.h
@@ -19,6 +19,7 @@
#include "clang/AST/GlobalDecl.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
+#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
#include "llvm/Support/Error.h"
#include <memory>
@@ -78,18 +79,18 @@ class Interpreter {
/// Link a dynamic library
llvm::Error LoadDynamicLibrary(const char *name);
- /// \returns the \c JITTargetAddress of a \c GlobalDecl. This interface uses
+ /// \returns the \c ExecutorAddr of a \c GlobalDecl. This interface uses
/// the CodeGenModule's internal mangling cache to avoid recomputing the
/// mangled name.
- llvm::Expected<llvm::JITTargetAddress> getSymbolAddress(GlobalDecl GD) const;
+ llvm::Expected<llvm::orc::ExecutorAddr> getSymbolAddress(GlobalDecl GD) const;
- /// \returns the \c JITTargetAddress of a given name as written in the IR.
- llvm::Expected<llvm::JITTargetAddress>
+ /// \returns the \c ExecutorAddr of a given name as written in the IR.
+ llvm::Expected<llvm::orc::ExecutorAddr>
getSymbolAddress(llvm::StringRef IRName) const;
- /// \returns the \c JITTargetAddress of a given name as written in the object
+ /// \returns the \c ExecutorAddr of a given name as written in the object
/// file.
- llvm::Expected<llvm::JITTargetAddress>
+ llvm::Expected<llvm::orc::ExecutorAddr>
getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const;
};
} // namespace clang
diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp b/clang/lib/Interpreter/IncrementalExecutor.cpp
index d744270d486a1..fdf12dd214148 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -77,7 +77,7 @@ llvm::Error IncrementalExecutor::runCtors() const {
return Jit->initialize(Jit->getMainJITDylib());
}
-llvm::Expected<llvm::JITTargetAddress>
+llvm::Expected<llvm::orc::ExecutorAddr>
IncrementalExecutor::getSymbolAddress(llvm::StringRef Name,
SymbolNameKind NameKind) const {
auto Sym = (NameKind == LinkerName) ? Jit->lookupLinkerMangled(Name)
@@ -85,7 +85,7 @@ IncrementalExecutor::getSymbolAddress(llvm::StringRef Name,
if (!Sym)
return Sym.takeError();
- return Sym->getValue();
+ return Sym;
}
} // end namespace clang
diff --git a/clang/lib/Interpreter/IncrementalExecutor.h b/clang/lib/Interpreter/IncrementalExecutor.h
index f7922ecb53800..dd0a210a06141 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -16,6 +16,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
+#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
#include <memory>
@@ -51,7 +52,7 @@ class IncrementalExecutor {
llvm::Error removeModule(PartialTranslationUnit &PTU);
llvm::Error runCtors() const;
llvm::Error cleanUp();
- llvm::Expected<llvm::JITTargetAddress>
+ llvm::Expected<llvm::orc::ExecutorAddr>
getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
llvm::orc::LLJIT &GetExecutionEngine() { return *Jit; }
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index a0ccbc20b95f4..24fb9da69a8bc 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -246,7 +246,7 @@ llvm::Error Interpreter::Execute(PartialTranslationUnit &T) {
return llvm::Error::success();
}
-llvm::Expected<llvm::JITTargetAddress>
+llvm::Expected<llvm::orc::ExecutorAddr>
Interpreter::getSymbolAddress(GlobalDecl GD) const {
if (!IncrExecutor)
return llvm::make_error<llvm::StringError>("Operation failed. "
@@ -256,7 +256,7 @@ Interpreter::getSymbolAddress(GlobalDecl GD) const {
return getSymbolAddress(MangledName);
}
-llvm::Expected<llvm::JITTargetAddress>
+llvm::Expected<llvm::orc::ExecutorAddr>
Interpreter::getSymbolAddress(llvm::StringRef IRName) const {
if (!IncrExecutor)
return llvm::make_error<llvm::StringError>("Operation failed. "
@@ -266,7 +266,7 @@ Interpreter::getSymbolAddress(llvm::StringRef IRName) const {
return IncrExecutor->getSymbolAddress(IRName, IncrementalExecutor::IRName);
}
-llvm::Expected<llvm::JITTargetAddress>
+llvm::Expected<llvm::orc::ExecutorAddr>
Interpreter::getSymbolAddressFromLinkerName(llvm::StringRef Name) const {
if (!IncrExecutor)
return llvm::make_error<llvm::StringError>("Operation failed. "
diff --git a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
index 6983a532c7315..c82d11de20e0d 100644
--- a/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ b/clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -25,7 +25,6 @@
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/TargetSelect.h"
-#include "llvm-c/Error.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -116,7 +115,8 @@ extern "C" int throw_exception() {
llvm::cantFail(Interp->ParseAndExecute(ExceptionCode));
testing::internal::CaptureStdout();
auto ThrowException =
- (int (*)())llvm::cantFail(Interp->getSymbolAddress("throw_exception"));
+ llvm::cantFail(Interp->getSymbolAddress("throw_exception"))
+ .toPtr<int (*)()>();
EXPECT_ANY_THROW(ThrowException());
std::string CapturedStdOut = testing::internal::GetCapturedStdout();
EXPECT_EQ(CapturedStdOut, "Caught: 'To be caught in JIT'\n");
diff --git a/clang/unittests/Interpreter/InterpreterTest.cpp b/clang/unittests/Interpreter/InterpreterTest.cpp
index d4900a0e4de8f..d555911a89451 100644
--- a/clang/unittests/Interpreter/InterpreterTest.cpp
+++ b/clang/unittests/Interpreter/InterpreterTest.cpp
@@ -225,7 +225,7 @@ TEST(IncrementalProcessing, FindMangledNameSymbol) {
std::string MangledName = MangleName(FD);
auto Addr = cantFail(Interp->getSymbolAddress(MangledName));
- EXPECT_NE(0U, Addr);
+ EXPECT_NE(0U, Addr.getValue());
GlobalDecl GD(FD);
EXPECT_EQ(Addr, cantFail(Interp->getSymbolAddress(GD)));
}
@@ -309,7 +309,8 @@ TEST(IncrementalProcessing, InstantiateTemplate) {
std::string MangledName = MangleName(TmpltSpec);
typedef int (*TemplateSpecFn)(void *);
- auto fn = (TemplateSpecFn)cantFail(Interp->getSymbolAddress(MangledName));
+ auto fn =
+ cantFail(Interp->getSymbolAddress(MangledName)).toPtr<TemplateSpecFn>();
EXPECT_EQ(42, fn(NewA));
free(NewA);
}
More information about the cfe-commits
mailing list