diff --git a/torch/csrc/jit/tensorexpr/llvm_codegen.cpp b/torch/csrc/jit/tensorexpr/llvm_codegen.cpp index ed9f2f9abc669..91d9e1e89f3d9 100644 --- a/torch/csrc/jit/tensorexpr/llvm_codegen.cpp +++ b/torch/csrc/jit/tensorexpr/llvm_codegen.cpp @@ -739,7 +739,9 @@ void LLVMCodeGenImpl::emitKernel( PM, asmStream, nullptr, -#if LLVM_VERSION_MAJOR >= 10 +#if LLVM_VERSION_MAJOR >= 18 + llvm::CodeGenFileType::AssemblyFile); +#elif LLVM_VERSION_MAJOR >= 10 llvm::CodeGenFileType::CGFT_AssemblyFile); #else llvm::TargetMachine::CodeGenFileType::CGFT_AssemblyFile); diff --git a/torch/csrc/jit/tensorexpr/llvm_jit.cpp b/torch/csrc/jit/tensorexpr/llvm_jit.cpp index e2b887c76806f..846ddf8d26b91 100644 --- a/torch/csrc/jit/tensorexpr/llvm_jit.cpp +++ b/torch/csrc/jit/tensorexpr/llvm_jit.cpp @@ -101,7 +101,11 @@ static llvm::orc::JITTargetMachineBuilder makeTargetMachineBuilder( c10::optional attrs) { auto JTMB = triple ? makeJTMBFromTriple(*triple, cpu, attrs) : makeJTMBFromHost(cpu, attrs); +#if LLVM_VERSION_MAJOR >= 18 + JTMB.setCodeGenOptLevel(llvm::CodeGenOptLevel::Default); +#else JTMB.setCodeGenOptLevel(llvm::CodeGenOpt::Default); +#endif JTMB.getOptions().AllowFPOpFusion = llvm::FPOpFusion::Fast; return JTMB; }