ac/llvm: use invariant.load metadata on load intrinsics instead of readnone
authorMarek Olšák <marek.olsak@amd.com>
Sun, 4 Dec 2022 11:14:10 +0000 (06:14 -0500)
committerMarge Bot <emma+marge@anholt.net>
Tue, 6 Dec 2022 13:27:16 +0000 (13:27 +0000)
readnone is illegal now and we should be using invariant.load since LLVM 15.
(suggested by Nicolai)

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20146>

src/amd/llvm/ac_llvm_build.c

index 0a79b6b..e43f6d6 100644 (file)
@@ -309,8 +309,12 @@ LLVMValueRef ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name,
 
    call = LLVMBuildCall2(ctx->builder, function_type, function, params, param_count, "");
 
-   if (attrib_mask & AC_FUNC_ATTR_READNONE)
-      LLVMAddCallSiteAttribute(call, -1, ac_get_llvm_attribute(ctx->context, "readnone"));
+   if (attrib_mask & AC_FUNC_ATTR_READNONE) {
+      if (LLVM_VERSION_MAJOR >= 15)
+         LLVMSetMetadata(call, ctx->invariant_load_md_kind, ctx->empty_md);
+      else
+         LLVMAddCallSiteAttribute(call, -1, ac_get_llvm_attribute(ctx->context, "readnone"));
+   }
 
    if (attrib_mask & AC_FUNC_ATTR_CONVERGENT)
       LLVMAddCallSiteAttribute(call, -1, ac_get_llvm_attribute(ctx->context, "convergent"));