radeonsi: set the calling convention for inlined function calls
authorMarek Olšák <marek.olsak@amd.com>
Wed, 19 Jun 2019 23:00:50 +0000 (19:00 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 25 Jun 2019 01:04:10 +0000 (21:04 -0400)
otherwise the behavior is undefined

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_compute_prim_discard.c
src/gallium/drivers/radeonsi/si_shader.c

index edadd56cc7b11f374bc88ae6a12ec303a74a1a8a..92c878acdcf535c64eefe4e07053fb7872ba7586 100644 (file)
@@ -4445,3 +4445,11 @@ ac_build_load_helper_invocation(struct ac_llvm_context *ctx)
        result = LLVMBuildNot(ctx->builder, result, "");
        return LLVMBuildSExt(ctx->builder, result, ctx->i32, "");
 }
+
+LLVMValueRef ac_build_call(struct ac_llvm_context *ctx, LLVMValueRef func,
+                          LLVMValueRef *args, unsigned num_args)
+{
+       LLVMValueRef ret = LLVMBuildCall(ctx->builder, func, args, num_args, "");
+       LLVMSetInstructionCallConv(ret, LLVMGetFunctionCallConv(func));
+       return ret;
+}
index a1654d2b2c4386360dad9c24d77a9f5f185a97c2..1928843c78c2ec7cee814f68c800f5db878ab4ee 100644 (file)
@@ -720,6 +720,9 @@ ac_build_ddxy_interp(struct ac_llvm_context *ctx, LLVMValueRef interp_ij);
 LLVMValueRef
 ac_build_load_helper_invocation(struct ac_llvm_context *ctx);
 
+LLVMValueRef ac_build_call(struct ac_llvm_context *ctx, LLVMValueRef func,
+                          LLVMValueRef *args, unsigned num_args);
+
 LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp op,
                                 LLVMValueRef ptr, LLVMValueRef val,
                                 const char *sync_scope);
index 0f2934243a1e81b5d025ff05dc26a2031eb6da50..28da7b9225071d1b4f2f874d0a1c01ef1df777f1 100644 (file)
@@ -667,7 +667,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx)
                vs_params[param_vertex_id] = index[i];
                vs_params[param_instance_id] = instance_id;
 
-               LLVMValueRef ret = LLVMBuildCall(builder, vs, vs_params, num_vs_params, "");
+               LLVMValueRef ret = ac_build_call(&ctx->ac, vs, vs_params, num_vs_params);
                for (unsigned chan = 0; chan < 4; chan++)
                        pos[i][chan] = LLVMBuildExtractValue(builder, ret, chan, "");
        }
index eb75e2a77a41da7a6b2f046000cc3368779aaa0f..54b29d0ae017e1cce46ac763b05276d54b3f433c 100644 (file)
@@ -6591,7 +6591,7 @@ static void si_build_wrapper_function(struct si_shader_context *ctx,
                        out_idx += param_size;
                }
 
-               ret = LLVMBuildCall(builder, parts[part], in, num_params, "");
+               ret = ac_build_call(&ctx->ac, parts[part], in, num_params);
 
                if (is_merged_shader(ctx) &&
                    part + 1 == next_shader_first_part) {