diff options
author | Francisco Jerez <[email protected]> | 2016-06-19 14:31:59 -0700 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2016-07-11 20:34:34 -0700 |
commit | 4ef1c0918da4363aa20b7c1a91d344fae6c01942 (patch) | |
tree | fa5d65f8d020464691d4c512aa9627a6abe51c21 /src/gallium/state_trackers/clover | |
parent | 70fe6267a37dfc97ef8b6dd22a0431fcfc293d2a (diff) |
clover: Move back to using build_error to signal compilation failure.
This partially reverts 7e0180d57d330bd8d3047e841086712376b2a1cc.
Having two different exception subclasses for compilation and linking
makes it more difficult to share or move code between the two
codepaths, because the exact same function under the same error
condition would need to throw one exception or the other depending on
what top-level API is being implemented with it. There is little
benefit anyway because clCompileProgram() and clLinkProgram() can tell
whether they are linking or compiling a program.
Reviewed-by: Serge Martin <[email protected]>
Tested-by: Jan Vesely <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover')
5 files changed, 17 insertions, 17 deletions
diff --git a/src/gallium/state_trackers/clover/api/program.cpp b/src/gallium/state_trackers/clover/api/program.cpp index 27ca2efd0bc..ff199abe5c0 100644 --- a/src/gallium/state_trackers/clover/api/program.cpp +++ b/src/gallium/state_trackers/clover/api/program.cpp @@ -186,8 +186,6 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs, } catch (error &e) { if (e.get() == CL_INVALID_COMPILER_OPTIONS) return CL_INVALID_BUILD_OPTIONS; - if (e.get() == CL_COMPILE_PROGRAM_FAILURE) - return CL_BUILD_PROGRAM_FAILURE; return e.get(); } @@ -227,6 +225,9 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs, prog.build(devs, opts, headers); return CL_SUCCESS; +} catch (build_error &e) { + return CL_COMPILE_PROGRAM_FAILURE; + } catch (error &e) { return e.get(); } diff --git a/src/gallium/state_trackers/clover/core/error.hpp b/src/gallium/state_trackers/clover/core/error.hpp index 59a5af4c799..3165402d7e3 100644 --- a/src/gallium/state_trackers/clover/core/error.hpp +++ b/src/gallium/state_trackers/clover/core/error.hpp @@ -65,11 +65,10 @@ namespace clover { cl_int code; }; - class compile_error : public error { + class build_error : public error { public: - compile_error(const std::string &what = "") : - error(CL_COMPILE_PROGRAM_FAILURE, what) { - } + build_error(const std::string &what = "") : + error(CL_BUILD_PROGRAM_FAILURE, what) {} }; template<typename O> diff --git a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp index 4adb05f5633..b96236b0897 100644 --- a/src/gallium/state_trackers/clover/llvm/codegen/native.cpp +++ b/src/gallium/state_trackers/clover/llvm/codegen/native.cpp @@ -98,7 +98,7 @@ namespace { const auto elf = elf::get(code); const auto symtab = elf::get_symbol_table(elf.get()); if (!symtab) - fail(r_log, compile_error(), "Unable to find symbol table."); + fail(r_log, build_error(), "Unable to find symbol table."); return elf::get_symbol_offsets(elf.get(), symtab); } @@ -110,7 +110,7 @@ namespace { std::string err; auto t = ::llvm::TargetRegistry::lookupTarget(target.triple, err); if (!t) - fail(r_log, compile_error(), err); + fail(r_log, build_error(), err); std::unique_ptr<TargetMachine> tm { t->createTargetMachine(target.triple, target.cpu, "", {}, @@ -118,7 +118,7 @@ namespace { ::llvm::CodeModel::Default, ::llvm::CodeGenOpt::Default) }; if (!tm) - fail(r_log, compile_error(), + fail(r_log, build_error(), "Could not create TargetMachine: " + target.triple); ::llvm::SmallVector<char, 1024> data; @@ -133,7 +133,7 @@ namespace { (ft == TargetMachine::CGFT_AssemblyFile); if (tm->addPassesToEmitFile(pm, fos, ft)) - fail(r_log, compile_error(), "TargetMachine can't emit this file"); + fail(r_log, build_error(), "TargetMachine can't emit this file"); pm.run(mod); } diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index 40b00b7ef13..db3b48176b0 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -70,7 +70,7 @@ namespace { raw_string_ostream os { *reinterpret_cast<std::string *>(data) }; ::llvm::DiagnosticPrinterRawOStream printer { os }; di.print(printer); - throw compile_error(); + throw build_error(); } } @@ -173,7 +173,7 @@ namespace { // Compile the code clang::EmitLLVMOnlyAction act(&ctx); if (!c.ExecuteAction(act)) - throw compile_error(); + throw build_error(); return act.takeModule(); } @@ -241,7 +241,7 @@ namespace { for (auto &m : modules) { if (compat::link_in_module(*linker, parse_module_library(m, ctx, r_log))) - throw compile_error(); + throw build_error(); } return std::move(mod); diff --git a/src/gallium/state_trackers/clover/tgsi/compiler.cpp b/src/gallium/state_trackers/clover/tgsi/compiler.cpp index e385a079898..9bbd4541e9b 100644 --- a/src/gallium/state_trackers/clover/tgsi/compiler.cpp +++ b/src/gallium/state_trackers/clover/tgsi/compiler.cpp @@ -48,7 +48,7 @@ namespace { if (!(ts >> offset)) { r_log = "invalid kernel start address"; - throw compile_error(); + throw build_error(); } while (ts >> tok) { @@ -72,7 +72,7 @@ namespace { args.push_back({ module::argument::sampler, 0 }); else { r_log = "invalid kernel argument"; - throw compile_error(); + throw build_error(); } } @@ -86,7 +86,7 @@ namespace { if (!tgsi_text_translate(source, prog, ARRAY_SIZE(prog))) { r_log = "translate failed"; - throw compile_error(); + throw build_error(); } unsigned sz = tgsi_num_tokens(prog) * sizeof(tgsi_token); @@ -100,7 +100,7 @@ clover::tgsi::compile_program(const std::string &source, std::string &r_log) { const size_t body_pos = source.find("COMP\n"); if (body_pos == std::string::npos) { r_log = "invalid source"; - throw compile_error(); + throw build_error(); } const char *body = &source[body_pos]; |