radeonsi: fix passing address32_hi to LLVM for high values
authorMarek Olšák <marek.olsak@amd.com>
Sat, 24 Feb 2018 23:33:28 +0000 (00:33 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 7 Mar 2018 18:55:49 +0000 (13:55 -0500)
The old function treats high values as negative, which LLVM interprets as 0.

src/amd/common/ac_llvm_util.c
src/amd/common/ac_llvm_util.h
src/gallium/drivers/radeonsi/si_shader.c

index 3530bf088bef9fd28fcf2fa2be383294d7a79808..bb9e873af817ffc9e8bdbe1237d28140bcfd3a3c 100644 (file)
@@ -202,11 +202,11 @@ ac_dump_module(LLVMModuleRef module)
 
 void
 ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
-                                    const char *name, int value)
+                                    const char *name, unsigned value)
 {
        char str[16];
 
-       snprintf(str, sizeof(str), "%i", value);
+       snprintf(str, sizeof(str), "0x%x", value);
        LLVMAddTargetDependentFunctionAttr(F, name, str);
 }
 
index 5329bb1b702f9f6c35f102800118ab901202c0c0..9c6b89bf6c1502932678ab8534228a74e09532c7 100644 (file)
@@ -87,7 +87,7 @@ LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
 
 void
 ac_llvm_add_target_dep_function_attr(LLVMValueRef F,
-                                    const char *name, int value);
+                                    const char *name, unsigned value);
 
 static inline unsigned
 ac_get_load_intr_attribs(bool can_speculate)
index 2e57eca6e54157b461121a4a14c1d0ddc4c62b7e..d95e69f81adb5b465ae592ea6ddfb34a01e67dca 100644 (file)
@@ -4456,8 +4456,11 @@ static void si_create_function(struct si_shader_context *ctx,
                        *fninfo->assign[i] = LLVMGetParam(ctx->main_fn, i);
        }
 
-       si_llvm_add_attribute(ctx->main_fn, "amdgpu-32bit-address-high-bits",
-                             ctx->screen->info.address32_hi);
+       if (ctx->screen->info.address32_hi) {
+               ac_llvm_add_target_dep_function_attr(ctx->main_fn,
+                                                    "amdgpu-32bit-address-high-bits",
+                                                    ctx->screen->info.address32_hi);
+       }
 
        if (max_workgroup_size) {
                si_llvm_add_attribute(ctx->main_fn, "amdgpu-max-work-group-size",