mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
clc: add dump_llvm debug options
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26524>
This commit is contained in:
parent
d9d398e652
commit
65de9bc81a
4 changed files with 25 additions and 2 deletions
|
|
@ -1063,6 +1063,7 @@ clc environment variables
|
|||
|
||||
a comma-separated list of debug channels to enable.
|
||||
|
||||
- ``dump_llvm`` Dumps all generated LLVM IRs
|
||||
- ``dump_spirv`` Dumps all compiled, linked and specialized SPIR-Vs
|
||||
- ``verbose`` Enable debug logging of clc code
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
static const struct debug_named_value clc_debug_options[] = {
|
||||
{ "dump_spirv", CLC_DEBUG_DUMP_SPIRV, "Dump spirv blobs" },
|
||||
{ "dump_llvm", CLC_DEBUG_DUMP_LLVM, "Dump LLVM blobs" },
|
||||
{ "verbose", CLC_DEBUG_VERBOSE, NULL },
|
||||
DEBUG_NAMED_VALUE_END
|
||||
};
|
||||
|
|
|
|||
|
|
@ -269,7 +269,8 @@ clc_specialize_spirv(const struct clc_binary *in_spirv,
|
|||
|
||||
enum clc_debug_flags {
|
||||
CLC_DEBUG_DUMP_SPIRV = 1 << 0,
|
||||
CLC_DEBUG_VERBOSE = 1 << 1,
|
||||
CLC_DEBUG_DUMP_LLVM = 1 << 1,
|
||||
CLC_DEBUG_VERBOSE = 1 << 2,
|
||||
};
|
||||
uint64_t clc_debug_flags(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ using ::llvm::Module;
|
|||
using ::llvm::raw_string_ostream;
|
||||
using ::clang::driver::Driver;
|
||||
|
||||
static void
|
||||
clc_dump_llvm(const llvm::Module *mod, FILE *f);
|
||||
|
||||
static void
|
||||
llvm_log_handler(const ::llvm::DiagnosticInfo &di, void *data) {
|
||||
const clc_logger *logger = static_cast<clc_logger *>(data);
|
||||
|
|
@ -968,7 +971,12 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
|
|||
return {};
|
||||
}
|
||||
|
||||
return act.takeModule();
|
||||
auto mod = act.takeModule();
|
||||
|
||||
if (clc_debug_flags() & CLC_DEBUG_DUMP_LLVM)
|
||||
clc_dump_llvm(mod.get(), stdout);
|
||||
|
||||
return mod;
|
||||
}
|
||||
|
||||
static SPIRV::VersionNumber
|
||||
|
|
@ -1252,6 +1260,18 @@ clc_spirv_specialize(const struct clc_binary *in_spirv,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
clc_dump_llvm(const llvm::Module *mod, FILE *f)
|
||||
{
|
||||
std::string out;
|
||||
raw_string_ostream os(out);
|
||||
|
||||
mod->print(os, nullptr);
|
||||
os.flush();
|
||||
|
||||
fwrite(out.c_str(), out.size(), 1, f);
|
||||
}
|
||||
|
||||
void
|
||||
clc_dump_spirv(const struct clc_binary *spvbin, FILE *f)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue