James Y Knight
2009-Dec-29 23:16 UTC
[LLVMdev] LLVM{Add,Remove}FunctionAttr totally broken
The LLVMAddFunctionAttr and LLVMRemoveFunctionAttr are busted: they actually set the return value's attributes, not the function's attributes. There seems to be no C API for actually setting the function attributes. LLVMGetFunctionAttr, however, does correctly return the function attributes, not the return value's attributes. There is no C API for getting the return value attributes. (And if the above functions are fixed, there would also be no way to set return value attributes). I'd like to propose that LLVM{Add,Remove}FunctionAttr be fixed to actually set the function attributes. And that a new API, LLVM {Add,Remove,Get}RetAttr be added, like: void LLVMAddRetAttr(LLVMValueRef Fn, LLVMAttribute PA); void LLVMRemoveRetAttr(LLVMValueRef Fn, LLVMAttribute PA); LLVMAttribute LLVMGetRetAttr(LLVMValueRef Fn); which will do the associated actions on the return value. If this is acceptable, I can submit a trivial patch that implements it. James PS: no comments on my last patch, not sure if it was overlooked or just everyone's busy over the holidays: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091221/092943.html
Matti Niemenmaa
2010-Jan-07 12:16 UTC
[LLVMdev] LLVM{Add,Remove}FunctionAttr totally broken
On 2009-12-30 01:16, James Y Knight wrote:> The LLVMAddFunctionAttr and LLVMRemoveFunctionAttr are busted: they > actually set the return value's attributes, not the function's > attributes. There seems to be no C API for actually setting the > function attributes. > > LLVMGetFunctionAttr, however, does correctly return the function > attributes, not the return value's attributes. There is no C API for > getting the return value attributes. (And if the above functions are > fixed, there would also be no way to set return value attributes). > > I'd like to propose that LLVM{Add,Remove}FunctionAttr be fixed to > actually set the function attributes. And that a new API, LLVM > {Add,Remove,Get}RetAttr be added, like: > > void LLVMAddRetAttr(LLVMValueRef Fn, LLVMAttribute PA); > void LLVMRemoveRetAttr(LLVMValueRef Fn, LLVMAttribute PA); > LLVMAttribute LLVMGetRetAttr(LLVMValueRef Fn); > > which will do the associated actions on the return value. > > If this is acceptable, I can submit a trivial patch that implements it.Given that they are indeed completely broken, I suggest filing a bug in the Bugzilla to make sure this gets fixed. Remember to attach your patch!