<div dir="ltr"><div>Hi Tim Northover,</div><div><br></div><div>I just use Mac OS X, Intel Core i5. 'retValue' is initialized, computed, and then returned from 'myFunction', so I think this problem is not introduced by uninitialized value. In addition, <span style="font-size:12.8px">'306205760' is not a meaningless value, but the result of truncating</span> <span style="font-size:12.8px">'140583176769504' to 32 bits. </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Actually, I instrumented some call instructions for value store and load, which can be simplified as follow: </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">1. Storing values with function 'myStore':</span></div><div><span style="font-size:12.8px">       call void myStore(i64 %1); </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">2. Loading values with function 'myLoad':</span></div><div><span style="font-size:12.8px">       %0 = call i64 myLoad();     </span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">The problem is that t</span><span style="font-size:12.8px">he call on 'myStore' can correctly pass 'i64 %1' to the function body of 'myStore'. However, when I use 'myLoad' to return the stored value to '%0', the 64bits value is truncated to a 32bits value. For example, </span><span style="font-size:12.8px">'140583176769504' is returned in 'myLoad', but actually </span><span style="font-size:12.8px">'306205760' is assigned to %0. </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><br></div><div>Best regards,</div><div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Qiuping Yi</div><div style="font-size:12.8px">Parasol Laboratory</div><div style="font-size:12.8px">Department of Computer Science and Engineering</div><div style="font-size:12.8px">Texas A&M University</div><div style="font-size:12.8px">College Station</div><div style="font-size:12.8px">TX 77843</div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Jul 12, 2017 at 10:16 AM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 12 July 2017 at 11:10, Qiuping Yi via llvm-dev<br>
<span class="gmail-"><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> int64_t myFunction() {<br>
>      int64_t retValue;<br>
>      ...<br>
>      std::cout << "retValue: " << retValue << "\n";<br>
>      return retValue;<br>
> }<br>
<br>
</span>If retValue isn't initialized then this program has undefined<br>
behaviour as C++ so all bets are off (LLVM might be propagating an<br>
"undef" and simply not returning a meaningful value).<br>
<br>
Otherwise we need more detail. I'd expect this to work on all targets<br>
(int64_t would in almost every case map to i64, and this straight<br>
return should be fine, particularly if it comes from C++). So are you<br>
using a custom target and does it have any quirks that might be<br>
relevant? The key functions to look at would be LowerCall and<br>
LowerReturn in XYZISelLowering.cpp.<br>
<br>
Cheers.<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div></div></div>