<div dir="ltr"><span style="font-size:12.8px">> Yes, as I said, I made it up. The real code used .LCPI42_27 or</span><br style="font-size:12.8px"><span style="font-size:12.8px">> .LCPI36_27or something (I forget), used different registers and had</span><br style="font-size:12.8px"><span style="font-size:12.8px">> dozens of instructions in between. But those details don't matter so I</span><br style="font-size:12.8px"><span style="font-size:12.8px">> simplified it.</span><br><br>Thank you for sharing the reason in more detail. <div>At first glance, it seems that the key difference is "bl<span class="" style="white-space:pre">      </span>_ZNK7TypeKey10GetNumArgsEv(PLT)" <br>between -O1 and -O2 from the clsload.s file. Could you tell me one example to understand<div>what it is problem? <br><br>* filename: debug-O0-to-O3-clsload.c-assembly-with-save-temps.tar.gz<br>  download: <a href="https://onedrive.live.com/redir?resid=C93799B86B006829!176&authkey=!ACoaXTFQPkbQDoo&ithint=file%2cgz">https://onedrive.live.com/redir?resid=C93799B86B006829!176&authkey=!ACoaXTFQPkbQDoo&ithint=file%2cgz</a><br><div><div><br></div><div><br></div><div>-------------------------------- clsload.s: -O1 ---------------------------------------</div><div><br></div><div>.Ltmp599:</div><div><span class="" style="white-space:pre">     </span>.loc<span class="" style="white-space:pre">      </span>64 442 122              @ /work/dotnet/arm-32/coreclr/src/vm/clsload.cpp:442:122</div><div><span class="" style="white-space:pre">    </span>mov<span class="" style="white-space:pre">       </span>r0, r4</div><div><span class="" style="white-space:pre">     </span>bl<span class="" style="white-space:pre">        </span>_ZNK7TypeKey10GetNumArgsEv(PLT)</div><div><span class="" style="white-space:pre">    </span>ldr<span class="" style="white-space:pre">       </span>r1, .LCPI36_2</div><div><span class="" style="white-space:pre">      </span>ldr<span class="" style="white-space:pre">       </span>r2, [sp, #20]</div><div><br></div><div>-------------------------------- clsload.s: -O2 ---------------------------------------</div><div>.Ltmp2818:</div><div>@ BB#4:</div><div><span class="" style="white-space:pre">        </span>@DEBUG_VALUE: LookupTypeHandleForTypeKeyInner:pKey <- R4</div><div><span class="" style="white-space:pre">        </span>@DEBUG_VALUE: LookupTypeHandleForTypeKeyInner:fCheckUnderLock <- R5</div><div><span class="" style="white-space:pre">     </span>ldr<span class="" style="white-space:pre">       </span>r1, .LCPI36_2</div><span class="" style="white-space:pre"> </span>.loc<span class="" style="white-space:pre">      </span>34 769 53 discriminator 5 @ /work/dotnet/arm-32/coreclr/src/vm/crossgen/../typehandle.h:769:53 </div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 11, 2016 at 10:39 PM, 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 10 May 2016 at 22:11, Geunsik Lim <<a href="mailto:leemgs@gmail.com">leemgs@gmail.com</a>> wrote:<br>
>> we cannot combine the 2 ldr instructions and litpools because they get<br>
>> added to a different pc to form the correct address.<br>
><br>
> I wonder how we can figure out the reason such as the above statement from<br>
> the libcoreclr.so (or clsload.s).<br>
<br>
</span>The key was reusing litpool entries that get added to PC. That's an<br>
extremely odd sequence and almost certainly never what you want to do.<br>
After that it was just stepping through LLVM to work out where things<br>
went wrong.<br>
<span class=""><br>
> Actually, I could not find the same assembly code that you commented to<br>
> r268662  from clsload.s file.<br>
<br>
</span>Yes, as I said, I made it up. The real code used .LCPI42_27 or<br>
.LCPI36_27or something (I forget), used different registers and had<br>
dozens of instructions in between. But those details don't matter so I<br>
simplified it.<br>
<span class=""><br>
>> The inliner was needed in this case because most TLS accesses were hidden<br>
>> away in GetThread.<br>
>> You could write C code that would fail at -O1 if you tried.<br>
><br>
> It's strange. I can normally run C# console applications  with libcoreclr.so<br>
> that is built by -O1 such as -O0<br>
<br>
</span>Yes,  libcoreclr.so isn't affected at -O1. You'd have to write C code<br>
specially designed to trigger the bug (or be otherwise unlucky).<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><a href="http://leemgs.fedorapeople.org" style="font-family:Tahoma" target="_blank">http://leemgs.fedorapeople.org</a><span style="font-family:Tahoma"> </span></div><div>Don't try to avoid pain if you fail.<br>If you decided to face the challenges in life, <br>you can gain a lot by giving your best.<br>Cheolsang Jeong's Book & life<br>--<br></div></div></div>
</div>