Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jobs:
CTEST_TEST_TIMEOUT: ${{inputs.ctest_test_timeout}}
USE_SIMD: ${{inputs.simd}}
FMT_VERSION: ${{inputs.fmt_ver}}
fmt_BUILD_VERSION: ${{inputs.fmt_ver}}
OPENCOLORIO_VERSION: ${{inputs.opencolorio_ver}}
OPENEXR_VERSION: ${{inputs.openexr_ver}}
OPENIMAGEIO_VERSION: ${{inputs.openimageio_ver}}
Expand Down Expand Up @@ -134,7 +135,7 @@ jobs:
restore-keys: ${{inputs.nametag}}
- name: Install LLVM and Clang
if: inputs.llvm_action_ver != ''
uses: KyleMayes/install-llvm-action@a7a1a882e2d06ebe05d5bb97c3e1f8c984ae96fc # v2.0.7
uses: KyleMayes/install-llvm-action@98e68e10c96dffcb7bfed8b2144541a66b49aa02 # v2.0.8
with:
version: ${{ inputs.llvm_action_ver }}
- name: Dependencies
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,14 @@ jobs:
python_ver: "3.13"
aclang: 15
setenvs: export LLVMBREWVER="@19"
- desc: MacOS-15-ARM aclang16/C++17/py3.13 llvm19 oiio-main
- desc: MacOS-15-ARM aclang16/C++17/py3.13 llvm21 oiio-main
runner: macos-15
nametag: macos15-arm-py313
cc_compiler: clang
cxx_compiler: clang++
cxx_std: 17
python_ver: "3.13"
openimageio_ver: main
setenvs: export LLVMBREWVER="@19"


windows:
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ NEW or CHANGED minimum dependencies since the last major release are **bold**.
$OpenImageIO_ROOT/lib to be in your LD_LIBRARY_PATH (or
DYLD_LIBRARY_PATH on OS X).

