<div dir="ltr">Your example doesn't seem complete enough, but I don't think arg promotion is the tool you want here.<div><br></div><div>Adding byval in this example would be equivalent to:</div><div>%i.load = load i8* %i<br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">@_gfortran_transfer_integer_</span><span style="font-family:arial,sans-serif;font-size:13px">write(%struct.__st_parameter_</span><span style="font-family:arial,sans-serif;font-size:13px">dt*, i8 %i.load, i32)</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">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).</span></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 23, 2014 at 8:49 PM, Yuanfang Chen <span dir="ltr"><<a href="mailto:cyfmxc@gmail.com" target="_blank">cyfmxc@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, Jan 23, 2014 at 10:57 PM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
> That is not what byval does. byval implicitly copies the pointee into the<br>
> argument slots used for the call or registers on some architectures.<br>
<br>
</div>Thanks Reid. I looked into the argpromotion code and you are right.<br>
'byval' does not work for this case. I think I'll stick to my<br>
workaround for now. But I don't quite understand why argpromotion<br>
does not check for readonly use other than (GEPorNonGEP) LoadInst.<br>
For case like<br>
<br>
define void @checksum_(i32* noalias %i) {<br>
. . . load %i<br>
call void @_gfortran_transfer_integer_write(%xx, %i, 4)<br>
}<br>
<br>
If type of<br>
@_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8*,<br>
i32) is changed to<br>
@_gfortran_transfer_integer_write(%struct.__st_parameter_dt*, i8* byval, i32)<br>
<br>
It makes sense to argpro %i of checksum_ , right?<br>
</blockquote></div><br></div>