[Mesa-dev] [PATCH] radeonsi: don't generate "ret void undef"

Marek Olšák maraeo at gmail.com
Mon Jun 13 16:17:55 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

Use LLVMBuildRetVoid in epilogs and the GS copy shader and
si_llvm_build_ret otherwise.
---
 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 f2bd337..6dc4985 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -6230,6 +6230,14 @@ int si_compile_llvm(struct si_screen *sscreen,
 	return r;
 }
 
+static void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret)
+{
+	if (LLVMGetTypeKind(LLVMTypeOf(ret)) == LLVMVoidTypeKind)
+		LLVMBuildRetVoid(ctx->radeon_bld.gallivm.builder);
+	else
+		LLVMBuildRet(ctx->radeon_bld.gallivm.builder, ret);
+}
+
 /* Generate code for the hardware VS shader stage to go with a geometry shader */
 static int si_generate_gs_copy_shader(struct si_screen *sscreen,
 				      struct si_shader_context *ctx,
@@ -6291,7 +6299,7 @@ static int si_generate_gs_copy_shader(struct si_screen *sscreen,
 
 	si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
 
-	LLVMBuildRet(gallivm->builder, ctx->return_value);
+	LLVMBuildRetVoid(gallivm->builder);
 
 	/* Dump LLVM IR before any optimization passes */
 	if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
@@ -6572,7 +6580,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
 		goto out;
 	}
 
-	LLVMBuildRet(bld_base->base.gallivm->builder, ctx.return_value);
+	si_llvm_build_ret(&ctx, ctx.return_value);
 	mod = bld_base->base.gallivm->module;
 
 	/* Dump LLVM IR before any optimization passes */
@@ -6807,7 +6815,7 @@ static bool si_compile_vs_prolog(struct si_screen *sscreen,
 	}
 
 	/* Compile. */
-	LLVMBuildRet(gallivm->builder, ret);
+	si_llvm_build_ret(&ctx, ret);
 	radeon_llvm_finalize_module(&ctx.radeon_bld);
 
 	if (si_compile_llvm(sscreen, &out->binary, &out->config, tm,
@@ -6880,7 +6888,7 @@ static bool si_compile_vs_epilog(struct si_screen *sscreen,
 	}
 
 	/* Compile. */
-	LLVMBuildRet(gallivm->builder, ctx.return_value);
+	LLVMBuildRetVoid(gallivm->builder);
 	radeon_llvm_finalize_module(&ctx.radeon_bld);
 
 	if (si_compile_llvm(sscreen, &out->binary, &out->config, tm,
@@ -7035,7 +7043,7 @@ static bool si_compile_tcs_epilog(struct si_screen *sscreen,
 			      LLVMGetParam(func, last_sgpr + 3));
 
 	/* Compile. */
-	LLVMBuildRet(gallivm->builder, ctx.return_value);
+	LLVMBuildRetVoid(gallivm->builder);
 	radeon_llvm_finalize_module(&ctx.radeon_bld);
 
 	if (si_compile_llvm(sscreen, &out->binary, &out->config, tm,
@@ -7228,7 +7236,7 @@ static bool si_compile_ps_prolog(struct si_screen *sscreen,
 	}
 
 	/* Compile. */
-	LLVMBuildRet(gallivm->builder, ret);
+	si_llvm_build_ret(&ctx, ret);
 	radeon_llvm_finalize_module(&ctx.radeon_bld);
 
 	if (si_compile_llvm(sscreen, &out->binary, &out->config, tm,
-- 
2.7.4



More information about the mesa-dev mailing list