#endif
}
+#if LLVM_API_VERSION > 500
static Attribute::AttrKind
convert_attr (AttrKind kind)
{
return Attribute::NoUnwind;
}
}
+#else
+static LLVMAttribute
+convert_attr (AttrKind kind)
+{
+ switch (kind) {
+ case LLVM_ATTR_NO_UNWIND:
+ return LLVMNoUnwindAttribute;
+ case LLVM_ATTR_NO_INLINE:
+ return LLVMNoInlineAttribute;
+ case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+ return LLVMOptimizeForSizeAttribute;
+ case LLVM_ATTR_IN_REG:
+ return LLVMInRegAttribute;
+ case LLVM_ATTR_STRUCT_RET:
+ return LLVMStructRetAttribute;
+ case LLVM_ATTR_NO_ALIAS:
+ return LLVMNoAliasAttribute;
+ case LLVM_ATTR_BY_VAL:
+ return LLVMByValAttribute;
+ case LLVM_ATTR_UW_TABLE:
+ return LLVMUWTable;
+ default:
+ assert (0);
+ return LLVMNoUnwindAttribute;
+ }
+}
+#endif
void
mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind)
#if LLVM_API_VERSION > 100
unwrap<Function> (func)->addAttribute (AttributeList::FunctionIndex, convert_attr (kind));
#else
- unwrap<Function> (func)->addFnAttr (convert_attr (kind));
+ Function *Func = unwrap<Function>(func);
+ const AttributeSet PAL = Func->getAttributes();
+ AttrBuilder B(convert_attr (kind));
+ const AttributeSet PALnew =
+ PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
+ AttributeSet::get(Func->getContext(),
+ AttributeSet::FunctionIndex, B));
+ Func->setAttributes(PALnew);
#endif
}