compiler construction - Adding the inreg attribute to LLVM IR function parameters -
i'm working llvm , want recreate piece of ir api: declare void @fun(i32* inreg, i32 inreg) but can't seem it. my current attempt is: function* fun = cast<function>(m.getorinsertfunction("fun",type)); ((fun -> getattributes()).getparamattributes(0)).addattribute(c,0,attribute::inreg); ((fun -> getattributes()).getparamattributes(1)).addattribute(c,0,attribute::inreg); this code literally doesn't after line 1, lines 2 , 3 ignored , in ir output is: declare void @fun(i32* , i32 ) how work correctly? managing function attributes in llvm quite inconvenient attributes packed immutable , global sets. assigning attribute function argument means replacing set representing function , argument attributes new one. fortunately, there @ least helper functions makes job bit easier. suggest using llvm::function::addattribute() method. function* fun = cast<function>(m.getorinsertfunction("fun", type)); fun->addattrib...