<div dir="ltr"><div class="gmail_extra" style>Hi Stepan,</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>So, the attached C code translates as the attached IR wrt struct by-val return/argument passing. You can see that Clang lowers it to an array ([3 x i64] %f.coerce) when passing arguments on ARM, but uses sret (%struct.Foo* noalias sret %agg.result) when returning. This is due to the unimplemented features in the ARM back-end, AFAIK.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>Compare that with Intel's IR:</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>ARM:</div><div class="gmail_extra" style>
<div class="gmail_extra">define void @printFoo([3 x i64] %f.coerce) #0 {</div><div><br></div><div style>x86_64:</div><div style><div>define void @printFoo(%struct.Foo* byval align 8 %f) #0 {</div><div><br></div></div></div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>I don't want to discourage you to implementing them now, it'd actually be a great improvement, but if you don't change (at least) Clang (and probably dragonegg too) to use the new constructs, they will go untested and it'll break when people try to use it. </div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>This has happened before with struct byval and union support and the decision was to remove the support completely until some good soul would implement them entirely and move the relevant front-ends to use it, so we can test it. </div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>If you have that kind of time and are willing to go the full length, please, by all means, implement struct byval in the ARM back-end. It'd be a great addition! But if you're only trying to get your front-end to produce beautiful IR on a small subset of the problem, I recommend that you follow Clang's example and cast to an array.</div>
<div class="gmail_extra" style><br></div><div class="gmail_extra" style>cheers,</div><div class="gmail_extra" style>--renato</div><div class="gmail_extra" style><br></div><div class="gmail_extra" style>PS: This example is producing *very* bad code, even at O3... A byval change would probably make it *much* more efficient!</div>
</div>