[Mesa-dev] [PATCH] radeonsi: Dump LLVM IR before optimization passes

eocallaghan at alterapraxis.com eocallaghan at alterapraxis.com
Thu Feb 4 03:01:50 UTC 2016


Reviewed-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>

On 2016-02-04 13:28, Michel Dänzer wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
> 
> Otherwise it's not possible to diagnose problems caused by optimization
> passes.
> 
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c
> b/src/gallium/drivers/radeonsi/si_shader.c
> index 2192b21..d6c719f 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -4089,13 +4089,10 @@ int si_compile_llvm(struct si_screen *sscreen,
>  	int r = 0;
>  	unsigned count = p_atomic_inc_return(&sscreen->b.num_compilations);
> 
> -	if (r600_can_dump_shader(&sscreen->b, processor)) {
> +	if (!(sscreen->b.debug_flags & DBG_NO_IR) &&
> +	    r600_can_dump_shader(&sscreen->b, processor))
>  		fprintf(stderr, "radeonsi: Compiling shader %d\n", count);
> 
> -		if (!(sscreen->b.debug_flags & DBG_NO_IR))
> -			LLVMDumpModule(mod);
> -	}
> -
>  	if (!si_replace_shader(count, binary)) {
>  		r = radeon_llvm_compile(mod, binary,
>  			r600_get_llvm_processor_name(sscreen->b.family), tm,
> @@ -4177,6 +4174,11 @@ static int si_generate_gs_copy_shader(struct
> si_screen *sscreen,
> 
>  	si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
> 
> +	/* Dump LLVM IR before any optimization passes */
> +	if (!(sscreen->b.debug_flags & DBG_NO_IR) &&
> +	    r600_can_dump_shader(&sscreen->b, TGSI_PROCESSOR_GEOMETRY))
> +		LLVMDumpModule(bld_base->base.gallivm->module);
> +
>  	radeon_llvm_finalize_module(&si_shader_ctx->radeon_bld);
> 
>  	if (dump)
> @@ -4383,9 +4385,15 @@ int si_shader_create(struct si_screen *sscreen,
> LLVMTargetMachineRef tm,
>  		goto out;
>  	}
> 
> +	mod = bld_base->base.gallivm->module;
> +
> +	/* Dump LLVM IR before any optimization passes */
> +	if (!(sscreen->b.debug_flags & DBG_NO_IR) &&
> +	    r600_can_dump_shader(&sscreen->b, si_shader_ctx.type))
> +		LLVMDumpModule(mod);
> +
>  	radeon_llvm_finalize_module(&si_shader_ctx.radeon_bld);
> 
> -	mod = bld_base->base.gallivm->module;
>  	r = si_compile_llvm(sscreen, &shader->binary, &shader->config, tm,
>  			    mod, debug, si_shader_ctx.type);
>  	if (r) {



More information about the mesa-dev mailing list