<div dir="ltr">Hi<div><br></div><div>I think this patch is causing build problems for me </div><div><br></div><div><span style="font-family:monospace">/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c: In function ‘create_llvm_function’:
<br>/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c:265:4: error: implicit declaration of function ‘ac_add_function_attr’ [-Werror=implicit-function-declaration]
<br>    ac_add_function_attr(main_function, i + 1, AC_FUNC_ATTR_BYVAL);
<br>    ^~~~~~~~~~~~~~~~~~~~
<br>/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c: In function ‘visit_interp’:
<br>/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c:3022:11: warning: ‘location’ may be used uninitialized in this function [-Wmaybe-uninitialized]
<br>  unsigned location;
<br>           ^~~~~~~~
<br>/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c:3089:10: warning: ‘src_c1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
<br>    temp2 = LLVMBuildFMul(ctx->builder, ddy_el, src_c1, "");
<br>    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<br>/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c:3086:10: warning: ‘src_c0’ may be used uninitialized in this function [-Wmaybe-uninitialized]
<br>    temp1 = LLVMBuildFMul(ctx->builder, ddx_el, src_c0, "");
<br>    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<br>/var/tmp/portage/media-libs/mesa-9999/work/mesa-9999/src/amd/common/ac_nir_to_llvm.c:3044:12: warning: ‘src0’ may be used uninitialized in this function [-Wmaybe-uninitialized]
<br>   src_c1 = to_float(ctx, LLVMBuildExtractElement(ctx->builder, src0, ctx->i32one, ""));
<br>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<br>cc1: some warnings being treated as errors<br>
<br></span></div><div><br></div><div>Was it tested?</div><div><br></div><div>Mike</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 1 Mar 2017 at 17:22 Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Mar 1, 2017 at 5:29 PM, Jose Fonseca <<a href="mailto:jfonseca@vmware.com" class="gmail_msg" target="_blank">jfonseca@vmware.com</a>> wrote:<br class="gmail_msg">
> On 23/02/17 00:01, Marek Olšák wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> From: Marek Olšák <<a href="mailto:marek.olsak@amd.com" class="gmail_msg" target="_blank">marek.olsak@amd.com</a>><br class="gmail_msg">
>><br class="gmail_msg">
>> They can vary at call sites if the intrinsic is NOT a legacy SI intrinsic.<br class="gmail_msg">
>> We need this to force readnone or inaccessiblememonly on some amdgcn<br class="gmail_msg">
>> intrinsics.<br class="gmail_msg">
>><br class="gmail_msg">
>> This is only used with LLVM 4.0 and later. Intrinsics only used with<br class="gmail_msg">
>> LLVM <= 3.9 don't need the LEGACY flag.<br class="gmail_msg">
>><br class="gmail_msg">
>> gallivm and ac code is in the same patch, because splitting would be<br class="gmail_msg">
>> more complicated with all the LEGACY uses all over the place.<br class="gmail_msg">
>> ---<br class="gmail_msg">
>>  src/amd/common/ac_llvm_build.c                    | 23 ++++----<br class="gmail_msg">
>>  src/amd/common/ac_llvm_util.c                     | 31 +++++++----<br class="gmail_msg">
>>  src/amd/common/ac_llvm_util.h                     | 17 +++---<br class="gmail_msg">
>>  src/amd/common/ac_nir_to_llvm.c                   | 63<br class="gmail_msg">
>> ++++++++++++++--------<br class="gmail_msg">
>>  src/gallium/auxiliary/draw/draw_llvm.c            |  6 ++-<br class="gmail_msg">
>>  src/gallium/auxiliary/gallivm/lp_bld_intr.c       | 51 ++++++++++++------<br class="gmail_msg">
>>  src/gallium/auxiliary/gallivm/lp_bld_intr.h       | 11 ++--<br class="gmail_msg">
>>  src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |  3 +-<br class="gmail_msg">
>>  src/gallium/drivers/llvmpipe/lp_state_fs.c        |  3 +-<br class="gmail_msg">
>>  src/gallium/drivers/llvmpipe/lp_state_setup.c     |  7 +--<br class="gmail_msg">
>>  src/gallium/drivers/radeonsi/si_shader.c          | 64<br class="gmail_msg">
>> ++++++++++++++---------<br class="gmail_msg">
>>  src/gallium/drivers/radeonsi/si_shader_tgsi_alu.c | 14 +++--<br class="gmail_msg">
>>  12 files changed, 184 insertions(+), 109 deletions(-)<br class="gmail_msg">
>><br class="gmail_msg">
>> diff --git a/src/amd/common/ac_llvm_build.c<br class="gmail_msg">
>> b/src/amd/common/ac_llvm_build.c<br class="gmail_msg">
>> index 2f25b14..5c8b7f7 100644<br class="gmail_msg">
>> --- a/src/amd/common/ac_llvm_build.c<br class="gmail_msg">
>> +++ b/src/amd/common/ac_llvm_build.c<br class="gmail_msg">
>> @@ -75,47 +75,50 @@ ac_llvm_context_init(struct ac_llvm_context *ctx,<br class="gmail_msg">
>> LLVMContextRef context)<br class="gmail_msg">
>>                                                         "amdgpu.uniform",<br class="gmail_msg">
>> 14);<br class="gmail_msg">
>><br class="gmail_msg">
>>         ctx->empty_md = LLVMMDNodeInContext(ctx->context, NULL, 0);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  LLVMValueRef<br class="gmail_msg">
>>  ac_emit_llvm_intrinsic(struct ac_llvm_context *ctx, const char *name,<br class="gmail_msg">
>>                        LLVMTypeRef return_type, LLVMValueRef *params,<br class="gmail_msg">
>>                        unsigned param_count, unsigned attrib_mask)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>> -       LLVMValueRef function;<br class="gmail_msg">
>> +       LLVMValueRef function, call;<br class="gmail_msg">
>> +       bool set_callsite_attrs = HAVE_LLVM >= 0x0400 &&<br class="gmail_msg">
>> +                                 !(attrib_mask & AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>         function = LLVMGetNamedFunction(ctx->module, name);<br class="gmail_msg">
>>         if (!function) {<br class="gmail_msg">
>>                 LLVMTypeRef param_types[32], function_type;<br class="gmail_msg">
>>                 unsigned i;<br class="gmail_msg">
>><br class="gmail_msg">
>>                 assert(param_count <= 32);<br class="gmail_msg">
>><br class="gmail_msg">
>>                 for (i = 0; i < param_count; ++i) {<br class="gmail_msg">
>>                         assert(params[i]);<br class="gmail_msg">
>>                         param_types[i] = LLVMTypeOf(params[i]);<br class="gmail_msg">
>>                 }<br class="gmail_msg">
>>                 function_type =<br class="gmail_msg">
>>                     LLVMFunctionType(return_type, param_types,<br class="gmail_msg">
>> param_count, 0);<br class="gmail_msg">
>>                 function = LLVMAddFunction(ctx->module, name,<br class="gmail_msg">
>> function_type);<br class="gmail_msg">
>><br class="gmail_msg">
>>                 LLVMSetFunctionCallConv(function, LLVMCCallConv);<br class="gmail_msg">
>>                 LLVMSetLinkage(function, LLVMExternalLinkage);<br class="gmail_msg">
>><br class="gmail_msg">
>> -               attrib_mask |= AC_FUNC_ATTR_NOUNWIND;<br class="gmail_msg">
>> -               while (attrib_mask) {<br class="gmail_msg">
>> -                       enum ac_func_attr attr = 1u <<<br class="gmail_msg">
>> u_bit_scan(&attrib_mask);<br class="gmail_msg">
>> -                       ac_add_function_attr(function, -1, attr);<br class="gmail_msg">
>> -               }<br class="gmail_msg">
>> +               if (!set_callsite_attrs)<br class="gmail_msg">
>> +                       ac_add_func_attributes(ctx->context, function,<br class="gmail_msg">
>> attrib_mask);<br class="gmail_msg">
>>         }<br class="gmail_msg">
>> -       return LLVMBuildCall(ctx->builder, function, params, param_count,<br class="gmail_msg">
>> "");<br class="gmail_msg">
>> +<br class="gmail_msg">
>> +       call = LLVMBuildCall(ctx->builder, function, params, param_count,<br class="gmail_msg">
>> "");<br class="gmail_msg">
>> +       if (set_callsite_attrs)<br class="gmail_msg">
>> +               ac_add_func_attributes(ctx->context, call, attrib_mask);<br class="gmail_msg">
>> +       return call;<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  LLVMValueRef<br class="gmail_msg">
>>  ac_build_gather_values_extended(struct ac_llvm_context *ctx,<br class="gmail_msg">
>>                                 LLVMValueRef *values,<br class="gmail_msg">
>>                                 unsigned value_count,<br class="gmail_msg">
>>                                 unsigned value_stride,<br class="gmail_msg">
>>                                 bool load)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMBuilderRef builder = ctx->builder;<br class="gmail_msg">
>> @@ -524,21 +527,22 @@ ac_build_tbuffer_store(struct ac_llvm_context *ctx,<br class="gmail_msg">
>>         /* The instruction offset field has 12 bits */<br class="gmail_msg">
>>         assert(offen || inst_offset < (1 << 12));<br class="gmail_msg">
>><br class="gmail_msg">
>>         /* The intrinsic is overloaded, we need to add a type suffix for<br class="gmail_msg">
>> overloading to work. */<br class="gmail_msg">
>>         unsigned func = CLAMP(num_channels, 1, 3) - 1;<br class="gmail_msg">
>>         const char *types[] = {"i32", "v2i32", "v4i32"};<br class="gmail_msg">
>>         char name[256];<br class="gmail_msg">
>>         snprintf(name, sizeof(name), "llvm.SI.tbuffer.store.%s",<br class="gmail_msg">
>> types[func]);<br class="gmail_msg">
>><br class="gmail_msg">
>>         ac_emit_llvm_intrinsic(ctx, name, ctx->voidt,<br class="gmail_msg">
>> -                              args, ARRAY_SIZE(args), 0);<br class="gmail_msg">
>> +                              args, ARRAY_SIZE(args),<br class="gmail_msg">
>> +                              AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  void<br class="gmail_msg">
>>  ac_build_tbuffer_store_dwords(struct ac_llvm_context *ctx,<br class="gmail_msg">
>>                               LLVMValueRef rsrc,<br class="gmail_msg">
>>                               LLVMValueRef vdata,<br class="gmail_msg">
>>                               unsigned num_channels,<br class="gmail_msg">
>>                               LLVMValueRef vaddr,<br class="gmail_msg">
>>                               LLVMValueRef soffset,<br class="gmail_msg">
>>                               unsigned inst_offset)<br class="gmail_msg">
>> @@ -836,12 +840,13 @@ LLVMValueRef ac_emit_clamp(struct ac_llvm_context<br class="gmail_msg">
>> *ctx, LLVMValueRef value)<br class="gmail_msg">
>><br class="gmail_msg">
>>         const char *intr = HAVE_LLVM >= 0x0308 ? "llvm.AMDGPU.clamp." :<br class="gmail_msg">
>>                                                  "llvm.AMDIL.clamp.";<br class="gmail_msg">
>>         LLVMValueRef args[3] = {<br class="gmail_msg">
>>                 value,<br class="gmail_msg">
>>                 LLVMConstReal(ctx->f32, 0),<br class="gmail_msg">
>>                 LLVMConstReal(ctx->f32, 1),<br class="gmail_msg">
>>         };<br class="gmail_msg">
>><br class="gmail_msg">
>>         return ac_emit_llvm_intrinsic(ctx, intr, ctx->f32, args, 3,<br class="gmail_msg">
>> -                                     AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>> +                                     AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> +                                     AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>> diff --git a/src/amd/common/ac_llvm_util.c b/src/amd/common/ac_llvm_util.c<br class="gmail_msg">
>> index be127c5..fb525dd 100644<br class="gmail_msg">
>> --- a/src/amd/common/ac_llvm_util.c<br class="gmail_msg">
>> +++ b/src/amd/common/ac_llvm_util.c<br class="gmail_msg">
>> @@ -17,21 +17,21 @@<br class="gmail_msg">
>>   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR<br class="gmail_msg">
>> THE<br class="gmail_msg">
>>   * USE OR OTHER DEALINGS IN THE SOFTWARE.<br class="gmail_msg">
>>   *<br class="gmail_msg">
>>   * The above copyright notice and this permission notice (including the<br class="gmail_msg">
>>   * next paragraph) shall be included in all copies or substantial<br class="gmail_msg">
>> portions<br class="gmail_msg">
>>   * of the Software.<br class="gmail_msg">
>>   *<br class="gmail_msg">
>>   */<br class="gmail_msg">
>>  /* based on pieces from si_pipe.c and radeon_llvm_emit.c */<br class="gmail_msg">
>>  #include "ac_llvm_util.h"<br class="gmail_msg">
>> -<br class="gmail_msg">
>> +#include "util/bitscan.h"<br class="gmail_msg">
>>  #include <llvm-c/Core.h><br class="gmail_msg">
>><br class="gmail_msg">
>>  #include "c11/threads.h"<br class="gmail_msg">
>><br class="gmail_msg">
>>  #include <assert.h><br class="gmail_msg">
>>  #include <stdio.h><br class="gmail_msg">
>>  #include <string.h><br class="gmail_msg">
>><br class="gmail_msg">
>>  static void ac_init_llvm_target()<br class="gmail_msg">
>>  {<br class="gmail_msg">
>> @@ -173,40 +173,53 @@ static const char *attr_to_str(enum ac_func_attr<br class="gmail_msg">
>> attr)<br class="gmail_msg">
>>     case AC_FUNC_ATTR_READNONE: return "readnone";<br class="gmail_msg">
>>     case AC_FUNC_ATTR_READONLY: return "readonly";<br class="gmail_msg">
>>     default:<br class="gmail_msg">
>>            fprintf(stderr, "Unhandled function attribute: %x\n", attr);<br class="gmail_msg">
>>            return 0;<br class="gmail_msg">
>>     }<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  #endif<br class="gmail_msg">
>><br class="gmail_msg">
>> -void<br class="gmail_msg">
>> -ac_add_function_attr(LLVMValueRef function,<br class="gmail_msg">
>> -                     int attr_idx,<br class="gmail_msg">
>> -                     enum ac_func_attr attr)<br class="gmail_msg">
>> +static void<br class="gmail_msg">
>> +ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,<br class="gmail_msg">
>> +                     int attr_idx, enum ac_func_attr attr)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>> -<br class="gmail_msg">
>>  #if HAVE_LLVM < 0x0400<br class="gmail_msg">
>>     LLVMAttribute llvm_attr = ac_attr_to_llvm_attr(attr);<br class="gmail_msg">
>>     if (attr_idx == -1) {<br class="gmail_msg">
>>        LLVMAddFunctionAttr(function, llvm_attr);<br class="gmail_msg">
>>     } else {<br class="gmail_msg">
>>        LLVMAddAttribute(LLVMGetParam(function, attr_idx - 1), llvm_attr);<br class="gmail_msg">
>>     }<br class="gmail_msg">
>>  #else<br class="gmail_msg">
>> -   LLVMContextRef context =<br class="gmail_msg">
>> LLVMGetModuleContext(LLVMGetGlobalParent(function));<br class="gmail_msg">
>>     const char *attr_name = attr_to_str(attr);<br class="gmail_msg">
>>     unsigned kind_id = LLVMGetEnumAttributeKindForName(attr_name,<br class="gmail_msg">
>>                                                        strlen(attr_name));<br class="gmail_msg">
>> -   LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(context, kind_id,<br class="gmail_msg">
>> 0);<br class="gmail_msg">
>> -   LLVMAddAttributeAtIndex(function, attr_idx, llvm_attr);<br class="gmail_msg">
>> +   LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(ctx, kind_id, 0);<br class="gmail_msg">
>> +<br class="gmail_msg">
>> +   if (LLVMIsAFunction(function))<br class="gmail_msg">
>> +      LLVMAddAttributeAtIndex(function, attr_idx, llvm_attr);<br class="gmail_msg">
>> +   else<br class="gmail_msg">
>> +      LLVMAddCallSiteAttribute(function, attr_idx, llvm_attr);<br class="gmail_msg">
>>  #endif<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>> +void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,<br class="gmail_msg">
>> +                           unsigned attrib_mask)<br class="gmail_msg">
>> +{<br class="gmail_msg">
>> +       attrib_mask |= AC_FUNC_ATTR_NOUNWIND;<br class="gmail_msg">
>> +       attrib_mask &= ~AC_FUNC_ATTR_LEGACY;<br class="gmail_msg">
>> +<br class="gmail_msg">
>> +       while (attrib_mask) {<br class="gmail_msg">
>> +               enum ac_func_attr attr = 1u << u_bit_scan(&attrib_mask);<br class="gmail_msg">
>> +               ac_add_function_attr(ctx, function, -1, attr);<br class="gmail_msg">
>> +       }<br class="gmail_msg">
>> +}<br class="gmail_msg">
>> +<br class="gmail_msg">
>>  void<br class="gmail_msg">
>>  ac_dump_module(LLVMModuleRef module)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         char *str = LLVMPrintModuleToString(module);<br class="gmail_msg">
>>         fprintf(stderr, "%s", str);<br class="gmail_msg">
>>         LLVMDisposeMessage(str);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>> diff --git a/src/amd/common/ac_llvm_util.h b/src/amd/common/ac_llvm_util.h<br class="gmail_msg">
>> index 93d3d27..4fe4ab4 100644<br class="gmail_msg">
>> --- a/src/amd/common/ac_llvm_util.h<br class="gmail_msg">
>> +++ b/src/amd/common/ac_llvm_util.h<br class="gmail_msg">
>> @@ -34,28 +34,29 @@ extern "C" {<br class="gmail_msg">
>>  #endif<br class="gmail_msg">
>><br class="gmail_msg">
>>  enum ac_func_attr {<br class="gmail_msg">
>>         AC_FUNC_ATTR_ALWAYSINLINE = (1 << 0),<br class="gmail_msg">
>>         AC_FUNC_ATTR_BYVAL        = (1 << 1),<br class="gmail_msg">
>>         AC_FUNC_ATTR_INREG        = (1 << 2),<br class="gmail_msg">
>>         AC_FUNC_ATTR_NOALIAS      = (1 << 3),<br class="gmail_msg">
>>         AC_FUNC_ATTR_NOUNWIND     = (1 << 4),<br class="gmail_msg">
>>         AC_FUNC_ATTR_READNONE     = (1 << 5),<br class="gmail_msg">
>>         AC_FUNC_ATTR_READONLY     = (1 << 6),<br class="gmail_msg">
>> +<br class="gmail_msg">
>> +       /* Legacy intrinsic that needs attributes on function declarations<br class="gmail_msg">
>> +        * and they must match the internal LLVM definition exactly,<br class="gmail_msg">
>> otherwise<br class="gmail_msg">
>> +        * intrinsic selection fails.<br class="gmail_msg">
>> +        */<br class="gmail_msg">
>> +       AC_FUNC_ATTR_LEGACY       = (1u << 31),<br class="gmail_msg">
>>  };<br class="gmail_msg">
>><br class="gmail_msg">
>>  LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family,<br class="gmail_msg">
>> bool supports_spill);<br class="gmail_msg">
>><br class="gmail_msg">
>>  void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);<br class="gmail_msg">
>>  bool ac_is_sgpr_param(LLVMValueRef param);<br class="gmail_msg">
>> -<br class="gmail_msg">
>> -void<br class="gmail_msg">
>> -ac_add_function_attr(LLVMValueRef function,<br class="gmail_msg">
>> -                     int attr_idx,<br class="gmail_msg">
>> -                     enum ac_func_attr attr);<br class="gmail_msg">
>> -<br class="gmail_msg">
>> -void<br class="gmail_msg">
>> -ac_dump_module(LLVMModuleRef module);<br class="gmail_msg">
>> +void ac_add_func_attributes(LLVMContextRef ctx, LLVMValueRef function,<br class="gmail_msg">
>> +                           unsigned attrib_mask);<br class="gmail_msg">
>> +void ac_dump_module(LLVMModuleRef module);<br class="gmail_msg">
>><br class="gmail_msg">
>>  #ifdef __cplusplus<br class="gmail_msg">
>>  }<br class="gmail_msg">
>>  #endif<br class="gmail_msg">
>> diff --git a/src/amd/common/ac_nir_to_llvm.c<br class="gmail_msg">
>> b/src/amd/common/ac_nir_to_llvm.c<br class="gmail_msg">
>> index b3dc63c..4ec19d5 100644<br class="gmail_msg">
>> --- a/src/amd/common/ac_nir_to_llvm.c<br class="gmail_msg">
>> +++ b/src/amd/common/ac_nir_to_llvm.c<br class="gmail_msg">
>> @@ -1039,26 +1039,27 @@ static LLVMValueRef emit_imul_high(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>         src0 = LLVMBuildSExt(ctx->builder, src0, ctx->i64, "");<br class="gmail_msg">
>>         src1 = LLVMBuildSExt(ctx->builder, src1, ctx->i64, "");<br class="gmail_msg">
>><br class="gmail_msg">
>>         dst64 = LLVMBuildMul(ctx->builder, src0, src1, "");<br class="gmail_msg">
>>         dst64 = LLVMBuildAShr(ctx->builder, dst64, LLVMConstInt(ctx->i64,<br class="gmail_msg">
>> 32, false), "");<br class="gmail_msg">
>>         result = LLVMBuildTrunc(ctx->builder, dst64, ctx->i32, "");<br class="gmail_msg">
>>         return result;<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static LLVMValueRef emit_bitfield_extract(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx,<br class="gmail_msg">
>> -                                         const char *intrin,<br class="gmail_msg">
>> +                                         const char *intrin, unsigned<br class="gmail_msg">
>> attr_mask,<br class="gmail_msg">
>>                                           LLVMValueRef srcs[3])<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMValueRef result;<br class="gmail_msg">
>>         LLVMValueRef icond = LLVMBuildICmp(ctx->builder, LLVMIntEQ,<br class="gmail_msg">
>> srcs[2], LLVMConstInt(ctx->i32, 32, false), "");<br class="gmail_msg">
>> -       result = ac_emit_llvm_intrinsic(&ctx->ac, intrin, ctx->i32, srcs,<br class="gmail_msg">
>> 3, AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>> +       result = ac_emit_llvm_intrinsic(&ctx->ac, intrin, ctx->i32, srcs,<br class="gmail_msg">
>> 3,<br class="gmail_msg">
>> +                                       AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> attr_mask);<br class="gmail_msg">
>><br class="gmail_msg">
>>         result = LLVMBuildSelect(ctx->builder, icond, srcs[0], result,<br class="gmail_msg">
>> "");<br class="gmail_msg">
>>         return result;<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static LLVMValueRef emit_bitfield_insert(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                                          LLVMValueRef src0, LLVMValueRef<br class="gmail_msg">
>> src1,<br class="gmail_msg">
>>                                          LLVMValueRef src2, LLVMValueRef<br class="gmail_msg">
>> src3)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMValueRef bfi_args[3], result;<br class="gmail_msg">
>> @@ -1418,24 +1419,26 @@ static void visit_alu(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx, nir_alu_instr *instr)<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_fmin:<br class="gmail_msg">
>>                 result = emit_intrin_2f_param(ctx, "llvm.minnum",<br class="gmail_msg">
>>                                               to_float_type(ctx,<br class="gmail_msg">
>> def_type), src[0], src[1]);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_ffma:<br class="gmail_msg">
>>                 result = emit_intrin_3f_param(ctx, "llvm.fma",<br class="gmail_msg">
>>                                               to_float_type(ctx,<br class="gmail_msg">
>> def_type), src[0], src[1], src[2]);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_ibitfield_extract:<br class="gmail_msg">
>> -               result = emit_bitfield_extract(ctx, "llvm.AMDGPU.bfe.i32",<br class="gmail_msg">
>> src);<br class="gmail_msg">
>> +               result = emit_bitfield_extract(ctx, "llvm.AMDGPU.bfe.i32",<br class="gmail_msg">
>> +                                              AC_FUNC_ATTR_LEGACY, src);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_ubitfield_extract:<br class="gmail_msg">
>> -               result = emit_bitfield_extract(ctx, "llvm.AMDGPU.bfe.u32",<br class="gmail_msg">
>> src);<br class="gmail_msg">
>> +               result = emit_bitfield_extract(ctx, "llvm.AMDGPU.bfe.u32",<br class="gmail_msg">
>> +                                              AC_FUNC_ATTR_LEGACY, src);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_bitfield_insert:<br class="gmail_msg">
>>                 result = emit_bitfield_insert(ctx, src[0], src[1], src[2],<br class="gmail_msg">
>> src[3]);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_bitfield_reverse:<br class="gmail_msg">
>>                 result = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>> "llvm.bitreverse.i32", ctx->i32, src, 1, AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_op_bit_count:<br class="gmail_msg">
>>                 result = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>> "llvm.ctpop.i32", ctx->i32, src, 1, AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>> @@ -1635,22 +1638,23 @@ static LLVMValueRef<br class="gmail_msg">
>> radv_lower_gather4_integer(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = tinfo->args[1];<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0xf,<br class="gmail_msg">
>> 0); /* dmask */<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0, 0);<br class="gmail_msg">
>> /* unorm */<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0, 0);<br class="gmail_msg">
>> /* r128 */<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, da ? 1<br class="gmail_msg">
>> : 0, 0);<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0, 0);<br class="gmail_msg">
>> /* glc */<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0, 0);<br class="gmail_msg">
>> /* slc */<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0, 0);<br class="gmail_msg">
>> /* tfe */<br class="gmail_msg">
>>                 txq_args[txq_arg_count++] = LLVMConstInt(ctx->i32, 0, 0);<br class="gmail_msg">
>> /* lwe */<br class="gmail_msg">
>>                 size = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>> "llvm.SI.getresinfo.i32", ctx->v4i32,<br class="gmail_msg">
>> -                                          txq_args, txq_arg_count,<br class="gmail_msg">
>> -                                          AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>> +                                             txq_args, txq_arg_count,<br class="gmail_msg">
>> +                                             AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> +                                             AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>                 for (c = 0; c < 2; c++) {<br class="gmail_msg">
>>                         half_texel[c] =<br class="gmail_msg">
>> LLVMBuildExtractElement(ctx->builder, size,<br class="gmail_msg">
>><br class="gmail_msg">
>> LLVMConstInt(ctx->i32, c, false), "");<br class="gmail_msg">
>>                         half_texel[c] = LLVMBuildUIToFP(ctx->builder,<br class="gmail_msg">
>> half_texel[c], ctx->f32, "");<br class="gmail_msg">
>>                         half_texel[c] = ac_emit_fdiv(&ctx->ac,<br class="gmail_msg">
>> ctx->f32one, half_texel[c]);<br class="gmail_msg">
>>                         half_texel[c] = LLVMBuildFMul(ctx->builder,<br class="gmail_msg">
>> half_texel[c],<br class="gmail_msg">
>><br class="gmail_msg">
>> LLVMConstReal(ctx->f32, -0.5), "");<br class="gmail_msg">
>>                 }<br class="gmail_msg">
>>         }<br class="gmail_msg">
>> @@ -1660,21 +1664,22 @@ static LLVMValueRef<br class="gmail_msg">
>> radv_lower_gather4_integer(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                 LLVMValueRef index = LLVMConstInt(ctx->i32,<br class="gmail_msg">
>> coord_vgpr_index + c, 0);<br class="gmail_msg">
>>                 tmp = LLVMBuildExtractElement(ctx->builder, coord, index,<br class="gmail_msg">
>> "");<br class="gmail_msg">
>>                 tmp = LLVMBuildBitCast(ctx->builder, tmp, ctx->f32, "");<br class="gmail_msg">
>>                 tmp = LLVMBuildFAdd(ctx->builder, tmp, half_texel[c], "");<br class="gmail_msg">
>>                 tmp = LLVMBuildBitCast(ctx->builder, tmp, ctx->i32, "");<br class="gmail_msg">
>>                 coord = LLVMBuildInsertElement(ctx->builder, coord, tmp,<br class="gmail_msg">
>> index, "");<br class="gmail_msg">
>>         }<br class="gmail_msg">
>><br class="gmail_msg">
>>         tinfo->args[0] = coord;<br class="gmail_msg">
>>         return ac_emit_llvm_intrinsic(&ctx->ac, intr_name,<br class="gmail_msg">
>> tinfo->dst_type, tinfo->args, tinfo->arg_count,<br class="gmail_msg">
>> -                                  AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> AC_FUNC_ATTR_NOUNWIND);<br class="gmail_msg">
>> +                                     AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> AC_FUNC_ATTR_NOUNWIND |<br class="gmail_msg">
>> +                                     AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static LLVMValueRef build_tex_intrinsic(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                                         nir_tex_instr *instr,<br class="gmail_msg">
>>                                         struct ac_tex_info *tinfo)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         const char *name = "llvm.SI.image.sample";<br class="gmail_msg">
>>         const char *infix = "";<br class="gmail_msg">
>>         char intr_name[127];<br class="gmail_msg">
>> @@ -1728,21 +1733,22 @@ static LLVMValueRef build_tex_intrinsic(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                 has_offset ? ".o" : "", type);<br class="gmail_msg">
>><br class="gmail_msg">
>>         if (instr->op == nir_texop_tg4) {<br class="gmail_msg">
>>                 enum glsl_base_type stype =<br class="gmail_msg">
>> glsl_get_sampler_result_type(instr->texture->var->type);<br class="gmail_msg">
>>                 if (stype == GLSL_TYPE_UINT || stype == GLSL_TYPE_INT) {<br class="gmail_msg">
>>                         return radv_lower_gather4_integer(ctx, tinfo,<br class="gmail_msg">
>> instr, intr_name,<br class="gmail_msg">
>>                                                           (int)has_offset<br class="gmail_msg">
>> + (int)is_shadow);<br class="gmail_msg">
>>                 }<br class="gmail_msg">
>>         }<br class="gmail_msg">
>>         return ac_emit_llvm_intrinsic(&ctx->ac, intr_name,<br class="gmail_msg">
>> tinfo->dst_type, tinfo->args, tinfo->arg_count,<br class="gmail_msg">
>> -                                  AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> AC_FUNC_ATTR_NOUNWIND);<br class="gmail_msg">
>> +                                     AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> AC_FUNC_ATTR_NOUNWIND |<br class="gmail_msg">
>> +                                     AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static LLVMValueRef visit_vulkan_resource_index(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                                                  nir_intrinsic_instr<br class="gmail_msg">
>> *instr)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMValueRef index = get_src(ctx, instr->src[0]);<br class="gmail_msg">
>>         unsigned desc_set = nir_intrinsic_desc_set(instr);<br class="gmail_msg">
>>         unsigned binding = nir_intrinsic_binding(instr);<br class="gmail_msg">
>>         LLVMValueRef desc_ptr = ctx->descriptor_sets[desc_set];<br class="gmail_msg">
>> @@ -2006,21 +2012,23 @@ static LLVMValueRef visit_load_ubo_buffer(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>         if (instr->dest.ssa.bit_size == 64)<br class="gmail_msg">
>>                 num_components *= 2;<br class="gmail_msg">
>><br class="gmail_msg">
>>         for (unsigned i = 0; i < num_components; ++i) {<br class="gmail_msg">
>>                 LLVMValueRef params[] = {<br class="gmail_msg">
>>                         rsrc,<br class="gmail_msg">
>>                         LLVMBuildAdd(ctx->builder, LLVMConstInt(ctx->i32,<br class="gmail_msg">
>> 4 * i, 0),<br class="gmail_msg">
>>                                      offset, "")<br class="gmail_msg">
>>                 };<br class="gmail_msg">
>>                 results[i] = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>> "llvm.SI.load.const", ctx->f32,<br class="gmail_msg">
>> -                                                params, 2,<br class="gmail_msg">
>> AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>> +                                                   params, 2,<br class="gmail_msg">
>> +                                                   AC_FUNC_ATTR_READNONE<br class="gmail_msg">
>> |<br class="gmail_msg">
>> +                                                   AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>         }<br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>>         ret = ac_build_gather_values(&ctx->ac, results,<br class="gmail_msg">
>> instr->num_components);<br class="gmail_msg">
>>         return LLVMBuildBitCast(ctx->builder, ret,<br class="gmail_msg">
>>                                 get_def_type(ctx, &instr->dest.ssa), "");<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static void<br class="gmail_msg">
>>  radv_get_deref_offset(struct nir_to_llvm_context *ctx, nir_deref *tail,<br class="gmail_msg">
>> @@ -2103,21 +2111,23 @@ load_gs_input(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                 args[1] = vtx_offset;<br class="gmail_msg">
>>                 args[2] = LLVMConstInt(ctx->i32, (param * 4 + i +<br class="gmail_msg">
>> const_index) * 256, false);<br class="gmail_msg">
>>                 args[3] = ctx->i32zero;<br class="gmail_msg">
>>                 args[4] = ctx->i32one; /* OFFEN */<br class="gmail_msg">
>>                 args[5] = ctx->i32zero; /* IDXEN */<br class="gmail_msg">
>>                 args[6] = ctx->i32one; /* GLC */<br class="gmail_msg">
>>                 args[7] = ctx->i32zero; /* SLC */<br class="gmail_msg">
>>                 args[8] = ctx->i32zero; /* TFE */<br class="gmail_msg">
>><br class="gmail_msg">
>>                 value[i] = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>> "llvm.SI.buffer.load.dword.i32.i32",<br class="gmail_msg">
>> -                                           ctx->i32, args, 9,<br class="gmail_msg">
>> AC_FUNC_ATTR_READONLY);<br class="gmail_msg">
>> +                                                 ctx->i32, args, 9,<br class="gmail_msg">
>> +                                                 AC_FUNC_ATTR_READONLY |<br class="gmail_msg">
>> +                                                 AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>         }<br class="gmail_msg">
>>         result = ac_build_gather_values(&ctx->ac, value,<br class="gmail_msg">
>> instr->num_components);<br class="gmail_msg">
>><br class="gmail_msg">
>>         return result;<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static LLVMValueRef visit_load_var(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                                    nir_intrinsic_instr *instr)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMValueRef values[8];<br class="gmail_msg">
>> @@ -2685,21 +2695,23 @@ static LLVMValueRef visit_image_size(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>         params[2] = LLVMConstInt(ctx->i32, 15, false);<br class="gmail_msg">
>>         params[3] = ctx->i32zero;<br class="gmail_msg">
>>         params[4] = ctx->i32zero;<br class="gmail_msg">
>>         params[5] = da ? ctx->i32one : ctx->i32zero;<br class="gmail_msg">
>>         params[6] = ctx->i32zero;<br class="gmail_msg">
>>         params[7] = ctx->i32zero;<br class="gmail_msg">
>>         params[8] = ctx->i32zero;<br class="gmail_msg">
>>         params[9] = ctx->i32zero;<br class="gmail_msg">
>><br class="gmail_msg">
>>         res = ac_emit_llvm_intrinsic(&ctx->ac, "llvm.SI.getresinfo.i32",<br class="gmail_msg">
>> ctx->v4i32,<br class="gmail_msg">
>> -                                 params, 10, AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>> +                                    params, 10,<br class="gmail_msg">
>> +                                    AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> +                                    AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>         if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE &&<br class="gmail_msg">
>>             glsl_sampler_type_is_array(type)) {<br class="gmail_msg">
>>                 LLVMValueRef two = LLVMConstInt(ctx->i32, 2, false);<br class="gmail_msg">
>>                 LLVMValueRef six = LLVMConstInt(ctx->i32, 6, false);<br class="gmail_msg">
>>                 LLVMValueRef z = LLVMBuildExtractElement(ctx->builder,<br class="gmail_msg">
>> res, two, "");<br class="gmail_msg">
>>                 z = LLVMBuildSDiv(ctx->builder, z, six, "");<br class="gmail_msg">
>>                 res = LLVMBuildInsertElement(ctx->builder, res, z, two,<br class="gmail_msg">
>> "");<br class="gmail_msg">
>>         }<br class="gmail_msg">
>>         return res;<br class="gmail_msg">
>> @@ -2729,21 +2741,21 @@ static void emit_discard_if(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>><br class="gmail_msg">
>>         cond = LLVMBuildICmp(ctx->builder, LLVMIntNE,<br class="gmail_msg">
>>                              get_src(ctx, instr->src[0]),<br class="gmail_msg">
>>                              ctx->i32zero, "");<br class="gmail_msg">
>><br class="gmail_msg">
>>         cond = LLVMBuildSelect(ctx->builder, cond,<br class="gmail_msg">
>>                                LLVMConstReal(ctx->f32, -1.0f),<br class="gmail_msg">
>>                                ctx->f32zero, "");<br class="gmail_msg">
>>         ac_emit_llvm_intrinsic(&ctx->ac, "llvm.AMDGPU.kill",<br class="gmail_msg">
>>                                ctx->voidt,<br class="gmail_msg">
>> -                              &cond, 1, 0);<br class="gmail_msg">
>> +                              &cond, 1, AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static LLVMValueRef<br class="gmail_msg">
>>  visit_load_local_invocation_index(struct nir_to_llvm_context *ctx)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMValueRef result;<br class="gmail_msg">
>>         LLVMValueRef thread_id = ac_get_thread_id(&ctx->ac);<br class="gmail_msg">
>>         result = LLVMBuildAnd(ctx->builder, ctx->tg_size,<br class="gmail_msg">
>>                               LLVMConstInt(ctx->i32, 0xfc0, false), "");<br class="gmail_msg">
>><br class="gmail_msg">
>> @@ -2984,21 +2996,21 @@ visit_emit_vertex(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>          * have any effect, and GS threads have no externally observable<br class="gmail_msg">
>>          * effects other than emitting vertices.<br class="gmail_msg">
>>          */<br class="gmail_msg">
>>         can_emit = LLVMBuildICmp(ctx->builder, LLVMIntULT, gs_next_vertex,<br class="gmail_msg">
>>                                  LLVMConstInt(ctx->i32,<br class="gmail_msg">
>> ctx->gs_max_out_vertices, false), "");<br class="gmail_msg">
>><br class="gmail_msg">
>>         kill = LLVMBuildSelect(ctx->builder, can_emit,<br class="gmail_msg">
>>                                LLVMConstReal(ctx->f32, 1.0f),<br class="gmail_msg">
>>                                LLVMConstReal(ctx->f32, -1.0f), "");<br class="gmail_msg">
>>         ac_emit_llvm_intrinsic(&ctx->ac, "llvm.AMDGPU.kill",<br class="gmail_msg">
>> -                           ctx->voidt, &kill, 1, 0);<br class="gmail_msg">
>> +                           ctx->voidt, &kill, 1, AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>         /* loop num outputs */<br class="gmail_msg">
>>         idx = 0;<br class="gmail_msg">
>>         for (unsigned i = 0; i < RADEON_LLVM_MAX_OUTPUTS; ++i) {<br class="gmail_msg">
>>                 LLVMValueRef *out_ptr = &ctx->outputs[i * 4];<br class="gmail_msg">
>>                 if (!(ctx->output_mask & (1ull << i)))<br class="gmail_msg">
>>                         continue;<br class="gmail_msg">
>><br class="gmail_msg">
>>                 for (unsigned j = 0; j < 4; j++) {<br class="gmail_msg">
>>                         LLVMValueRef out_val = LLVMBuildLoad(ctx->builder,<br class="gmail_msg">
>> @@ -3144,21 +3156,21 @@ static void visit_intrinsic(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>         case nir_intrinsic_image_atomic_comp_swap:<br class="gmail_msg">
>>                 result = visit_image_atomic(ctx, instr);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_intrinsic_image_size:<br class="gmail_msg">
>>                 result = visit_image_size(ctx, instr);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_intrinsic_discard:<br class="gmail_msg">
>>                 ctx->shader_info->fs.can_discard = true;<br class="gmail_msg">
>>                 ac_emit_llvm_intrinsic(&ctx->ac, "llvm.AMDGPU.kilp",<br class="gmail_msg">
>>                                        ctx->voidt,<br class="gmail_msg">
>> -                                      NULL, 0, 0);<br class="gmail_msg">
>> +                                      NULL, 0, AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_intrinsic_discard_if:<br class="gmail_msg">
>>                 emit_discard_if(ctx, instr);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_intrinsic_memory_barrier:<br class="gmail_msg">
>>                 emit_waitcnt(ctx);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>>         case nir_intrinsic_barrier:<br class="gmail_msg">
>>                 emit_barrier(ctx);<br class="gmail_msg">
>>                 break;<br class="gmail_msg">
>> @@ -3924,21 +3936,22 @@ handle_vs_input_decl(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx,<br class="gmail_msg">
>><br class="gmail_msg">
>>         for (unsigned i = 0; i < attrib_count; ++i, ++idx) {<br class="gmail_msg">
>>                 t_offset = LLVMConstInt(ctx->i32, index + i, false);<br class="gmail_msg">
>><br class="gmail_msg">
>>                 t_list = ac_build_indexed_load_const(&ctx->ac, t_list_ptr,<br class="gmail_msg">
>> t_offset);<br class="gmail_msg">
>>                 args[0] = t_list;<br class="gmail_msg">
>>                 args[1] = LLVMConstInt(ctx->i32, 0, false);<br class="gmail_msg">
>>                 args[2] = buffer_index;<br class="gmail_msg">
>>                 input = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>>                         "llvm.SI.vs.load.input", ctx->v4f32, args, 3,<br class="gmail_msg">
>> -                       AC_FUNC_ATTR_READNONE | AC_FUNC_ATTR_NOUNWIND);<br class="gmail_msg">
>> +                       AC_FUNC_ATTR_READNONE | AC_FUNC_ATTR_NOUNWIND |<br class="gmail_msg">
>> +                       AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>                 for (unsigned chan = 0; chan < 4; chan++) {<br class="gmail_msg">
>>                         LLVMValueRef llvm_chan = LLVMConstInt(ctx->i32,<br class="gmail_msg">
>> chan, false);<br class="gmail_msg">
>>                         ctx->inputs[radeon_llvm_reg_index_soa(idx, chan)]<br class="gmail_msg">
>> =<br class="gmail_msg">
>>                                 to_integer(ctx,<br class="gmail_msg">
>> LLVMBuildExtractElement(ctx->builder,<br class="gmail_msg">
>>                                                         input, llvm_chan,<br class="gmail_msg">
>> ""));<br class="gmail_msg">
>>                 }<br class="gmail_msg">
>>         }<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>> @@ -4257,22 +4270,23 @@ si_llvm_init_export_args(struct<br class="gmail_msg">
>> nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                         args[4] = ctx->i32one;<br class="gmail_msg">
>><br class="gmail_msg">
>>                         for (unsigned chan = 0; chan < 2; chan++) {<br class="gmail_msg">
>>                                 LLVMValueRef pack_args[2] = {<br class="gmail_msg">
>>                                         values[2 * chan],<br class="gmail_msg">
>>                                         values[2 * chan + 1]<br class="gmail_msg">
>>                                 };<br class="gmail_msg">
>>                                 LLVMValueRef packed;<br class="gmail_msg">
>><br class="gmail_msg">
>>                                 packed = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>> "llvm.SI.packf16",<br class="gmail_msg">
>> -                                                            ctx->i32,<br class="gmail_msg">
>> pack_args, 2,<br class="gmail_msg">
>> -<br class="gmail_msg">
>> AC_FUNC_ATTR_READNONE);<br class="gmail_msg">
>> +                                                               ctx->i32,<br class="gmail_msg">
>> pack_args, 2,<br class="gmail_msg">
>> +<br class="gmail_msg">
>> AC_FUNC_ATTR_READNONE |<br class="gmail_msg">
>> +<br class="gmail_msg">
>> AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>                                 args[chan + 5] = packed;<br class="gmail_msg">
>>                         }<br class="gmail_msg">
>>                         break;<br class="gmail_msg">
>><br class="gmail_msg">
>>                 case V_028714_SPI_SHADER_UNORM16_ABGR:<br class="gmail_msg">
>>                         for (unsigned chan = 0; chan < 4; chan++) {<br class="gmail_msg">
>>                                 val[chan] = emit_float_saturate(ctx,<br class="gmail_msg">
>> values[chan], 0, 1);<br class="gmail_msg">
>>                                 val[chan] = LLVMBuildFMul(ctx->builder,<br class="gmail_msg">
>> val[chan],<br class="gmail_msg">
>><br class="gmail_msg">
>> LLVMConstReal(ctx->f32, 65535), "");<br class="gmail_msg">
>>                                 val[chan] = LLVMBuildFAdd(ctx->builder,<br class="gmail_msg">
>> val[chan],<br class="gmail_msg">
>> @@ -4443,21 +4457,22 @@ handle_vs_outputs_post(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx)<br class="gmail_msg">
>>                 si_llvm_init_export_args(ctx, values, target, args);<br class="gmail_msg">
>><br class="gmail_msg">
>>                 if (target >= V_008DFC_SQ_EXP_POS &&<br class="gmail_msg">
>>                     target <= (V_008DFC_SQ_EXP_POS + 3)) {<br class="gmail_msg">
>>                         memcpy(pos_args[target - V_008DFC_SQ_EXP_POS],<br class="gmail_msg">
>>                                args, sizeof(args));<br class="gmail_msg">
>>                 } else {<br class="gmail_msg">
>>                         ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>>                                                "llvm.SI.export",<br class="gmail_msg">
>>                                                ctx->voidt,<br class="gmail_msg">
>> -                                              args, 9, 0);<br class="gmail_msg">
>> +                                              args, 9,<br class="gmail_msg">
>> +                                              AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>                 }<br class="gmail_msg">
>>         }<br class="gmail_msg">
>><br class="gmail_msg">
>>         /* We need to add the position output manually if it's missing. */<br class="gmail_msg">
>>         if (!pos_args[0][0]) {<br class="gmail_msg">
>>                 pos_args[0][0] = LLVMConstInt(ctx->i32, 0xf, false);<br class="gmail_msg">
>>                 pos_args[0][1] = ctx->i32zero; /* EXEC mask */<br class="gmail_msg">
>>                 pos_args[0][2] = ctx->i32zero; /* last export? */<br class="gmail_msg">
>>                 pos_args[0][3] = LLVMConstInt(ctx->i32,<br class="gmail_msg">
>> V_008DFC_SQ_EXP_POS, false);<br class="gmail_msg">
>>                 pos_args[0][4] = ctx->i32zero; /* COMPR flag */<br class="gmail_msg">
>> @@ -4498,21 +4513,22 @@ handle_vs_outputs_post(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx)<br class="gmail_msg">
>>                 if (!pos_args[i][0])<br class="gmail_msg">
>>                         continue;<br class="gmail_msg">
>><br class="gmail_msg">
>>                 /* Specify the target we are exporting */<br class="gmail_msg">
>>                 pos_args[i][3] = LLVMConstInt(ctx->i32,<br class="gmail_msg">
>> V_008DFC_SQ_EXP_POS + pos_idx++, false);<br class="gmail_msg">
>>                 if (pos_idx == num_pos_exports)<br class="gmail_msg">
>>                         pos_args[i][2] = ctx->i32one;<br class="gmail_msg">
>>                 ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>>                                        "llvm.SI.export",<br class="gmail_msg">
>>                                        ctx->voidt,<br class="gmail_msg">
>> -                                      pos_args[i], 9, 0);<br class="gmail_msg">
>> +                                      pos_args[i], 9,<br class="gmail_msg">
>> +                                      AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>         }<br class="gmail_msg">
>><br class="gmail_msg">
>>         ctx->shader_info->vs.pos_exports = num_pos_exports;<br class="gmail_msg">
>>         ctx->shader_info->vs.param_exports = param_count;<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static void<br class="gmail_msg">
>>  handle_es_outputs_post(struct nir_to_llvm_context *ctx)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         int j;<br class="gmail_msg">
>> @@ -4554,21 +4570,22 @@ si_export_mrt_color(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx,<br class="gmail_msg">
>>         si_llvm_init_export_args(ctx, color, param,<br class="gmail_msg">
>>                                  args);<br class="gmail_msg">
>><br class="gmail_msg">
>>         if (is_last) {<br class="gmail_msg">
>>                 args[1] = ctx->i32one; /* whether the EXEC mask is valid<br class="gmail_msg">
>> */<br class="gmail_msg">
>>                 args[2] = ctx->i32one; /* DONE bit */<br class="gmail_msg">
>>         } else if (args[0] == ctx->i32zero)<br class="gmail_msg">
>>                 return; /* unnecessary NULL export */<br class="gmail_msg">
>><br class="gmail_msg">
>>         ac_emit_llvm_intrinsic(&ctx->ac, "llvm.SI.export",<br class="gmail_msg">
>> -                           ctx->voidt, args, 9, 0);<br class="gmail_msg">
>> +                              ctx->voidt, args, 9,<br class="gmail_msg">
>> +                              AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static void<br class="gmail_msg">
>>  si_export_mrt_z(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>                 LLVMValueRef depth, LLVMValueRef stencil,<br class="gmail_msg">
>>                 LLVMValueRef samplemask)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         LLVMValueRef args[9];<br class="gmail_msg">
>>         unsigned mask = 0;<br class="gmail_msg">
>>         args[1] = ctx->i32one; /* whether the EXEC mask is valid */<br class="gmail_msg">
>> @@ -4598,21 +4615,22 @@ si_export_mrt_z(struct nir_to_llvm_context *ctx,<br class="gmail_msg">
>>         }<br class="gmail_msg">
>><br class="gmail_msg">
>>         /* SI (except OLAND) has a bug that it only looks<br class="gmail_msg">
>>          * at the X writemask component. */<br class="gmail_msg">
>>         if (ctx->options->chip_class == SI &&<br class="gmail_msg">
>>             ctx->options->family != CHIP_OLAND)<br class="gmail_msg">
>>                 mask |= 0x01;<br class="gmail_msg">
>><br class="gmail_msg">
>>         args[0] = LLVMConstInt(ctx->i32, mask, false);<br class="gmail_msg">
>>         ac_emit_llvm_intrinsic(&ctx->ac, "llvm.SI.export",<br class="gmail_msg">
>> -                           ctx->voidt, args, 9, 0);<br class="gmail_msg">
>> +                              ctx->voidt, args, 9,<br class="gmail_msg">
>> +                              AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  static void<br class="gmail_msg">
>>  handle_fs_outputs_post(struct nir_to_llvm_context *ctx)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>>         unsigned index = 0;<br class="gmail_msg">
>>         LLVMValueRef depth = NULL, stencil = NULL, samplemask = NULL;<br class="gmail_msg">
>><br class="gmail_msg">
>>         for (unsigned i = 0; i < RADEON_LLVM_MAX_OUTPUTS; ++i) {<br class="gmail_msg">
>>                 LLVMValueRef values[4];<br class="gmail_msg">
>> @@ -5021,21 +5039,22 @@ ac_gs_copy_shader_emit(struct nir_to_llvm_context<br class="gmail_msg">
>> *ctx)<br class="gmail_msg">
>><br class="gmail_msg">
>>                 for (unsigned j = 0; j < 4; j++) {<br class="gmail_msg">
>>                         LLVMValueRef value;<br class="gmail_msg">
>>                         args[2] = LLVMConstInt(ctx->i32,<br class="gmail_msg">
>>                                                (idx * 4 + j) *<br class="gmail_msg">
>>                                                ctx->gs_max_out_vertices *<br class="gmail_msg">
>> 16 * 4, false);<br class="gmail_msg">
>><br class="gmail_msg">
>>                         value = ac_emit_llvm_intrinsic(&ctx->ac,<br class="gmail_msg">
>><br class="gmail_msg">
>> "llvm.SI.buffer.load.dword.i32.i32",<br class="gmail_msg">
>>                                                        ctx->i32, args, 9,<br class="gmail_msg">
>> -<br class="gmail_msg">
>> AC_FUNC_ATTR_READONLY);<br class="gmail_msg">
>> +<br class="gmail_msg">
>> AC_FUNC_ATTR_READONLY |<br class="gmail_msg">
>> +<br class="gmail_msg">
>> AC_FUNC_ATTR_LEGACY);<br class="gmail_msg">
>><br class="gmail_msg">
>>                         LLVMBuildStore(ctx->builder,<br class="gmail_msg">
>>                                        to_float(ctx, value),<br class="gmail_msg">
>> ctx->outputs[radeon_llvm_reg_index_soa(i, j)]);<br class="gmail_msg">
>>                 }<br class="gmail_msg">
>>                 idx++;<br class="gmail_msg">
>>         }<br class="gmail_msg">
>>         handle_vs_outputs_post(ctx);<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  void ac_create_gs_copy_shader(LLVMTargetMachineRef tm,<br class="gmail_msg">
>> diff --git a/src/gallium/auxiliary/draw/draw_llvm.c<br class="gmail_msg">
>> b/src/gallium/auxiliary/draw/draw_llvm.c<br class="gmail_msg">
>> index 8952dc8..586a9be 100644<br class="gmail_msg">
>> --- a/src/gallium/auxiliary/draw/draw_llvm.c<br class="gmail_msg">
>> +++ b/src/gallium/auxiliary/draw/draw_llvm.c<br class="gmail_msg">
>> @@ -1588,21 +1588,22 @@ draw_llvm_generate(struct draw_llvm *llvm, struct<br class="gmail_msg">
>> draw_llvm_variant *variant)<br class="gmail_msg">
>><br class="gmail_msg">
>>     func_type = LLVMFunctionType(LLVMInt8TypeInContext(context),<br class="gmail_msg">
>>                                  arg_types, num_arg_types, 0);<br class="gmail_msg">
>><br class="gmail_msg">
>>     variant_func = LLVMAddFunction(gallivm->module, func_name, func_type);<br class="gmail_msg">
>>     variant->function = variant_func;<br class="gmail_msg">
>><br class="gmail_msg">
>>     LLVMSetFunctionCallConv(variant_func, LLVMCCallConv);<br class="gmail_msg">
>>     for (i = 0; i < num_arg_types; ++i)<br class="gmail_msg">
>>        if (LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind)<br class="gmail_msg">
>> -         lp_add_function_attr(variant_func, i + 1, LP_FUNC_ATTR_NOALIAS);<br class="gmail_msg">
>> +         lp_add_function_attr(context, variant_func, i + 1,<br class="gmail_msg">
>> +                              LP_FUNC_ATTR_NOALIAS);<br class="gmail_msg">
>><br class="gmail_msg">
>>     context_ptr               = LLVMGetParam(variant_func, 0);<br class="gmail_msg">
>>     io_ptr                    = LLVMGetParam(variant_func, 1);<br class="gmail_msg">
>>     vbuffers_ptr              = LLVMGetParam(variant_func, 2);<br class="gmail_msg">
>>     count                     = LLVMGetParam(variant_func, 3);<br class="gmail_msg">
>>     /*<br class="gmail_msg">
>>      * XXX: the maxelt part is unused. Not really useful, since we cannot<br class="gmail_msg">
>>      * get index buffer overflows due to vsplit (which provides its own<br class="gmail_msg">
>>      * elts buffer, with a different size than what's passed in here).<br class="gmail_msg">
>>      */<br class="gmail_msg">
>> @@ -2262,21 +2263,22 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,<br class="gmail_msg">
>>     func_type = LLVMFunctionType(int32_type, arg_types,<br class="gmail_msg">
>> ARRAY_SIZE(arg_types), 0);<br class="gmail_msg">
>><br class="gmail_msg">
>>     variant_func = LLVMAddFunction(gallivm->module, func_name, func_type);<br class="gmail_msg">
>><br class="gmail_msg">
>>     variant->function = variant_func;<br class="gmail_msg">
>><br class="gmail_msg">
>>     LLVMSetFunctionCallConv(variant_func, LLVMCCallConv);<br class="gmail_msg">
>><br class="gmail_msg">
>>     for (i = 0; i < ARRAY_SIZE(arg_types); ++i)<br class="gmail_msg">
>>        if (LLVMGetTypeKind(arg_types[i]) == LLVMPointerTypeKind)<br class="gmail_msg">
>> -         lp_add_function_attr(variant_func, i + 1, LP_FUNC_ATTR_NOALIAS);<br class="gmail_msg">
>> +         lp_add_function_attr(context, variant_func, i + 1,<br class="gmail_msg">
>> +                              LP_FUNC_ATTR_NOALIAS);<br class="gmail_msg">
>><br class="gmail_msg">
>>     context_ptr               = LLVMGetParam(variant_func, 0);<br class="gmail_msg">
>>     input_array               = LLVMGetParam(variant_func, 1);<br class="gmail_msg">
>>     io_ptr                    = LLVMGetParam(variant_func, 2);<br class="gmail_msg">
>>     num_prims                 = LLVMGetParam(variant_func, 3);<br class="gmail_msg">
>>     system_values.instance_id = LLVMGetParam(variant_func, 4);<br class="gmail_msg">
>>     prim_id_ptr               = LLVMGetParam(variant_func, 5);<br class="gmail_msg">
>>     system_values.invocation_id = LLVMGetParam(variant_func, 6);<br class="gmail_msg">
>><br class="gmail_msg">
>>     lp_build_name(context_ptr, "context");<br class="gmail_msg">
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c<br class="gmail_msg">
>> b/src/gallium/auxiliary/gallivm/lp_bld_intr.c<br class="gmail_msg">
>> index 049671a..1b50e68 100644<br class="gmail_msg">
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c<br class="gmail_msg">
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c<br class="gmail_msg">
>> @@ -152,83 +152,100 @@ static const char *attr_to_str(enum lp_func_attr<br class="gmail_msg">
>> attr)<br class="gmail_msg">
>>     case LP_FUNC_ATTR_READONLY: return "readonly";<br class="gmail_msg">
>>     default:<br class="gmail_msg">
>>        _debug_printf("Unhandled function attribute: %x\n", attr);<br class="gmail_msg">
>>        return 0;<br class="gmail_msg">
>>     }<br class="gmail_msg">
>>  }<br class="gmail_msg">
>><br class="gmail_msg">
>>  #endif<br class="gmail_msg">
>><br class="gmail_msg">
>>  void<br class="gmail_msg">
>> -lp_add_function_attr(LLVMValueRef function,<br class="gmail_msg">
>> -                     int attr_idx,<br class="gmail_msg">
>> -                     enum lp_func_attr attr)<br class="gmail_msg">
>> +lp_add_function_attr(LLVMContextRef ctx, LLVMValueRef function,<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> If function is not always a function, then it's better the parameter is<br class="gmail_msg">
> renamed to functionOrCall or something like that.<br class="gmail_msg">
><br class="gmail_msg">
>> +                     int attr_idx, enum lp_func_attr attr)<br class="gmail_msg">
>>  {<br class="gmail_msg">
>><br class="gmail_msg">
>>  #if HAVE_LLVM < 0x0400<br class="gmail_msg">
>>     LLVMAttribute llvm_attr = lp_attr_to_llvm_attr(attr);<br class="gmail_msg">
>>     if (attr_idx == -1) {<br class="gmail_msg">
>>        LLVMAddFunctionAttr(function, llvm_attr);<br class="gmail_msg">
>>     } else {<br class="gmail_msg">
>>        LLVMAddAttribute(LLVMGetParam(function, attr_idx - 1), llvm_attr);<br class="gmail_msg">
>>     }<br class="gmail_msg">
>>  #else<br class="gmail_msg">
>> -   LLVMContextRef context =<br class="gmail_msg">
>> LLVMGetModuleContext(LLVMGetGlobalParent(function));<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> Even when LLVMIsAFunction(function) is false, we could still get the<br class="gmail_msg">
> LLVMContextRef:<br class="gmail_msg">
><br class="gmail_msg">
>    LLVMModuleRef module;<br class="gmail_msg">
>    if (LLVMIsAFunction(functionOrCall)) {<br class="gmail_msg">
>       module = LLVMGetGlobalParent(functionOrCall);<br class="gmail_msg">
>    } else {<br class="gmail_msg">
>       LLVMBasicBlockRef bb = LLVMValueAsBasicBlock(functionOrCall);<br class="gmail_msg">
<br class="gmail_msg">
The correct function is LLVMGetInstructionParent.<br class="gmail_msg">
<br class="gmail_msg">
>       LLVMValueRef function = LLVMGetBasicBlockParent(bb)<br class="gmail_msg">
>       module = LLVMGetGlobalParent(function);<br class="gmail_msg">
><br class="gmail_msg">
>    }<br class="gmail_msg">
>    LLVMContextRef context = LLVMGetModuleContext(module);<br class="gmail_msg">
><br class="gmail_msg">
> This would enable to keep lp_add_function_attr prototype alone.<br class="gmail_msg">
><br class="gmail_msg">
> Otherwise looks good to me.<br class="gmail_msg">
><br class="gmail_msg">
> Reviewed-by: Jose Fonseca <<a href="mailto:jfonseca@vmware.com" class="gmail_msg" target="_blank">jfonseca@vmware.com</a>><br class="gmail_msg">
<br class="gmail_msg">
Thanks.<br class="gmail_msg">
<br class="gmail_msg">
Marek<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
mesa-dev mailing list<br class="gmail_msg">
<a href="mailto:mesa-dev@lists.freedesktop.org" class="gmail_msg" target="_blank">mesa-dev@lists.freedesktop.org</a><br class="gmail_msg">
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br class="gmail_msg">
</blockquote></div>