radv: setup llvm target data layout
authorDave Airlie <airlied@redhat.com>
Mon, 13 Mar 2017 20:50:59 +0000 (06:50 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 14 Mar 2017 00:33:59 +0000 (10:33 +1000)
Ported from radeonsi, pointed out by Tom.

"This prevents LLVM from using sext instructions for local memory
offsets and allows the backend to fold immediate offsets into the
instruction. This also prevents some incorrect code generation for
ptrtoint and inttoptr instructions."

Cc: "13.0 17.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tom Stellard <tstellar@redhat.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_nir_to_llvm.c

index 7675ecf545ef822d88bd65222d530c49d7c31f8d..0aba6797e7c72ac627616cd63aa19f634369be17 100644 (file)
@@ -4793,6 +4793,13 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
        memset(shader_info, 0, sizeof(*shader_info));
 
        LLVMSetTarget(ctx.module, options->supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--");
+
+       LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
+       char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
+       LLVMSetDataLayout(ctx.module, data_layout_str);
+       LLVMDisposeTargetData(data_layout);
+       LLVMDisposeMessage(data_layout_str);
+
        setup_types(&ctx);
 
        ctx.builder = LLVMCreateBuilderInContext(ctx.context);