radv: set noalias/dereferenceable LLVM attributes based on param types
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 25 Jan 2019 08:21:33 +0000 (09:21 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 28 Jan 2019 15:30:38 +0000 (16:30 +0100)
Instead of using this useless array_params_mask variable.
This should set these two attributes to streamout buffers too.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_nir_to_llvm.c

index 690be94748572023e900d342802d09d6d89056bd..e80938527e5a41d28a7237927409f2ff82e61a40 100644 (file)
@@ -433,7 +433,6 @@ get_tcs_out_current_patch_data_offset(struct radv_shader_context *ctx)
 struct arg_info {
        LLVMTypeRef types[MAX_ARGS];
        LLVMValueRef *assign[MAX_ARGS];
-       unsigned array_params_mask;
        uint8_t count;
        uint8_t sgpr_count;
        uint8_t num_sgprs_used;
@@ -464,13 +463,6 @@ add_arg(struct arg_info *info, enum ac_arg_regfile regfile, LLVMTypeRef type,
        }
 }
 
-static inline void
-add_array_arg(struct arg_info *info, LLVMTypeRef type, LLVMValueRef *param_ptr)
-{
-       info->array_params_mask |= (1 << info->count);
-       add_arg(info, ARG_SGPR, type, param_ptr);
-}
-
 static void assign_arguments(LLVMValueRef main_function,
                             struct arg_info *info)
 {
@@ -509,10 +501,11 @@ create_llvm_function(LLVMContextRef ctx, LLVMModuleRef module,
 
        LLVMSetFunctionCallConv(main_function, RADEON_LLVM_AMDGPU_CS);
        for (unsigned i = 0; i < args->sgpr_count; ++i) {
+               LLVMValueRef P = LLVMGetParam(main_function, i);
+
                ac_add_function_attr(ctx, main_function, i + 1, AC_FUNC_ATTR_INREG);
 
-               if (args->array_params_mask & (1 << i)) {
-                       LLVMValueRef P = LLVMGetParam(main_function, i);
+               if (LLVMGetTypeKind(LLVMTypeOf(P)) == LLVMPointerTypeKind) {
                        ac_add_function_attr(ctx, main_function, i + 1, AC_FUNC_ATTR_NOALIAS);
                        ac_add_attr_dereferenceable(P, UINT64_MAX);
                }
@@ -726,15 +719,16 @@ declare_global_input_sgprs(struct radv_shader_context *ctx,
                while (mask) {
                        int i = u_bit_scan(&mask);
 
-                       add_array_arg(args, type, &ctx->descriptor_sets[i]);
+                       add_arg(args, ARG_SGPR, type, &ctx->descriptor_sets[i]);
                }
        } else {
-               add_array_arg(args, ac_array_in_const32_addr_space(type), desc_sets);
+               add_arg(args, ARG_SGPR, ac_array_in_const32_addr_space(type),
+                       desc_sets);
        }
 
        if (ctx->shader_info->info.loads_push_constants) {
                /* 1 for push constants and dynamic descriptors */
-               add_array_arg(args, type, &ctx->abi.push_constants);
+               add_arg(args, ARG_SGPR, type, &ctx->abi.push_constants);
        }
 
        if (ctx->shader_info->info.so.num_outputs) {