View | Details | Raw Unified | Return to bug 218196
Collapse All | Expand All

(-)Makefile.common (-1 / +1 lines)
Lines 60-66 Link Here
60
60
61
COMPONENT=		${PORTNAME:tl:C/^lib//:C/mesa-//}
61
COMPONENT=		${PORTNAME:tl:C/^lib//:C/mesa-//}
62
62
63
MESA_LLVM_VER=39
63
MESA_LLVM_VER=40
64
64
65
CONFIGURE_ARGS+=	--with-sha1=libcrypto
65
CONFIGURE_ARGS+=	--with-sha1=libcrypto
66
66
(-)files/patch-src_gallium_auxiliary_draw_draw_llvm.c (+22 lines)
Line 0 Link Here
1
--- src/gallium/auxiliary/draw/draw_llvm.c.orig	2017-02-20 03:46:54.000000000 -0800
2
+++ src/gallium/auxiliary/draw/draw_llvm.c	2017-03-24 11:18:24.753337000 -0700
3
@@ -1574,8 +1574,7 @@ draw_llvm_generate(struct draw_llvm *llv
4
    LLVMSetFunctionCallConv(variant_func, LLVMCCallConv);
5
    for (i = 0; i < num_arg_types; ++i)
6
       if (LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind)
7
-         LLVMAddAttribute(LLVMGetParam(variant_func, i),
8
-                          LLVMNoAliasAttribute);
9
+         lp_add_function_attr(variant_func, i + 1, LP_FUNC_ATTR_NOALIAS);
10
 
11
    context_ptr               = LLVMGetParam(variant_func, 0);
12
    io_ptr                    = LLVMGetParam(variant_func, 1);
13
@@ -2189,8 +2188,7 @@ draw_gs_llvm_generate(struct draw_llvm *
14
 
15
    for (i = 0; i < ARRAY_SIZE(arg_types); ++i)
16
       if (LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind)
17
-         LLVMAddAttribute(LLVMGetParam(variant_func, i),
18
-                          LLVMNoAliasAttribute);
19
+         lp_add_function_attr(variant_func, i + 1, LP_FUNC_ATTR_NOALIAS);
20
 
21
    context_ptr               = LLVMGetParam(variant_func, 0);
22
    input_array               = LLVMGetParam(variant_func, 1);
(-)files/patch-src_gallium_auxiliary_gallivm_lp_bld_intr.c (+99 lines)
Line 0 Link Here
1
--- src/gallium/auxiliary/gallivm/lp_bld_intr.c.orig	2017-03-24 14:07:46.566133000 -0700
2
+++ src/gallium/auxiliary/gallivm/lp_bld_intr.c	2017-03-24 14:08:08.499367000 -0700
3
@@ -46,6 +46,7 @@
4
 
5
 #include "util/u_debug.h"
6
 #include "util/u_string.h"
7
+#include "util/bitscan.h"
8
 
9
 #include "lp_bld_const.h"
10
 #include "lp_bld_intr.h"
11
@@ -120,13 +121,73 @@ lp_declare_intrinsic(LLVMModuleRef modul
12
 }
13
 
14
 
15
+#if HAVE_LLVM < 0x0400
16
+static LLVMAttribute lp_attr_to_llvm_attr(enum lp_func_attr attr)
17
+{
18
+   switch (attr) {
19
+   case LP_FUNC_ATTR_ALWAYSINLINE: return LLVMAlwaysInlineAttribute;
20
+   case LP_FUNC_ATTR_BYVAL: return LLVMByValAttribute;
21
+   case LP_FUNC_ATTR_INREG: return LLVMInRegAttribute;
22
+   case LP_FUNC_ATTR_NOALIAS: return LLVMNoAliasAttribute;
23
+   case LP_FUNC_ATTR_NOUNWIND: return LLVMNoUnwindAttribute;
24
+   case LP_FUNC_ATTR_READNONE: return LLVMReadNoneAttribute;
25
+   case LP_FUNC_ATTR_READONLY: return LLVMReadOnlyAttribute;
26
+   default:
27
+      _debug_printf("Unhandled function attribute: %x\n", attr);
28
+      return 0;
29
+   }
30
+}
31
+
32
+#else
33
+
34
+static const char *attr_to_str(enum lp_func_attr attr)
35
+{
36
+   switch (attr) {
37
+   case LP_FUNC_ATTR_ALWAYSINLINE: return "alwaysinline";
38
+   case LP_FUNC_ATTR_BYVAL: return "byval";
39
+   case LP_FUNC_ATTR_INREG: return "inreg";
40
+   case LP_FUNC_ATTR_NOALIAS: return "noalias";
41
+   case LP_FUNC_ATTR_NOUNWIND: return "nounwind";
42
+   case LP_FUNC_ATTR_READNONE: return "readnone";
43
+   case LP_FUNC_ATTR_READONLY: return "readonly";
44
+   default:
45
+      _debug_printf("Unhandled function attribute: %x\n", attr);
46
+      return 0;
47
+   }
48
+}
49
+
50
+#endif
51
+
52
+void
53
+lp_add_function_attr(LLVMValueRef function,
54
+                     int attr_idx,
55
+                     enum lp_func_attr attr)
56
+{
57
+
58
+#if HAVE_LLVM < 0x0400
59
+   LLVMAttribute llvm_attr = lp_attr_to_llvm_attr(attr);
60
+   if (attr_idx == -1) {
61
+      LLVMAddFunctionAttr(function, llvm_attr);
62
+   } else {
63
+      LLVMAddAttribute(LLVMGetParam(function, attr_idx - 1), llvm_attr);
64
+   }
65
+#else
66
+   LLVMContextRef context = LLVMGetModuleContext(LLVMGetGlobalParent(function));
67
+   const char *attr_name = attr_to_str(attr);
68
+   unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name,
69
+                                                      strlen(attr_name));
70
+   LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(context, kind_id, 0);
71
+   LLVMAddAttributeAtIndex(function, attr_idx, llvm_attr);
72
+#endif
73
+}
74
+
75
 LLVMValueRef
76
 lp_build_intrinsic(LLVMBuilderRef builder,
77
                    const char *name,
78
                    LLVMTypeRef ret_type,
79
                    LLVMValueRef *args,
80
                    unsigned num_args,
81
-                   LLVMAttribute attr)
82
+                   unsigned attr_mask)
83
 {
84
    LLVMModuleRef module = LLVMGetGlobalParent(LLVMGetBasicBlockParent(LLVMGetInsertBlock(builder)));
85
    LLVMValueRef function;
86
@@ -148,7 +209,12 @@ lp_build_intrinsic(LLVMBuilderRef builde
87
       /* NoUnwind indicates that the intrinsic never raises a C++ exception.
88
        * Set it for all intrinsics.
89
        */
90
-      LLVMAddFunctionAttr(function, attr | LLVMNoUnwindAttribute);
91
+      attr_mask |= LP_FUNC_ATTR_NOUNWIND;
92
+
93
+      while (attr_mask) {
94
+         enum lp_func_attr attr = 1 << u_bit_scan(&attr_mask);
95
+         lp_add_function_attr(function, -1, attr);
96
+      }
97
 
98
       if (gallivm_debug & GALLIVM_DEBUG_IR) {
99
          lp_debug_dump_value(function);
(-)files/patch-src_gallium_auxiliary_gallivm_lp_bld_intr.h (+39 lines)
Line 0 Link Here
1
--- src/gallium/auxiliary/gallivm/lp_bld_intr.h.orig	2017-02-20 03:46:54.000000000 -0800
2
+++ src/gallium/auxiliary/gallivm/lp_bld_intr.h	2017-03-24 11:18:24.754156000 -0700
3
@@ -46,6 +46,16 @@
4
  */
5
 #define LP_MAX_FUNC_ARGS 32
6
 
7
+enum lp_func_attr {
8
+   LP_FUNC_ATTR_ALWAYSINLINE = (1 << 0),
9
+   LP_FUNC_ATTR_BYVAL        = (1 << 1),
10
+   LP_FUNC_ATTR_INREG        = (1 << 2),
11
+   LP_FUNC_ATTR_NOALIAS      = (1 << 3),
12
+   LP_FUNC_ATTR_NOUNWIND     = (1 << 4),
13
+   LP_FUNC_ATTR_READNONE     = (1 << 5),
14
+   LP_FUNC_ATTR_READONLY     = (1 << 6),
15
+   LP_FUNC_ATTR_LAST         = (1 << 7)
16
+};
17
 
18
 void
19
 lp_format_intrinsic(char *name,
20
@@ -60,13 +70,18 @@ lp_declare_intrinsic(LLVMModuleRef modul
21
                      LLVMTypeRef *arg_types,
22
                      unsigned num_args);
23
 
24
+void
25
+lp_add_function_attr(LLVMValueRef function,
26
+                     int attr_idx,
27
+                     enum lp_func_attr attr);
28
+
29
 LLVMValueRef
30
 lp_build_intrinsic(LLVMBuilderRef builder,
31
                    const char *name,
32
                    LLVMTypeRef ret_type,
33
                    LLVMValueRef *args,
34
                    unsigned num_args,
35
-                   LLVMAttribute attr);
36
+                   unsigned attr_mask);
37
 
38
 
39
 LLVMValueRef
(-)files/patch-src_gallium_auxiliary_gallivm_lp_bld_sample_soa.c (+20 lines)
Line 0 Link Here
1
--- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c.orig	2017-02-20 03:46:54.000000000 -0800
2
+++ src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c	2017-03-24 11:18:24.755867000 -0700
3
@@ -60,6 +60,7 @@
4
 #include "lp_bld_struct.h"
5
 #include "lp_bld_quad.h"
6
 #include "lp_bld_pack.h"
7
+#include "lp_bld_intr.h"
8
 
9
 
10
 /**
11
@@ -3316,7 +3317,8 @@ lp_build_sample_soa_func(struct gallivm_
12
 
13
       for (i = 0; i < num_param; ++i) {
14
          if(LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind) {
15
-            LLVMAddAttribute(LLVMGetParam(function, i), LLVMNoAliasAttribute);
16
+
17
+            lp_add_function_attr(function, i + 1, LP_FUNC_ATTR_NOALIAS);
18
          }
19
       }
20
 
(-)files/patch-src_gallium_drivers_llvmpipe_lp_state_fs.c (+82 lines)
Line 0 Link Here
1
--- src/gallium/drivers/llvmpipe/lp_state_fs.c.orig	2017-03-24 13:06:45.849265000 -0700
2
+++ src/gallium/drivers/llvmpipe/lp_state_fs.c	2017-03-24 13:08:00.385629000 -0700
3
@@ -1,9 +1,9 @@
4
 /**************************************************************************
5
- * 
6
+ *
7
  * Copyright 2009 VMware, Inc.
8
  * Copyright 2007 VMware, Inc.
9
  * All Rights Reserved.
10
- * 
11
+ *
12
  * Permission is hereby granted, free of charge, to any person obtaining a
13
  * copy of this software and associated documentation files (the
14
  * "Software"), to deal in the Software without restriction, including
15
@@ -11,11 +11,11 @@
16
  * distribute, sub license, and/or sell copies of the Software, and to
17
  * permit persons to whom the Software is furnished to do so, subject to
18
  * the following conditions:
19
- * 
20
+ *
21
  * The above copyright notice and this permission notice (including the
22
  * next paragraph) shall be included in all copies or substantial portions
23
  * of the Software.
24
- * 
25
+ *
26
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
29
@@ -23,7 +23,7 @@
30
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
31
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
32
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
- * 
34
+ *
35
  **************************************************************************/
36
 
37
 /**
38
@@ -2257,7 +2257,7 @@ generate_fragment(struct llvmpipe_contex
39
    blend_type.width = 8;        /* 8-bit ubyte values */
40
    blend_type.length = 16;      /* 16 elements per vector */
41
 
42
-   /* 
43
+   /*
44
     * Generate the function prototype. Any change here must be reflected in
45
     * lp_jit.h's lp_jit_frag_func function pointer type, and vice-versa.
46
     */
47
@@ -2296,7 +2296,7 @@ generate_fragment(struct llvmpipe_contex
48
     */
49
    for(i = 0; i < ARRAY_SIZE(arg_types); ++i)
50
       if(LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind)
51
-         LLVMAddAttribute(LLVMGetParam(function, i), LLVMNoAliasAttribute);
52
+         lp_add_function_attr(function, i + 1, LP_FUNC_ATTR_NOALIAS);
53
 
54
    context_ptr  = LLVMGetParam(function, 0);
55
    x            = LLVMGetParam(function, 1);
56
@@ -2557,7 +2557,7 @@ dump_fs_variant_key(const struct lp_frag
57
 void
58
 lp_debug_fs_variant(const struct lp_fragment_shader_variant *variant)
59
 {
60
-   debug_printf("llvmpipe: Fragment shader #%u variant #%u:\n", 
61
+   debug_printf("llvmpipe: Fragment shader #%u variant #%u:\n",
62
                 variant->shader->no, variant->no);
63
    tgsi_dump(variant->shader->base.tokens, 0);
64
    dump_fs_variant_key(&variant->key);
65
@@ -2632,7 +2632,7 @@ generate_variant(struct llvmpipe_context
66
    }
67
 
68
    lp_jit_init_types(variant);
69
-   
70
+
71
    if (variant->jit_function[RAST_EDGE_TEST] == NULL)
72
       generate_fragment(lp, shader, variant, RAST_EDGE_TEST);
73
 
74
@@ -3124,7 +3124,7 @@ make_variant_key(struct llvmpipe_context
75
  * Update fragment shader state.  This is called just prior to drawing
76
  * something when some fragment-related state has changed.
77
  */
78
-void 
79
+void
80
 llvmpipe_update_fs(struct llvmpipe_context *lp)
81
 {
82
    struct lp_fragment_shader *shader = lp->fs;
(-)files/patch-src_gallium_drivers_llvmpipe_lp_state_setup.c (+93 lines)
Line 0 Link Here
1
--- src/gallium/drivers/llvmpipe/lp_state_setup.c.orig	2017-03-24 13:06:45.848147000 -0700
2
+++ src/gallium/drivers/llvmpipe/lp_state_setup.c	2017-03-24 13:07:39.073135000 -0700
3
@@ -110,7 +110,7 @@ store_coef(struct gallivm_state *gallivm
4
 
5
 
6
 
7
-static void 
8
+static void
9
 emit_constant_coef4(struct gallivm_state *gallivm,
10
                     struct lp_setup_args *args,
11
                     unsigned slot,
12
@@ -125,7 +125,7 @@ emit_constant_coef4(struct gallivm_state
13
  * Setup the fragment input attribute with the front-facing value.
14
  * \param frontface  is the triangle front facing?
15
  */
16
-static void 
17
+static void
18
 emit_facing_coef(struct gallivm_state *gallivm,
19
                  struct lp_setup_args *args,
20
                  unsigned slot )
21
@@ -258,7 +258,7 @@ lp_do_offset_tri(struct gallivm_state *g
22
 
23
    /* mult = MAX2(dzdx, dzdy) * pgon_offset_scale */
24
    max = LLVMBuildFCmp(b, LLVMRealUGT, dzdx, dzdy, "");
25
-   max_value = LLVMBuildSelect(b, max, dzdx, dzdy, "max"); 
26
+   max_value = LLVMBuildSelect(b, max, dzdx, dzdy, "max");
27
 
28
    mult = LLVMBuildFMul(b, max_value,
29
                         lp_build_const_float(gallivm, key->pgon_offset_scale), "");
30
@@ -392,7 +392,7 @@ load_attribute(struct gallivm_state *gal
31
  * sometimes completely in case of tris covering a block fully,
32
  * which obviously wouldn't work)).
33
  */
34
-static void 
35
+static void
36
 emit_coef4( struct gallivm_state *gallivm,
37
             struct lp_setup_args *args,
38
             unsigned slot,
39
@@ -434,7 +434,7 @@ emit_coef4( struct gallivm_state *galliv
40
 }
41
 
42
 
43
-static void 
44
+static void
45
 emit_linear_coef( struct gallivm_state *gallivm,
46
                   struct lp_setup_args *args,
47
                   unsigned slot,
48
@@ -442,7 +442,7 @@ emit_linear_coef( struct gallivm_state *
49
 {
50
    /* nothing to do anymore */
51
    emit_coef4(gallivm,
52
-              args, slot, 
53
+              args, slot,
54
               attribv[0],
55
               attribv[1],
56
               attribv[2]);
57
@@ -457,7 +457,7 @@ emit_linear_coef( struct gallivm_state *
58
  * Later, when we compute the value at a particular fragment position we'll
59
  * divide the interpolated value by the interpolated W at that fragment.
60
  */
61
-static void 
62
+static void
63
 apply_perspective_corr( struct gallivm_state *gallivm,
64
                         struct lp_setup_args *args,
65
                         unsigned slot,
66
@@ -559,7 +559,7 @@ emit_apply_cyl_wrap(struct gallivm_state
67
 /**
68
  * Compute the inputs-> dadx, dady, a0 values.
69
  */
70
-static void 
71
+static void
72
 emit_tri_coef( struct gallivm_state *gallivm,
73
                const struct lp_setup_variant_key *key,
74
                struct lp_setup_args *args)
75
@@ -624,8 +624,7 @@ set_noalias(LLVMBuilderRef builder,
76
    int i;
77
    for(i = 0; i < nr_args; ++i)
78
       if(LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind)
79
-         LLVMAddAttribute(LLVMGetParam(function, i),
80
-            LLVMNoAliasAttribute);
81
+         lp_add_function_attr(function, i + 1, LP_FUNC_ATTR_NOALIAS);
82
 }
83
 
84
 static void
85
@@ -937,7 +936,7 @@ cull_setup_variants(struct llvmpipe_cont
86
  * prior to drawing something when some fragment-related state has
87
  * changed.
88
  */
89
-void 
90
+void
91
 llvmpipe_update_setup(struct llvmpipe_context *lp)
92
 {
93
    struct lp_setup_variant_key *key = &lp->setup_variant.key;
(-)files/patch-src_gallium_drivers_radeonsi_si_shader.c (+256 lines)
Line 0 Link Here
1
--- src/gallium/drivers/radeonsi/si_shader.c.orig	2017-02-20 03:46:54.000000000 -0800
2
+++ src/gallium/drivers/radeonsi/si_shader.c	2017-03-24 11:21:43.735415000 -0700
3
@@ -413,7 +413,7 @@ static void declare_input_vs(
4
 	args[2] = buffer_index;
5
 	input = lp_build_intrinsic(gallivm->builder,
6
 		"llvm.SI.vs.load.input", ctx->v4f32, args, 3,
7
-		LLVMReadNoneAttribute);
8
+		LP_FUNC_ATTR_READNONE);
9
 
10
 	/* Break up the vec4 into individual components */
11
 	for (chan = 0; chan < 4; chan++) {
12
@@ -808,7 +808,7 @@ static LLVMValueRef build_buffer_load(st
13
 		         type_names[func]);
14
 
15
 		return lp_build_intrinsic(gallivm->builder, name, types[func], args,
16
-		                          ARRAY_SIZE(args), LLVMReadOnlyAttribute);
17
+		                          ARRAY_SIZE(args), LP_FUNC_ATTR_READONLY);
18
 	} else {
19
 		LLVMValueRef args[] = {
20
 			LLVMBuildBitCast(gallivm->builder, rsrc, ctx->v16i8, ""),
21
@@ -839,7 +839,7 @@ static LLVMValueRef build_buffer_load(st
22
 		         type_names[func], arg_type);
23
 
24
 		return lp_build_intrinsic(gallivm->builder, name, types[func], args,
25
-		                          ARRAY_SIZE(args), LLVMReadOnlyAttribute);
26
+		                          ARRAY_SIZE(args), LP_FUNC_ATTR_READONLY);
27
 	}
28
 }
29
 
30
@@ -1126,14 +1126,14 @@ static LLVMValueRef fetch_input_gs(
31
 	value = lp_build_intrinsic(gallivm->builder,
32
 				   "llvm.SI.buffer.load.dword.i32.i32",
33
 				   ctx->i32, args, 9,
34
-				   LLVMReadOnlyAttribute);
35
+				   LP_FUNC_ATTR_READONLY);
36
 	if (tgsi_type_is_64bit(type)) {
37
 		LLVMValueRef value2;
38
 		args[2] = lp_build_const_int32(gallivm, (param * 4 + swizzle + 1) * 256);
39
 		value2 = lp_build_intrinsic(gallivm->builder,
40
 					    "llvm.SI.buffer.load.dword.i32.i32",
41
 					    ctx->i32, args, 9,
42
-					    LLVMReadOnlyAttribute);
43
+					    LP_FUNC_ATTR_READONLY);
44
 		return si_llvm_emit_fetch_64bit(bld_base, type,
45
 						value, value2);
46
 	}
47
@@ -1285,12 +1285,12 @@ static void interp_fs_input(struct si_sh
48
 			args[1] = attr_number;
49
 			front = lp_build_intrinsic(gallivm->builder, intr_name,
50
 						ctx->f32, args, args[3] ? 4 : 3,
51
-						LLVMReadNoneAttribute);
52
+						LP_FUNC_ATTR_READNONE);
53
 
54
 			args[1] = back_attr_number;
55
 			back = lp_build_intrinsic(gallivm->builder, intr_name,
56
 					       ctx->f32, args, args[3] ? 4 : 3,
57
-					       LLVMReadNoneAttribute);
58
+					       LP_FUNC_ATTR_READNONE);
59
 
60
 			result[chan] = LLVMBuildSelect(gallivm->builder,
61
 						is_face_positive,
62
@@ -1307,7 +1307,7 @@ static void interp_fs_input(struct si_sh
63
 		args[3] = interp_param;
64
 		result[0] = lp_build_intrinsic(gallivm->builder, intr_name,
65
 					ctx->f32, args, args[3] ? 4 : 3,
66
-					LLVMReadNoneAttribute);
67
+					LP_FUNC_ATTR_READNONE);
68
 		result[1] =
69
 		result[2] = lp_build_const_float(gallivm, 0.0f);
70
 		result[3] = lp_build_const_float(gallivm, 1.0f);
71
@@ -1322,7 +1322,7 @@ static void interp_fs_input(struct si_sh
72
 			args[3] = interp_param;
73
 			result[chan] = lp_build_intrinsic(gallivm->builder, intr_name,
74
 						ctx->f32, args, args[3] ? 4 : 3,
75
-						LLVMReadNoneAttribute);
76
+						LP_FUNC_ATTR_READNONE);
77
 		}
78
 	}
79
 }
80
@@ -1463,18 +1463,18 @@ static LLVMValueRef get_thread_id(struct
81
 
82
 	if (HAVE_LLVM < 0x0308) {
83
 		tid = lp_build_intrinsic(gallivm->builder, "llvm.SI.tid",
84
-				ctx->i32,   NULL, 0, LLVMReadNoneAttribute);
85
+				ctx->i32,   NULL, 0, LP_FUNC_ATTR_READNONE);
86
 	} else {
87
 		LLVMValueRef tid_args[2];
88
 		tid_args[0] = lp_build_const_int32(gallivm, 0xffffffff);
89
 		tid_args[1] = lp_build_const_int32(gallivm, 0);
90
 		tid_args[1] = lp_build_intrinsic(gallivm->builder,
91
 					"llvm.amdgcn.mbcnt.lo", ctx->i32,
92
-					tid_args, 2, LLVMReadNoneAttribute);
93
+					tid_args, 2, LP_FUNC_ATTR_READNONE);
94
 
95
 		tid = lp_build_intrinsic(gallivm->builder,
96
 					"llvm.amdgcn.mbcnt.hi", ctx->i32,
97
-					tid_args, 2, LLVMReadNoneAttribute);
98
+					tid_args, 2, LP_FUNC_ATTR_READNONE);
99
 	}
100
 	set_range_metadata(ctx, tid, 0, 64);
101
 	return tid;
102
@@ -1491,7 +1491,7 @@ static LLVMValueRef buffer_load_const(st
103
 	LLVMValueRef args[2] = {resource, offset};
104
 
105
 	return lp_build_intrinsic(builder, "llvm.SI.load.const", ctx->f32, args, 2,
106
-			       LLVMReadNoneAttribute);
107
+			       LP_FUNC_ATTR_READNONE);
108
 }
109
 
110
 static LLVMValueRef load_sample_position(struct si_shader_context *radeon_bld, LLVMValueRef sample_id)
111
@@ -1729,7 +1729,7 @@ static void declare_system_value(
112
 		value = lp_build_intrinsic(gallivm->builder,
113
 					   "llvm.amdgcn.ps.live",
114
 					   ctx->i1, NULL, 0,
115
-					   LLVMReadNoneAttribute);
116
+					   LP_FUNC_ATTR_READNONE);
117
 		value = LLVMBuildNot(gallivm->builder, value, "");
118
 		value = LLVMBuildSExt(gallivm->builder, value, ctx->i32, "");
119
 		break;
120
@@ -1942,7 +1942,7 @@ static void si_llvm_init_export_args(str
121
 			packed = lp_build_intrinsic(base->gallivm->builder,
122
 						    "llvm.SI.packf16",
123
 						    ctx->i32, pack_args, 2,
124
-						    LLVMReadNoneAttribute);
125
+						    LP_FUNC_ATTR_READNONE);
126
 			args[chan + 5] =
127
 				LLVMBuildBitCast(base->gallivm->builder,
128
 						 packed, ctx->f32, "");
129
@@ -2087,7 +2087,7 @@ static LLVMValueRef si_scale_alpha_by_sa
130
 
131
 	coverage = lp_build_intrinsic(gallivm->builder, "llvm.ctpop.i32",
132
 				   ctx->i32,
133
-				   &coverage, 1, LLVMReadNoneAttribute);
134
+				   &coverage, 1, LP_FUNC_ATTR_READNONE);
135
 
136
 	coverage = LLVMBuildUIToFP(gallivm->builder, coverage,
137
 				   ctx->f32, "");
138
@@ -3668,7 +3668,7 @@ static void load_emit_buffer(struct si_s
139
 	emit_data->output[emit_data->chan] = lp_build_intrinsic(
140
 			builder, intrinsic_name, dst_type,
141
 			emit_data->args, emit_data->arg_count,
142
-			LLVMReadOnlyAttribute);
143
+			LP_FUNC_ATTR_READONLY);
144
 }
145
 
146
 static LLVMValueRef get_memory_ptr(struct si_shader_context *ctx,
147
@@ -3773,7 +3773,7 @@ static void load_emit(
148
 			lp_build_intrinsic(
149
 				builder, "llvm.amdgcn.buffer.load.format.v4f32", emit_data->dst_type,
150
 				emit_data->args, emit_data->arg_count,
151
-				LLVMReadOnlyAttribute);
152
+				LP_FUNC_ATTR_READONLY);
153
 	} else {
154
 		get_image_intr_name("llvm.amdgcn.image.load",
155
 				emit_data->dst_type,		/* vdata */
156
@@ -3785,7 +3785,7 @@ static void load_emit(
157
 			lp_build_intrinsic(
158
 				builder, intrinsic_name, emit_data->dst_type,
159
 				emit_data->args, emit_data->arg_count,
160
-				LLVMReadOnlyAttribute);
161
+				LP_FUNC_ATTR_READONLY);
162
 	}
163
 }
164
 
165
@@ -4221,7 +4221,7 @@ static void resq_emit(
166
 		out = lp_build_intrinsic(
167
 			builder, "llvm.SI.getresinfo.i32", emit_data->dst_type,
168
 			emit_data->args, emit_data->arg_count,
169
-			LLVMReadNoneAttribute);
170
+			LP_FUNC_ATTR_READNONE);
171
 
172
 		/* Divide the number of layers by 6 to get the number of cubes. */
173
 		if (inst->Memory.Texture == TGSI_TEXTURE_CUBE_ARRAY) {
174
@@ -4455,7 +4455,7 @@ static void txq_emit(const struct lp_bui
175
 	emit_data->output[emit_data->chan] = lp_build_intrinsic(
176
 		base->gallivm->builder, "llvm.SI.getresinfo.i32",
177
 		emit_data->dst_type, emit_data->args, emit_data->arg_count,
178
-		LLVMReadNoneAttribute);
179
+		LP_FUNC_ATTR_READNONE);
180
 
181
 	/* Divide the number of layers by 6 to get the number of cubes. */
182
 	if (target == TGSI_TEXTURE_CUBE_ARRAY ||
183
@@ -4873,7 +4873,7 @@ static void si_lower_gather4_integer(str
184
 	emit_data->output[emit_data->chan] =
185
 		lp_build_intrinsic(builder, intr_name, emit_data->dst_type,
186
 				   emit_data->args, emit_data->arg_count,
187
-				   LLVMReadNoneAttribute);
188
+				   LP_FUNC_ATTR_READNONE);
189
 }
190
 
191
 static void build_tex_intrinsic(const struct lp_build_tgsi_action *action,
192
@@ -4897,7 +4897,7 @@ static void build_tex_intrinsic(const st
193
 			base->gallivm->builder,
194
 			"llvm.SI.vs.load.input", emit_data->dst_type,
195
 			emit_data->args, emit_data->arg_count,
196
-			LLVMReadNoneAttribute);
197
+			LP_FUNC_ATTR_READNONE);
198
 		return;
199
 	}
200
 
201
@@ -4974,7 +4974,7 @@ static void build_tex_intrinsic(const st
202
 	emit_data->output[emit_data->chan] = lp_build_intrinsic(
203
 		base->gallivm->builder, intr_name, emit_data->dst_type,
204
 		emit_data->args, emit_data->arg_count,
205
-		LLVMReadNoneAttribute);
206
+		LP_FUNC_ATTR_READNONE);
207
 }
208
 
209
 static void si_llvm_emit_txqs(
210
@@ -5072,13 +5072,13 @@ static void si_llvm_emit_ddxy(
211
 		args[1] = val;
212
 		tl = lp_build_intrinsic(gallivm->builder,
213
 					"llvm.amdgcn.ds.bpermute", ctx->i32,
214
-					args, 2, LLVMReadNoneAttribute);
215
+					args, 2, LP_FUNC_ATTR_READNONE);
216
 
217
 		args[0] = LLVMBuildMul(gallivm->builder, trbl_tid,
218
 				       lp_build_const_int32(gallivm, 4), "");
219
 		trbl = lp_build_intrinsic(gallivm->builder,
220
 					  "llvm.amdgcn.ds.bpermute", ctx->i32,
221
-					  args, 2, LLVMReadNoneAttribute);
222
+					  args, 2, LP_FUNC_ATTR_READNONE);
223
 	} else {
224
 		LLVMValueRef store_ptr, load_ptr0, load_ptr1;
225
 
226
@@ -5261,7 +5261,7 @@ static void build_interp_intrinsic(const
227
 		emit_data->output[chan] =
228
 			lp_build_intrinsic(gallivm->builder, intr_name,
229
 					   ctx->f32, args, args[3] ? 4 : 3,
230
-					   LLVMReadNoneAttribute);
231
+					   LP_FUNC_ATTR_READNONE);
232
 	}
233
 }
234
 
235
@@ -5446,10 +5446,10 @@ static void si_create_function(struct si
236
 		 * SGPR spilling significantly.
237
 		 */
238
 		if (LLVMGetTypeKind(LLVMTypeOf(P)) == LLVMPointerTypeKind) {
239
-			LLVMAddAttribute(P, LLVMByValAttribute);
240
+			lp_add_function_attr(ctx->main_fn, i + 1, LP_FUNC_ATTR_BYVAL);
241
 			lp_add_attr_dereferenceable(P, UINT64_MAX);
242
 		} else
243
-			LLVMAddAttribute(P, LLVMInRegAttribute);
244
+			lp_add_function_attr(ctx->main_fn, i + 1, LP_FUNC_ATTR_INREG);
245
 	}
246
 
247
 	if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
248
@@ -6395,7 +6395,7 @@ static int si_generate_gs_copy_shader(st
249
 						 lp_build_intrinsic(gallivm->builder,
250
 								 "llvm.SI.buffer.load.dword.i32.i32",
251
 								 ctx->i32, args, 9,
252
-								 LLVMReadOnlyAttribute),
253
+								 LP_FUNC_ATTR_READONLY),
254
 						 ctx->f32, "");
255
 		}
256
 	}
(-)files/patch-src_gallium_drivers_radeonsi_si_shader_tgsi_alu.c (+92 lines)
Line 0 Link Here
1
--- src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c.orig	2017-02-20 03:46:54.000000000 -0800
2
+++ src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c	2017-03-24 11:18:24.760067000 -0700
3
@@ -399,7 +399,7 @@ static void emit_frac(const struct lp_bu
4
 
5
 	LLVMValueRef floor = lp_build_intrinsic(builder, intr, emit_data->dst_type,
6
 						&emit_data->args[0], 1,
7
-						LLVMReadNoneAttribute);
8
+						LP_FUNC_ATTR_READNONE);
9
 	emit_data->output[emit_data->chan] = LLVMBuildFSub(builder,
10
 			emit_data->args[0], floor, "");
11
 }
12
@@ -449,7 +449,7 @@ build_tgsi_intrinsic_nomem(const struct 
13
 	emit_data->output[emit_data->chan] =
14
 		lp_build_intrinsic(base->gallivm->builder, action->intr_name,
15
 				   emit_data->dst_type, emit_data->args,
16
-				   emit_data->arg_count, LLVMReadNoneAttribute);
17
+				   emit_data->arg_count, LP_FUNC_ATTR_READNONE);
18
 }
19
 
20
 static void emit_bfi(const struct lp_build_tgsi_action *action,
21
@@ -507,7 +507,7 @@ static void emit_bfe(const struct lp_bui
22
 
23
 	bfe_sm5 = lp_build_intrinsic(builder, action->intr_name,
24
 				     emit_data->dst_type, emit_data->args,
25
-				     emit_data->arg_count, LLVMReadNoneAttribute);
26
+				     emit_data->arg_count, LP_FUNC_ATTR_READNONE);
27
 
28
 	/* Correct for GLSL semantics. */
29
 	cond = LLVMBuildICmp(builder, LLVMIntUGE, emit_data->args[2],
30
@@ -539,7 +539,7 @@ static void emit_lsb(const struct lp_bui
31
 	LLVMValueRef lsb =
32
 		lp_build_intrinsic(gallivm->builder, "llvm.cttz.i32",
33
 				emit_data->dst_type, args, ARRAY_SIZE(args),
34
-				LLVMReadNoneAttribute);
35
+				LP_FUNC_ATTR_READNONE);
36
 
37
 	/* TODO: We need an intrinsic to skip this conditional. */
38
 	/* Check for zero: */
39
@@ -566,7 +566,7 @@ static void emit_umsb(const struct lp_bu
40
 	LLVMValueRef msb =
41
 		lp_build_intrinsic(builder, "llvm.ctlz.i32",
42
 				emit_data->dst_type, args, ARRAY_SIZE(args),
43
-				LLVMReadNoneAttribute);
44
+				LP_FUNC_ATTR_READNONE);
45
 
46
 	/* The HW returns the last bit index from MSB, but TGSI wants
47
 	 * the index from LSB. Invert it by doing "31 - msb". */
48
@@ -593,7 +593,7 @@ static void emit_imsb(const struct lp_bu
49
 	LLVMValueRef msb =
50
 		lp_build_intrinsic(builder, "llvm.AMDGPU.flbit.i32",
51
 				emit_data->dst_type, &arg, 1,
52
-				LLVMReadNoneAttribute);
53
+				LP_FUNC_ATTR_READNONE);
54
 
55
 	/* The HW returns the last bit index from MSB, but TGSI wants
56
 	 * the index from LSB. Invert it by doing "31 - msb". */
57
@@ -917,13 +917,13 @@ static LLVMValueRef build_cube_intrinsic
58
 		LLVMValueRef out[4];
59
 
60
 		out[0] = lp_build_intrinsic(gallivm->builder, "llvm.amdgcn.cubetc",
61
-					    f32, in, 3, LLVMReadNoneAttribute);
62
+					    f32, in, 3, LP_FUNC_ATTR_READNONE);
63
 		out[1] = lp_build_intrinsic(gallivm->builder, "llvm.amdgcn.cubesc",
64
-					    f32, in, 3, LLVMReadNoneAttribute);
65
+					    f32, in, 3, LP_FUNC_ATTR_READNONE);
66
 		out[2] = lp_build_intrinsic(gallivm->builder, "llvm.amdgcn.cubema",
67
-					    f32, in, 3, LLVMReadNoneAttribute);
68
+					    f32, in, 3, LP_FUNC_ATTR_READNONE);
69
 		out[3] = lp_build_intrinsic(gallivm->builder, "llvm.amdgcn.cubeid",
70
-					    f32, in, 3, LLVMReadNoneAttribute);
71
+					    f32, in, 3, LP_FUNC_ATTR_READNONE);
72
 
73
 		return lp_build_gather_values(gallivm, out, 4);
74
 	} else {
75
@@ -937,7 +937,7 @@ static LLVMValueRef build_cube_intrinsic
76
 
77
 		return lp_build_intrinsic(gallivm->builder, "llvm.AMDGPU.cube",
78
 					  LLVMTypeOf(vec), &vec, 1,
79
-					  LLVMReadNoneAttribute);
80
+					  LP_FUNC_ATTR_READNONE);
81
 	}
82
 }
83
 
84
@@ -959,7 +959,7 @@ static void si_llvm_cube_to_2d_coords(st
85
 						    lp_build_const_int32(gallivm, i), "");
86
 
87
 	coords[2] = lp_build_intrinsic(builder, "llvm.fabs.f32",
88
-			type, &coords[2], 1, LLVMReadNoneAttribute);
89
+			type, &coords[2], 1, LP_FUNC_ATTR_READNONE);
90
 	coords[2] = lp_build_emit_llvm_unary(bld_base, TGSI_OPCODE_RCP, coords[2]);
