Author: Jonas Hahnfeld Date: 2022-06-30T21:25:14+02:00 New Revision: f22795de683d571bbf7e655a7b4ed5ccda186e66
URL: https://github.com/llvm/llvm-project/commit/f22795de683d571bbf7e655a7b4ed5ccda186e66 DIFF: https://github.com/llvm/llvm-project/commit/f22795de683d571bbf7e655a7b4ed5ccda186e66.diff LOG: [Interpreter] Pass target features to JIT This is required to support RISC-V where the '+d' target feature indicates the presence of the D instruction set extension, which changes to the Hard-float 'd' ABI. Differential Revision: https://reviews.llvm.org/D128853 Added: Modified: clang/lib/Interpreter/IncrementalExecutor.cpp clang/lib/Interpreter/IncrementalExecutor.h clang/lib/Interpreter/Interpreter.cpp Removed: ################################################################################ diff --git a/clang/lib/Interpreter/IncrementalExecutor.cpp b/clang/lib/Interpreter/IncrementalExecutor.cpp index c055827281b4f..227ab9703dc76 100644 --- a/clang/lib/Interpreter/IncrementalExecutor.cpp +++ b/clang/lib/Interpreter/IncrementalExecutor.cpp @@ -12,6 +12,8 @@ #include "IncrementalExecutor.h" +#include "clang/Basic/TargetInfo.h" +#include "clang/Basic/TargetOptions.h" #include "clang/Interpreter/PartialTranslationUnit.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" @@ -28,12 +30,13 @@ namespace clang { IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err, - const llvm::Triple &Triple) + const clang::TargetInfo &TI) : TSCtx(TSC) { using namespace llvm::orc; llvm::ErrorAsOutParameter EAO(&Err); - auto JTMB = JITTargetMachineBuilder(Triple); + auto JTMB = JITTargetMachineBuilder(TI.getTriple()); + JTMB.addFeatures(TI.getTargetOpts().Features); if (auto JitOrErr = LLJITBuilder().setJITTargetMachineBuilder(JTMB).create()) Jit = std::move(*JitOrErr); else { diff --git a/clang/lib/Interpreter/IncrementalExecutor.h b/clang/lib/Interpreter/IncrementalExecutor.h index 580724e1e24e2..f11ec0aa9e758 100644 --- a/clang/lib/Interpreter/IncrementalExecutor.h +++ b/clang/lib/Interpreter/IncrementalExecutor.h @@ -15,7 +15,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/Triple.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" #include <memory> @@ -32,6 +31,7 @@ class ThreadSafeContext; namespace clang { struct PartialTranslationUnit; +class TargetInfo; class IncrementalExecutor { using CtorDtorIterator = llvm::orc::CtorDtorIterator; @@ -45,7 +45,7 @@ class IncrementalExecutor { enum SymbolNameKind { IRName, LinkerName }; IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err, - const llvm::Triple &Triple); + const clang::TargetInfo &TI); ~IncrementalExecutor(); llvm::Error addModule(PartialTranslationUnit &PTU); diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index a10eb79b413b3..0191ad78581d9 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -213,10 +213,10 @@ Interpreter::Parse(llvm::StringRef Code) { llvm::Error Interpreter::Execute(PartialTranslationUnit &T) { assert(T.TheModule); if (!IncrExecutor) { - const llvm::Triple &Triple = - getCompilerInstance()->getASTContext().getTargetInfo().getTriple(); + const clang::TargetInfo &TI = + getCompilerInstance()->getASTContext().getTargetInfo(); llvm::Error Err = llvm::Error::success(); - IncrExecutor = std::make_unique<IncrementalExecutor>(*TSCtx, Err, Triple); + IncrExecutor = std::make_unique<IncrementalExecutor>(*TSCtx, Err, TI); if (Err) return Err; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits