Hello guys, For single scalar pointer parameter, we have 'byval' to specify the pointee is not changed. But for base+range parameters like: declare void @_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8*, i32) (This is the fortran runtime api to 'printf' one integer) The 2nd & 3rd args are used to specify the memory of that integer. I didn't find a comfortable way to specify that it's 'byval'. I need this to make argpromotion work. Right now I just create an alloca, load value into it, and specify this alloca(base+range) as parameter. Is it a missing feature or there is a solution already? thanks, yuanfang
That is not what byval does. byval implicitly copies the pointee into the argument slots used for the call or registers on some architectures. On Thu, Jan 23, 2014 at 7:42 PM, Yuanfang Chen <cyfmxc at gmail.com> wrote:> Hello guys, > > For single scalar pointer parameter, we have 'byval' to specify the > pointee is not changed. But for base+range parameters like: > declare void @_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, > i8*, i32) > (This is the fortran runtime api to 'printf' one integer) The 2nd & > 3rd args are used to specify the memory of that integer. I didn't find > a comfortable way to specify that it's 'byval'. I need this to make > argpromotion work. Right now I just create an alloca, load value into > it, and specify this alloca(base+range) as parameter. Is it a > missing feature or there is a solution already? > > > thanks, > yuanfang > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140123/86fc5081/attachment.html>
On Thu, Jan 23, 2014 at 10:57 PM, Reid Kleckner <rnk at google.com> wrote:> That is not what byval does. byval implicitly copies the pointee into the > argument slots used for the call or registers on some architectures.Thanks Reid. I looked into the argpromotion code and you are right. 'byval' does not work for this case. I think I'll stick to my workaround for now. But I don't quite understand why argpromotion does not check for readonly use other than (GEPorNonGEP) LoadInst. For case like define void @checksum_(i32* noalias %i) { . . . load %i call void @_gfortran_transfer_integer_write(%xx, %i, 4) } If type of @_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8*, i32) is changed to @_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8* byval, i32) It makes sense to argpro %i of checksum_ , right?