91
 
92
 	mad_args[1] = coords[2];
(-)files/patch-src_gallium_state_trackers_clover_llvm_codegen_bitcode.cpp (+33 lines)
Line 0 Link Here
1
--- src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp.orig	2017-03-24 14:45:44.224748000 -0700
2
+++ src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp	2017-03-24 14:50:20.817764000 -0700
3
@@ -32,12 +32,18 @@
4
 ///
5
 
6
 #include "llvm/codegen.hpp"
7
+#include "llvm/compat.hpp"
8
 #include "llvm/metadata.hpp"
9
 #include "core/error.hpp"
10
 #include "util/algorithm.hpp"
11
 
12
 #include <map>
13
+#if HAVE_LLVM < 0x0400
14
 #include <llvm/Bitcode/ReaderWriter.h>
15
+#else
16
+#include <llvm/Bitcode/BitcodeReader.h>
17
+#include <llvm/Bitcode/BitcodeWriter.h>
18
+#endif
19
 #include <llvm/Support/raw_ostream.h>
20
 
21
 using namespace clover;
22
@@ -92,8 +98,9 @@ clover::llvm::parse_module_library(const
23
                                    std::string &r_log) {
24
    auto mod = ::llvm::parseBitcodeFile(::llvm::MemoryBufferRef(
25
                                         as_string(m.secs[0].data), " "), ctx);
26
-   if (!mod)
27
-      fail(r_log, error(CL_INVALID_PROGRAM), mod.getError().message());
28
+   compat::handle_module_error(mod, [&](const std::string &s) {
29
+         fail(r_log, error(CL_INVALID_PROGRAM), s);
30
+      });
31
 
32
    return std::unique_ptr<::llvm::Module>(std::move(*mod));
33
 }