* [LLVM](http://www.llvm.org) **14.0 or newer**, 15, 16, 17, 18, 19, 20,
* [LLVM](http://www.llvm.org) **14.0 or newer**, 15, 16, 17, 18, 19, 20, 21,
including clang libraries.

* (optional) For GPU rendering on NVIDIA GPUs:
Expand Down
2 changes: 1 addition & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ checked_find_package (pugixml REQUIRED
# LLVM library setup
checked_find_package (LLVM REQUIRED
VERSION_MIN 14.0
VERSION_MAX 20.9
VERSION_MAX 21.9
PRINT LLVM_SYSTEM_LIBRARIES CLANG_LIBRARIES
LLVM_SHARED_MODE)
# ensure include directory is added (in case of non-standard locations
Expand Down
13 changes: 13 additions & 0 deletions src/liboslcomp/oslcomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,32 @@ OSLCompilerImpl::preprocess_buffer(const std::string& buffer,
llvm::raw_string_ostream errstream(preproc_errors);
clang::DiagnosticOptions* diagOptions = new clang::DiagnosticOptions();
clang::TextDiagnosticPrinter* diagPrinter
#if OSL_LLVM_VERSION < 210
= new clang::TextDiagnosticPrinter(errstream, diagOptions);
#else
= new clang::TextDiagnosticPrinter(errstream, *diagOptions);
#endif
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagIDs(
new clang::DiagnosticIDs);
clang::DiagnosticsEngine* diagEngine
#if OSL_LLVM_VERSION < 210
= new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter);
#else
= new clang::DiagnosticsEngine(diagIDs, *diagOptions, diagPrinter);
#endif
inst.setDiagnostics(diagEngine);

const std::shared_ptr<clang::TargetOptions> targetopts
= std::make_shared<clang::TargetOptions>(inst.getTargetOpts());
targetopts->Triple = llvm::sys::getDefaultTargetTriple();
clang::TargetInfo* target
#if OSL_LLVM_VERSION < 210
= clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(),
targetopts);
#else
= clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(),
*targetopts);
#endif

inst.setTarget(target);

Expand Down
4 changes: 4 additions & 0 deletions src/liboslexec/llvm_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,11 @@ BackendLLVM::run()
// The triple is empty with recent versions of LLVM (e.g., 15) for reasons that aren't
// clear. So we must set them to the expected values.
// See: https://llvm.org/docs/NVPTXUsage.html
# if OSL_LLVM_VERSION < 210
ll.module()->setTargetTriple("nvptx64-nvidia-cuda");
# else
ll.module()->setTargetTriple(llvm::Triple("nvptx64-nvidia-cuda"));
# endif
ll.module()->setDataLayout(
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-i128:128:128-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64");

Expand Down
101 changes: 74 additions & 27 deletions src/liboslexec/llvm_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,27 +476,13 @@ LLVM_Util::LLVM_Util(const PerThreadInfo& per_thread_info, int debuglevel,
m_llvm_type_longlong = (llvm::Type*)llvm::Type::getInt64Ty(*m_llvm_context);
m_llvm_type_void = (llvm::Type*)llvm::Type::getVoidTy(*m_llvm_context);

m_llvm_type_int_ptr = llvm::PointerType::get(m_llvm_type_int, 0);
m_llvm_type_int8_ptr = llvm::PointerType::get(m_llvm_type_int8, 0);
m_llvm_type_int64_ptr = llvm::PointerType::get(m_llvm_type_int64, 0);
m_llvm_type_bool_ptr = llvm::PointerType::get(m_llvm_type_bool, 0);
m_llvm_type_char_ptr = llvm::PointerType::get(m_llvm_type_char, 0);
m_llvm_type_void_ptr = m_llvm_type_char_ptr;
m_llvm_type_float_ptr = llvm::PointerType::get(m_llvm_type_float, 0);
m_llvm_type_longlong_ptr = llvm::PointerType::get(m_llvm_type_int64, 0);
m_llvm_type_double_ptr = llvm::PointerType::get(m_llvm_type_double, 0);

// A triple is a struct composed of 3 floats
std::vector<llvm::Type*> triplefields(3, m_llvm_type_float);
m_llvm_type_triple = type_struct(triplefields, "Vec3");
m_llvm_type_triple_ptr
= (llvm::PointerType*)llvm::PointerType::get(m_llvm_type_triple, 0);

// A matrix is a struct composed 16 floats
std::vector<llvm::Type*> matrixfields(16, m_llvm_type_float);
m_llvm_type_matrix = type_struct(matrixfields, "Matrix4");
m_llvm_type_matrix_ptr
= (llvm::PointerType*)llvm::PointerType::get(m_llvm_type_matrix, 0);

// Setup up wide aliases
// TODO: why are there casts to the base class llvm::Type *?
Expand All @@ -511,6 +497,48 @@ LLVM_Util::LLVM_Util(const PerThreadInfo& per_thread_info, int debuglevel,
m_llvm_type_wide_longlong = llvm_vector_type(m_llvm_type_longlong,
m_vector_width);

// A twide riple is a struct composed of 3 wide floats
std::vector<llvm::Type*> triple_wide_fields(3, m_llvm_type_wide_float);
m_llvm_type_wide_triple = type_struct(triple_wide_fields, "WideVec3");

// A wide matrix is a struct composed 16 wide floats
std::vector<llvm::Type*> matrix_wide_fields(16, m_llvm_type_wide_float);
m_llvm_type_wide_matrix = type_struct(matrix_wide_fields, "WideMatrix4");

#if OSL_LLVM_VERSION >= 210
// All opaque pointers now. Eventually, all the typed ones can go away.
m_llvm_type_void_ptr = llvm::PointerType::get(*m_llvm_context, 0);
m_llvm_type_int_ptr = m_llvm_type_void_ptr;
m_llvm_type_int8_ptr = m_llvm_type_void_ptr;
m_llvm_type_int64_ptr = m_llvm_type_void_ptr;
m_llvm_type_bool_ptr = m_llvm_type_void_ptr;
m_llvm_type_char_ptr = m_llvm_type_void_ptr;
m_llvm_type_float_ptr = m_llvm_type_void_ptr;
m_llvm_type_longlong_ptr = m_llvm_type_void_ptr;
m_llvm_type_double_ptr = m_llvm_type_void_ptr;
m_llvm_type_triple_ptr = m_llvm_type_void_ptr;
m_llvm_type_matrix_ptr = m_llvm_type_void_ptr;
m_llvm_type_wide_char_ptr = m_llvm_type_void_ptr;
m_llvm_type_wide_void_ptr = m_llvm_type_void_ptr;
m_llvm_type_wide_int_ptr = m_llvm_type_void_ptr;
m_llvm_type_wide_bool_ptr = m_llvm_type_void_ptr;
m_llvm_type_wide_float_ptr = m_llvm_type_void_ptr;
#else
// Old style typed pointers. These are marked as deprecated in LLVM 21,
// and will be removed in some subsequent version.
m_llvm_type_int_ptr = llvm::PointerType::get(m_llvm_type_int, 0);
m_llvm_type_int8_ptr = llvm::PointerType::get(m_llvm_type_int8, 0);
m_llvm_type_int64_ptr = llvm::PointerType::get(m_llvm_type_int64, 0);
m_llvm_type_bool_ptr = llvm::PointerType::get(m_llvm_type_bool, 0);
m_llvm_type_char_ptr = llvm::PointerType::get(m_llvm_type_char, 0);
m_llvm_type_void_ptr = m_llvm_type_char_ptr;
m_llvm_type_float_ptr = llvm::PointerType::get(m_llvm_type_float, 0);
m_llvm_type_longlong_ptr = llvm::PointerType::get(m_llvm_type_int64, 0);
m_llvm_type_double_ptr = llvm::PointerType::get(m_llvm_type_double, 0);
m_llvm_type_triple_ptr
= (llvm::PointerType*)llvm::PointerType::get(m_llvm_type_triple, 0);
m_llvm_type_matrix_ptr
= (llvm::PointerType*)llvm::PointerType::get(m_llvm_type_matrix, 0);
m_llvm_type_wide_char_ptr = llvm::PointerType::get(m_llvm_type_wide_char,
0);
m_llvm_type_wide_void_ptr = llvm_vector_type(m_llvm_type_void_ptr,
Expand All @@ -520,14 +548,7 @@ LLVM_Util::LLVM_Util(const PerThreadInfo& per_thread_info, int debuglevel,
0);
m_llvm_type_wide_float_ptr = llvm::PointerType::get(m_llvm_type_wide_float,
0);

// A triple is a struct composed of 3 floats
std::vector<llvm::Type*> triple_wide_fields(3, m_llvm_type_wide_float);
m_llvm_type_wide_triple = type_struct(triple_wide_fields, "WideVec3");

// A matrix is a struct composed 16 floats
std::vector<llvm::Type*> matrix_wide_fields(16, m_llvm_type_wide_float);
m_llvm_type_wide_matrix = type_struct(matrix_wide_fields, "WideMatrix4");
#endif

ustring_rep(m_ustring_rep); // setup ustring-related types
}
Expand All @@ -545,14 +566,20 @@ LLVM_Util::ustring_rep(UstringRep rep)
OSL_ASSERT(m_ustring_rep == UstringRep::hash);
m_llvm_type_ustring = llvm::Type::getInt64Ty(*m_llvm_context);
}
m_llvm_type_ustring_ptr = llvm::PointerType::get(m_llvm_type_ustring, 0);

// Batched versions haven't been updated to handle hash yet.
// For now leave them using the real ustring regardless of UstringRep
m_llvm_type_wide_ustring = llvm_vector_type(m_llvm_type_real_ustring,
m_vector_width);

#if OSL_LLVM_VERSION >= 210
m_llvm_type_ustring_ptr = m_llvm_type_void_ptr;
m_llvm_type_wide_ustring_ptr = m_llvm_type_void_ptr;
#else
m_llvm_type_ustring_ptr = llvm::PointerType::get(m_llvm_type_ustring, 0);
m_llvm_type_wide_ustring_ptr
= llvm::PointerType::get(m_llvm_type_wide_ustring, 0);
#endif
}


Expand Down Expand Up @@ -1790,8 +1817,13 @@ LLVM_Util::nvptx_target_machine()
&& "PTX compile error: LLVM Target is not initialized");

m_nvptx_target_machine = llvm_target->createTargetMachine(
ModuleTriple.str(), CUDA_TARGET_ARCH, "+ptx50", options,
llvm::Reloc::Static, llvm::CodeModel::Small,
#if OSL_LLVM_VERSION >= 210
llvm::Triple(ModuleTriple.str()),
#else
ModuleTriple.str(),
#endif
CUDA_TARGET_ARCH, "+ptx50", options, llvm::Reloc::Static,
llvm::CodeModel::Small,
#if OSL_LLVM_VERSION >= 180
llvm::CodeGenOptLevel::Default
#else
Expand Down Expand Up @@ -2911,7 +2943,11 @@ LLVM_Util::type_struct_field_at_index(llvm::Type* type, int index)
llvm::PointerType*
LLVM_Util::type_ptr(llvm::Type* type)
{
#if OSL_LLVM_VERSION >= 210
return m_llvm_type_void_ptr;
#else
return llvm::PointerType::get(type, 0);
#endif
}

llvm::Type*
Expand Down Expand Up @@ -2959,8 +2995,12 @@ llvm::PointerType*
LLVM_Util::type_function_ptr(llvm::Type* rettype, cspan<llvm::Type*> params,
bool varargs)
{
#if OSL_LLVM_VERSION >= 210
return m_llvm_type_void_ptr;
#else
llvm::FunctionType* functype = type_function(rettype, params, varargs);
return llvm::PointerType::getUnqual(functype);
#endif
}


Expand Down Expand Up @@ -3784,8 +3824,7 @@ llvm::Value*
LLVM_Util::ptr_to_cast(llvm::Value* val, llvm::Type* type,
const std::string& llname)
{
return builder().CreatePointerCast(val, llvm::PointerType::get(type, 0),
llname);
return builder().CreatePointerCast(val, type_ptr(type), llname);
}


Expand All @@ -3803,14 +3842,22 @@ llvm::Value*
LLVM_Util::ptr_cast(llvm::Value* val, const TypeDesc& type,
const std::string& llname)
{
#if OSL_LLVM_VERSION >= 210
return ptr_cast(val, m_llvm_type_void_ptr, llname);
#else
return ptr_cast(val, llvm::PointerType::get(llvm_type(type), 0), llname);
#endif
}


llvm::Value*
LLVM_Util::wide_ptr_cast(llvm::Value* val, const TypeDesc& type)
{
#if OSL_LLVM_VERSION >= 210
return ptr_cast(val, m_llvm_type_void_ptr);
#else
return ptr_cast(val, llvm::PointerType::get(llvm_vector_type(type), 0));
#endif
}


Expand Down
Loading