gallivm: Handle nir_instr_debug_info
Emits llvm source locations using the nir line numbers provided by nir_instr_debug_info. Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28613>
This commit is contained in:
committed by
Marge Bot
parent
d6ca378f1b
commit
77e84aba5c
@@ -1683,6 +1683,11 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
|
||||
builder = gallivm->builder;
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
memset(&vs_type, 0, sizeof vs_type);
|
||||
vs_type.floating = true; /* floating point values */
|
||||
vs_type.sign = true; /* values are signed */
|
||||
@@ -2413,6 +2418,11 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
|
||||
builder = gallivm->builder;
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
lp_build_context_init(&bld, gallivm, lp_type_int(32));
|
||||
|
||||
memset(&gs_type, 0, sizeof gs_type);
|
||||
@@ -2963,7 +2973,6 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
|
||||
}
|
||||
|
||||
lp_function_add_debug_info(gallivm, variant_func, func_type);
|
||||
lp_function_add_debug_info(gallivm, variant_coro, coro_func_type);
|
||||
|
||||
if (gallivm->cache && gallivm->cache->data_size) {
|
||||
gallivm_stub_func(gallivm, variant_func);
|
||||
@@ -2989,6 +2998,11 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
|
||||
builder = gallivm->builder;
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
lp_build_context_init(&bld, gallivm, lp_type_int(32));
|
||||
|
||||
memset(&tcs_type, 0, sizeof tcs_type);
|
||||
@@ -3056,9 +3070,16 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
|
||||
NULL, LLVMIntEQ);
|
||||
LLVMBuildRet(builder, lp_build_zero(gallivm, lp_type_uint(32)));
|
||||
|
||||
lp_function_add_debug_info(gallivm, variant_coro, coro_func_type);
|
||||
|
||||
block = LLVMAppendBasicBlockInContext(gallivm->context, variant_coro, "entry");
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
resources_ptr = LLVMGetParam(variant_coro, 0);
|
||||
input_array = LLVMGetParam(variant_coro, 1);
|
||||
output_array = LLVMGetParam(variant_coro, 2);
|
||||
@@ -3568,6 +3589,11 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
|
||||
builder = gallivm->builder;
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
lp_build_context_init(&bld, gallivm, lp_type_int(32));
|
||||
|
||||
memset(&tes_type, 0, sizeof tes_type);
|
||||
|
||||
@@ -5547,10 +5547,19 @@ visit_call(struct lp_build_nir_soa_context *bld,
|
||||
static void
|
||||
visit_block(struct lp_build_nir_soa_context *bld, nir_block *block)
|
||||
{
|
||||
struct gallivm_state *gallivm = bld->base.gallivm;
|
||||
|
||||
nir_foreach_instr(instr, block)
|
||||
{
|
||||
bld->instr = instr;
|
||||
|
||||
if (gallivm->di_builder && gallivm->file_name && instr->has_debug_info) {
|
||||
nir_instr_debug_info *debug_info = nir_instr_get_debug_info(instr);
|
||||
LLVMMetadataRef di_loc = LLVMDIBuilderCreateDebugLocation(
|
||||
gallivm->context, debug_info->nir_line, 1, gallivm->di_function, NULL);
|
||||
LLVMSetCurrentDebugLocation2(gallivm->builder, di_loc);
|
||||
}
|
||||
|
||||
switch (instr->type) {
|
||||
case nir_instr_type_alu:
|
||||
visit_alu(bld, nir_instr_as_alu(instr));
|
||||
@@ -5936,6 +5945,19 @@ void lp_build_nir_soa_func(struct gallivm_state *gallivm,
|
||||
_mesa_key_pointer_equal);
|
||||
bld.range_ht = _mesa_pointer_hash_table_create(NULL);
|
||||
|
||||
nir_index_ssa_defs(impl);
|
||||
|
||||
if (bld.base.gallivm->di_builder && bld.base.gallivm->file_name && shader->has_debug_info) {
|
||||
char *shader_src = nir_shader_gather_debug_info(shader, bld.base.gallivm->file_name, 1);
|
||||
if (shader_src) {
|
||||
FILE *f = fopen(bld.base.gallivm->file_name, "w");
|
||||
fprintf(f, "%s\n", shader_src);
|
||||
fclose(f);
|
||||
|
||||
ralloc_free(shader_src);
|
||||
}
|
||||
}
|
||||
|
||||
nir_foreach_reg_decl(reg, impl) {
|
||||
LLVMTypeRef type = get_register_type(&bld, reg);
|
||||
LLVMValueRef reg_alloc = lp_build_alloca(bld.base.gallivm,
|
||||
@@ -5943,7 +5965,6 @@ void lp_build_nir_soa_func(struct gallivm_state *gallivm,
|
||||
_mesa_hash_table_insert(bld.regs, reg, reg_alloc);
|
||||
}
|
||||
|
||||
nir_index_ssa_defs(impl);
|
||||
nir_divergence_analysis_impl(impl, impl->function->shader->options->divergence_analysis_options);
|
||||
bld.ssa_defs = calloc(impl->ssa_alloc * NIR_MAX_VEC_COMPONENTS * 2, sizeof(LLVMValueRef));
|
||||
visit_cf_list(&bld, &impl->body);
|
||||
|
||||
@@ -580,6 +580,11 @@ generate_compute(struct llvmpipe_context *lp,
|
||||
assert(builder);
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
if (is_mesh) {
|
||||
LLVMTypeRef output_type = create_mesh_jit_output_type_deref(gallivm);
|
||||
output_array = lp_build_array_alloca(gallivm, output_type, lp_build_const_int32(gallivm, align(MAX2(nir->info.mesh.max_primitives_out, nir->info.mesh.max_vertices_out), 8)), "outputs");
|
||||
@@ -712,6 +717,11 @@ generate_compute(struct llvmpipe_context *lp,
|
||||
builder = gallivm->builder;
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
struct lp_build_loop_state loop_state;
|
||||
|
||||
if (!use_coro) {
|
||||
|
||||
@@ -3320,6 +3320,11 @@ generate_fragment(struct llvmpipe_context *lp,
|
||||
assert(builder);
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
/* code generated texture sampling */
|
||||
struct lp_build_sampler_soa *sampler =
|
||||
lp_llvm_sampler_soa_create(lp_fs_variant_key_samplers(key),
|
||||
|
||||
@@ -328,6 +328,11 @@ llvmpipe_fs_variant_linear_llvm(struct llvmpipe_context *lp,
|
||||
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if (gallivm->di_function) {
|
||||
LLVMSetCurrentDebugLocation2(
|
||||
gallivm->builder, LLVMDIBuilderCreateDebugLocation(gallivm->context, 0, 0, gallivm->di_function, NULL));
|
||||
}
|
||||
|
||||
struct lp_build_context bld;
|
||||
lp_build_context_init(&bld, gallivm, fs_type);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user