(-)files/patch-src_gallium_state_trackers_clover_llvm_compat.hpp (+34 lines)
Line 0 Link Here
1
--- src/gallium/state_trackers/clover/llvm/compat.hpp.orig	2017-03-24 14:48:10.921731000 -0700
2
+++ src/gallium/state_trackers/clover/llvm/compat.hpp	2017-03-24 14:49:20.623489000 -0700
3
@@ -39,6 +39,11 @@
4
 #include <llvm/Linker/Linker.h>
5
 #include <llvm/Transforms/IPO.h>
6
 #include <llvm/Target/TargetMachine.h>
7
+#if HAVE_LLVM >= 0x0400
8
+#include <llvm/Support/Error.h>
9
+#else
10
+#include <llvm/Support/ErrorOr.h>
11
+#endif
12
 
13
 #if HAVE_LLVM >= 0x0307
14
 #include <llvm/IR/LegacyPassManager.h>
15
@@ -158,6 +163,19 @@ namespace clover {
16
 #else
17
          const auto default_reloc_model = ::llvm::Reloc::Default;
18
 #endif
19
+
20
+         template<typename M, typename F> void
21
+         handle_module_error(M &mod, const F &f) {
22
+#if HAVE_LLVM >= 0x0400
23
+            if (::llvm::Error err = mod.takeError())
24
+               ::llvm::handleAllErrors(std::move(err), [&](::llvm::ErrorInfoBase &eib) {
25
+                     f(eib.message());
26
+                  });
27
+#else
28
+            if (!mod)
29
+               f(mod.getError().message());
30
+#endif
31
+         }
32
       }
33
    }
34
 }

Return to bug 218196