gallivm: handle call attributes for llvm < 4.0 in lp_add_function_attr
authorRoland Scheidegger <sroland@vmware.com>
Fri, 21 Jul 2017 18:27:43 +0000 (20:27 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Fri, 21 Jul 2017 20:46:04 +0000 (22:46 +0200)
commitdbde58dd311a77c08d316362f9365b4c0b6852fe
tree661ef49559cc20ba4cc97b0a8f61420055eeba8e
parentaf9d6a8a99fa67bade628028b7265ae21445a930
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 <jfonseca@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_intr.c