[clang] [clang-repl] Factor out CreateJITBuilder() and allow specialization in derived classes (PR #84461)
Stefan Gränitz via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 03:27:51 PST 2024
================
@@ -373,21 +373,32 @@ Interpreter::Parse(llvm::StringRef Code) {
static llvm::Expected<llvm::orc::JITTargetMachineBuilder>
createJITTargetMachineBuilder(const std::string &TT) {
if (TT == llvm::sys::getProcessTriple())
+ // This fails immediately if the target backend is not registered
return llvm::orc::JITTargetMachineBuilder::detectHost();
- // FIXME: This can fail as well if the target is not registered! We just don't
- // catch it yet.
+
+ // If the target backend is not registered, LLJITBuilder::create() will fail
return llvm::orc::JITTargetMachineBuilder(llvm::Triple(TT));
}
+llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>>
+Interpreter::CreateJITBuilder(CompilerInstance &CI) {
+ auto JTMB = createJITTargetMachineBuilder(CI.getTargetOpts().Triple);
+ if (!JTMB)
+ return JTMB.takeError();
+ return IncrementalExecutor::createDefaultJITBuilder(std::move(*JTMB));
+}
+
llvm::Error Interpreter::CreateExecutor() {
- const clang::TargetInfo &TI =
- getCompilerInstance()->getASTContext().getTargetInfo();
if (IncrExecutor)
return llvm::make_error<llvm::StringError>("Operation failed. "
"Execution engine exists",
std::error_code());
+ llvm::Expected<std::unique_ptr<llvm::orc::LLJITBuilder>> JB =
+ CreateJITBuilder(*getCompilerInstance());
----------------
weliveindetail wrote:
We keep creating a new LLJITBuilder for each new IncrementalExecutor. This is questionable, but I didn't want to clutter the patch unnecessarily. I am happy to change that in a follow-up PR.
https://github.com/llvm/llvm-project/pull/84461
More information about the cfe-commits
mailing list