[Mesa-dev] [PATCH 11/19] gallium/radeon: more descriptive names for LLVM temporaries in debug builds

Tom Stellard tom at stellard.net
Wed Aug 10 16:13:56 UTC 2016


On Tue, Aug 09, 2016 at 12:36:40PM +0200, Nicolai Hähnle wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
> 
This is a great idea.

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

> ---
>  src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> index 7b96a58..22ff18e 100644
> --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> @@ -31,20 +31,21 @@
>  #include "gallivm/lp_bld_init.h"
>  #include "gallivm/lp_bld_intr.h"
>  #include "gallivm/lp_bld_misc.h"
>  #include "gallivm/lp_bld_swizzle.h"
>  #include "tgsi/tgsi_info.h"
>  #include "tgsi/tgsi_parse.h"
>  #include "util/u_math.h"
>  #include "util/u_memory.h"
>  #include "util/u_debug.h"
>  
> +#include <stdio.h>
>  #include <llvm-c/Core.h>
>  #include <llvm-c/Transforms/Scalar.h>
>  
>  LLVMTypeRef tgsi2llvmtype(struct lp_build_tgsi_context *bld_base,
>  			  enum tgsi_opcode_type type)
>  {
>  	LLVMContextRef ctx = bld_base->base.gallivm->context;
>  
>  	switch (type) {
>  	case TGSI_TYPE_UNSIGNED:
> @@ -421,20 +422,21 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
>  				 ctx->soa.addr[idx][chan] = si_build_alloca_undef(
>  					&ctx->gallivm,
>  					ctx->soa.bld_base.uint_bld.elem_type, "");
>  			}
>  		}
>  		break;
>  	}
>  
>  	case TGSI_FILE_TEMPORARY:
>  	{
> +		char name[16] = "";
>  		LLVMValueRef array_alloca = NULL;
>  		unsigned decl_size;
>  		first = decl->Range.First;
>  		last = decl->Range.Last;
>  		decl_size = 4 * ((last - first) + 1);
>  		if (decl->Declaration.Array) {
>  			unsigned id = decl->Array.ArrayID - 1;
>  			if (!ctx->arrays) {
>  				int size = bld_base->info->array_max[TGSI_FILE_TEMPORARY];
>  				ctx->arrays = CALLOC(size, sizeof(ctx->arrays[0]));
> @@ -458,34 +460,42 @@ static void emit_declaration(struct lp_build_tgsi_context *bld_base,
>  				ctx->arrays[id].alloca = array_alloca;
>  			}
>  		}
>  
>  		if (!ctx->temps_count) {
>  			ctx->temps_count = bld_base->info->file_max[TGSI_FILE_TEMPORARY] + 1;
>  			ctx->temps = MALLOC(TGSI_NUM_CHANNELS * ctx->temps_count * sizeof(LLVMValueRef));
>  		}
>  		if (!array_alloca) {
>  			for (i = 0; i < decl_size; ++i) {
> +#ifdef DEBUG
> +				snprintf(name, sizeof(name), "TEMP%d.%c",
> +					 first + i / 4, "xyzw"[i % 4]);
> +#endif
>  				ctx->temps[first * TGSI_NUM_CHANNELS + i] =
>  					si_build_alloca_undef(bld_base->base.gallivm,
>  							      bld_base->base.vec_type,
> -							      "temp");
> +							      name);
>  			}
>  		} else {
>  			LLVMValueRef idxs[2] = {
>  				bld_base->uint_bld.zero,
>  				NULL
>  			};
>  			for (i = 0; i < decl_size; ++i) {
> +#ifdef DEBUG
> +				snprintf(name, sizeof(name), "TEMP%d.%c",
> +					 first + i / 4, "xyzw"[i % 4]);
> +#endif
>  				idxs[1] = lp_build_const_int32(bld_base->base.gallivm, i);
>  				ctx->temps[first * TGSI_NUM_CHANNELS + i] =
> -					LLVMBuildGEP(builder, array_alloca, idxs, 2, "temp");
> +					LLVMBuildGEP(builder, array_alloca, idxs, 2, name);
>  			}
>  		}
>  		break;
>  	}
>  	case TGSI_FILE_INPUT:
>  	{
>  		unsigned idx;
>  		for (idx = decl->Range.First; idx <= decl->Range.Last; idx++) {
>  			if (ctx->load_input)
>  				ctx->load_input(ctx, idx, decl);
> -- 
> 2.7.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list