Skip to content

Commit 8eff393

Browse files
modikingjeffdaily
authored andcommitted
Update caffe2 with LLVM-18 API change (pytorch#109408)
Summary: llvm/llvm-project#66295 modified some internal LLVM APIs, update these places with the changes under LLVM version guard Test Plan: CI Differential Revision: D49340871 Pull Request resolved: pytorch#109408 Approved by: https://github.com/Skylion007
1 parent c77ddb8 commit 8eff393

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

torch/csrc/jit/tensorexpr/llvm_codegen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,9 @@ void LLVMCodeGenImpl::emitKernel(
739739
PM,
740740
asmStream,
741741
nullptr,
742-
#if LLVM_VERSION_MAJOR >= 10
742+
#if LLVM_VERSION_MAJOR >= 18
743+
llvm::CodeGenFileType::AssemblyFile);
744+
#elif LLVM_VERSION_MAJOR >= 10
743745
llvm::CodeGenFileType::CGFT_AssemblyFile);
744746
#else
745747
llvm::TargetMachine::CodeGenFileType::CGFT_AssemblyFile);

torch/csrc/jit/tensorexpr/llvm_jit.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ static llvm::orc::JITTargetMachineBuilder makeTargetMachineBuilder(
101101
c10::optional<std::string> attrs) {
102102
auto JTMB = triple ? makeJTMBFromTriple(*triple, cpu, attrs)
103103
: makeJTMBFromHost(cpu, attrs);
104+
#if LLVM_VERSION_MAJOR >= 18
105+
JTMB.setCodeGenOptLevel(llvm::CodeGenOptLevel::Default);
106+
#else
104107
JTMB.setCodeGenOptLevel(llvm::CodeGenOpt::Default);
108+
#endif
105109
JTMB.getOptions().AllowFPOpFusion = llvm::FPOpFusion::Fast;
106110
return JTMB;
107111
}

0 commit comments

Comments
 (0)