X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Fgallivm%2Flp_bld_intr.c;h=2f853457bf03f041e19158465902bb0cbad63544;hb=dffeaa55dd1155d7a1e8feb5ecfc54fff688fcd8;hp=0b25ae5d9d64d265984c1a7a95da7d0d3ec5cb8c;hpb=940da36a65c767ec9fc6817df3d0262b52de42f6;p=mesa.git diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c b/src/gallium/auxiliary/gallivm/lp_bld_intr.c index 0b25ae5d9d6..2f853457bf0 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c @@ -90,9 +90,9 @@ lp_format_intrinsic(char *name, } if (length) { - util_snprintf(name, size, "%s.v%u%c%u", name_root, length, c, width); + snprintf(name, size, "%s.v%u%c%u", name_root, length, c, width); } else { - util_snprintf(name, size, "%s.%c%u", name_root, c, width); + snprintf(name, size, "%s.%c%u", name_root, c, width); } } @@ -126,7 +126,6 @@ static LLVMAttribute lp_attr_to_llvm_attr(enum lp_func_attr attr) { switch (attr) { case LP_FUNC_ATTR_ALWAYSINLINE: return LLVMAlwaysInlineAttribute; - case LP_FUNC_ATTR_BYVAL: return LLVMByValAttribute; case LP_FUNC_ATTR_INREG: return LLVMInRegAttribute; case LP_FUNC_ATTR_NOALIAS: return LLVMNoAliasAttribute; case LP_FUNC_ATTR_NOUNWIND: return LLVMNoUnwindAttribute; @@ -144,12 +143,14 @@ static const char *attr_to_str(enum lp_func_attr attr) { switch (attr) { case LP_FUNC_ATTR_ALWAYSINLINE: return "alwaysinline"; - case LP_FUNC_ATTR_BYVAL: return "byval"; case LP_FUNC_ATTR_INREG: return "inreg"; case LP_FUNC_ATTR_NOALIAS: return "noalias"; case LP_FUNC_ATTR_NOUNWIND: return "nounwind"; case LP_FUNC_ATTR_READNONE: return "readnone"; case LP_FUNC_ATTR_READONLY: return "readonly"; + case LP_FUNC_ATTR_WRITEONLY: return "writeonly"; + case LP_FUNC_ATTR_INACCESSIBLE_MEM_ONLY: return "inaccessiblememonly"; + case LP_FUNC_ATTR_CONVERGENT: return "convergent"; default: _debug_printf("Unhandled function attribute: %x\n", attr); return 0; @@ -165,10 +166,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 @@ -236,6 +241,16 @@ lp_build_intrinsic(LLVMBuilderRef builder, function = lp_declare_intrinsic(module, name, ret_type, arg_types, num_args); + /* + * If llvm removes an intrinsic we use, we'll hit this abort (rather + * than a call to address zero in the jited code). + */ + if (LLVMGetIntrinsicID(function) == 0) { + _debug_printf("llvm (version 0x%x) found no intrinsic for %s, going to crash...\n", + HAVE_LLVM, name); + abort(); + } + if (!set_callsite_attrs) lp_add_func_attributes(function, attr_mask);