Module: Mesa
Branch: master
Commit: dbde58dd311a77c08d316362f9365b4c0b6852fe
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dbde58dd311a77c08d316362f9365b4c0b6852fe

Author: Roland Scheidegger <srol...@vmware.com>
Date:   Fri Jul 21 20:27:43 2017 +0200

gallivm: handle call attributes for llvm < 4.0 in lp_add_function_attr

We had some caller using LLVMAddInstrAttributes, which couldn't be
converted to lp_add_function_attr, because attributes were only handled
for functions in this case, so fix this.
For llvm >= 4.0, this already works correctly.
(radeonsi seems to avoid setting call site attributes prior to llvm 4.0,
the patch then citing it doesn't work when calling intrinsics. But at
least for calling external functions we always used that, albeit only
for actual call attributes, not call parameter attributes, though some
quick test shows llvm seems to handle that as well. The attribute index
is sort of iffy though, since attribute 0 of the call is the actual function,
attribute 1 corresponds to the first parameter of the called function.)
(Verified with GALLIVM_DEBUG=dumpbc plus llvm-dis that the correct
attributes are shown for calls, both for llvm 4.0 and 3.3.)

Reviewed-by: Jose Fonseca <jfons...@vmware.com>
Reviewed-by: Brian Paul <bri...@vmware.com>

---

 src/gallium/auxiliary/gallivm/lp_bld_intr.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c 
b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
index 19f98bb781..b92455593f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
@@ -168,10 +168,14 @@ lp_add_function_attr(LLVMValueRef function_or_call,
 
 #if HAVE_LLVM < 0x0400
    LLVMAttribute llvm_attr = lp_attr_to_llvm_attr(attr);
-   if (attr_idx == -1) {
-      LLVMAddFunctionAttr(function_or_call, llvm_attr);
+   if (LLVMIsAFunction(function_or_call)) {
+      if (attr_idx == -1) {
+         LLVMAddFunctionAttr(function_or_call, llvm_attr);
+      } else {
+         LLVMAddAttribute(LLVMGetParam(function_or_call, attr_idx - 1), 
llvm_attr);
+      }
    } else {
-      LLVMAddAttribute(LLVMGetParam(function_or_call, attr_idx - 1), 
llvm_attr);
+      LLVMAddInstrAttribute(function_or_call, attr_idx, llvm_attr);
    }
 #else
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to