@@ -1543,7 +1543,11 @@ LLVM_Util::make_jit_execengine(std::string* err, TargetISA requestedISA,
15431543 // TODO: investigate if reciprocals can be disabled by other means.
15441544 // Perhaps enable UnsafeFPMath, then modify creation of DIV instructions
15451545 // to remove the arcp (allow reciprocal) flag on that instructions
1546+ #if OSL_LLVM_VERSION < 220
1547+ // UnsafeFPMath was removed from TargetOptions in LLVM 22; FP math
1548+ // control is now handled via per-instruction fast-math flags in IR.
15461549 options.UnsafeFPMath = false ;
1550+ #endif
15471551 // Since there are OSL language functions isinf and isnan,
15481552 // we cannot assume there will not be infs and NANs
15491553 options.NoInfsFPMath = false ;
@@ -1805,7 +1809,11 @@ LLVM_Util::nvptx_target_machine()
18051809 // N.B. 'Standard' only allow fusion of 'blessed' ops (currently just
18061810 // fmuladd). To truly disable FMA and never fuse FP-ops, we need to
18071811 // instead use llvm::FPOpFusion::Strict.
1808- options.UnsafeFPMath = 1 ;
1812+ #if OSL_LLVM_VERSION < 220
1813+ // UnsafeFPMath was removed from TargetOptions in LLVM 22; FP math
1814+ // control is now handled via per-instruction fast-math flags in IR.
1815+ options.UnsafeFPMath = 1 ;
1816+ #endif
18091817 options.NoInfsFPMath = 1 ;
18101818 options.NoNaNsFPMath = 1 ;
18111819 options.HonorSignDependentRoundingFPMathOption = 0 ;
@@ -1817,8 +1825,13 @@ LLVM_Util::nvptx_target_machine()
18171825
18181826 // Verify that the NVPTX target has been initialized
18191827 std::string error;
1828+ #if OSL_LLVM_VERSION >= 220
1829+ const llvm::Target* llvm_target
1830+ = llvm::TargetRegistry::lookupTarget (ModuleTriple, error);
1831+ #else
18201832 const llvm::Target* llvm_target
18211833 = llvm::TargetRegistry::lookupTarget (ModuleTriple.str (), error);
1834+ #endif
18221835 OSL_ASSERT (llvm_target
18231836 && " PTX compile error: LLVM Target is not initialized" );
18241837
0 commit comments