<div dir="ltr">Thanks for your help and advice. I have found the problem, which is resulted from my own code. </div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="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 11:45 AM, mats petersson <span dir="ltr"><<a href="mailto:mats@planetcatfish.com" target="_blank">mats@planetcatfish.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I think this requires "complete code" (ideally the smallest possible that still reproduces the problem), not snippets. It is quite likely that the problem is somewhere other than in the precise lines quoted.<br><br></div><div>Using 64-bit values in x86 is far from rare, but it's of course possible that:<br></div><div>1. you have found a rare bug because your code is doing something unusual.<br></div><div>2. there is a bug somewhere in your own code, that you haven't spotted.<br><br></div><div>The bits of code you have posted don't look wrong, but they also aren't showing enough code to determine "yes that should work" or "no, that is wrong because ..."<br></div><div><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 12 July 2017 at 17:24, Qiuping Yi via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><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"><span><br clear="all"><div><div class="m_-4721149503911122052m_709147616982038266gmail_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></span><span><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="m_-4721149503911122052m_709147616982038266gmail-"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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="m_-4721149503911122052m_709147616982038266gmail-HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></span></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>