Skip to content

Commit

Permalink
Added better error checking for module_from_bitcode().
Browse files Browse the repository at this point in the history
Signed-off-by: Steena Monteiro <[email protected]>
  • Loading branch information
steenax86 committed May 3, 2022
1 parent f3198b3 commit c0ee2dd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/liboslexec/llvm_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1336,17 +1336,16 @@ BackendLLVM::run ()
osl_llvm_compiled_rs_dependant_ops_size,
"llvm_rs_dependant_ops", &err));
if (err.length())
shadingcontext()->errorf("ParseBitcodeFile returned '%s'\n", err);

shadingcontext()->errorf("llvm::parseBitcodeFile returned '%s' for llvm_rs_dependant_ops\n", err);

std::vector<char>& rs_free_function_bitcode = shadingsys().m_rs_bitcode;
OSL_ASSERT (rs_free_function_bitcode.size() && "Free Function bitcode is empty");

llvm::Module* rs_free_functions_module =
ll.module_from_bitcode (static_cast<const char*>(rs_free_function_bitcode.data()),
rs_free_function_bitcode.size(), "rs_free_functions");
ll.module_from_bitcode (static_cast<const char*>(rs_free_function_bitcode.data()),
rs_free_function_bitcode.size(), "rs_free_functions", &err);
if (err.length())
shadingcontext()->errorf("ParseBitcodeFile returned '%s'\n", err);
shadingcontext()->errorf("llvm::parseBitcodeFile returned '%s' for rs_free_functions\n", err);

std::unique_ptr<llvm::Module> rs_free_functions_module_ptr (rs_free_functions_module);
bool success = ll.absorb_module(std::move(rs_free_functions_module_ptr));
Expand All @@ -1356,19 +1355,21 @@ BackendLLVM::run ()
ll.module (ll.module_from_bitcode ((char*)osl_llvm_compiled_ops_block,
osl_llvm_compiled_ops_size,
"llvm_ops", &err));
if (err.length())
shadingcontext()->errorf("llvm::parseBitcodeFile returned '%s' for llvm_ops\n", err);
}

} else {
#ifdef OSL_LLVM_CUDA_BITCODE
ll.module (ll.module_from_bitcode ((char*)osl_llvm_compiled_ops_cuda_block,
osl_llvm_compiled_ops_cuda_size,
"llvm_ops", &err));
if (err.length())
shadingcontext()->errorf("llvm::parseBitcodeFile returned '%s' for cuda llvm_ops\n", err);
#else
OSL_ASSERT (0 && "Must generate LLVM CUDA bitcode for OptiX");
#endif
}
if (err.length())
shadingcontext()->errorf("ParseBitcodeFile returned '%s'\n", err);
OSL_ASSERT (ll.module());
#endif

Expand Down

0 comments on commit c0ee2dd

Please sign in to comment.