[LLVMdev] byval attr for base+range parameters

Reid Kleckner rnk at google.com
Thu Jan 23 23:50:19 PST 2014


Your example doesn't seem complete enough, but I don't think arg promotion
is the tool you want here.

Adding byval in this example would be equivalent to:
%i.load = load i8* %i
@_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8 %i.load,
i32)

Arg promotion is really designed to eliminate awkward constructs like byval
when possible and extra indirection when possible (say, a min
implementation that takes const int references).


On Thu, Jan 23, 2014 at 8:49 PM, Yuanfang Chen <cyfmxc at gmail.com> wrote:

> 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?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140123/555361f4/attachment.html>


More information about the llvm-dev mailing list