<div dir="ltr">Thank you, Jim.<div><br></div><div>Commited r<span style="color:rgb(0,0,0);white-space:pre-wrap">213924.</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 24, 2014 at 5:19 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Akira,<div><br></div><div>Patch LGTM. The testcase should also run with ARM (a second RUN line w/ a distinct check prefix) w/ check lines there to verify we don’t emit the “.code 16” then.</div>
<div><br></div><div>-Jim</div><div><br></div><div><div><blockquote type="cite"><div><div class="h5"><div>On Jul 24, 2014, at 3:02 PM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com" target="_blank">ahatanak@gmail.com</a>> wrote:</div>
<br></div></div><div><div><div class="h5"><div dir="ltr"><div>ToT clang (correctly) errors-out when the target is armv7 (thumb2) and the program it's compiling has an ARM mode file-level inline assembly statement: </div>
<div><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">
$ cat test2.c</div><p style="margin:0px;font-size:11px;font-family:Menlo">
</p><div style="margin:0px;font-size:11px;font-family:Menlo">__asm__ ("stmib sp, {r0-r14};");</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">
$ clang -arch armv7 -S -o - test2.c <br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>.section<span style="white-space:pre-wrap"> </span>__TEXT,__text,regular,pure_instructions</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>.ios_version_min 5, 0</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>.section<span style="white-space:pre-wrap"> </span>__TEXT,__textcoal_nt,coalesced,pure_instructions</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>.section<span style="white-space:pre-wrap"> </span>__TEXT,__const_coal,coalesced</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>.section<span style="white-space:pre-wrap"> </span>__TEXT,__picsymbolstub4,symbol_stubs,none,16</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>.section<span style="white-space:pre-wrap"> </span>__TEXT,__StaticInit,regular,pure_instructions</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>.section<span style="white-space:pre-wrap"> </span>__TEXT,__cstring,cstring_literals</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<span style="white-space:pre-wrap"> </span>.syntax unified</div><div style="margin:0px;font-size:11px;font-family:Menlo"> @ Start of file scope inline assembly</div><div style="margin:0px;font-size:11px;font-family:Menlo">
<b><inline asm>:1:1: </b><span style="color:rgb(195,55,32)"><b>error: </b></span><b>instruction requires: arm-mode</b></div><div style="margin:0px;font-size:11px;font-family:Menlo">stmib sp, {r0-r14};</div></div><div>
<br></div><div>However, when the .s file is generated with -no-integrated-as first, and then assembled later, clang completes assembling the .s file without any errors.</div>
<div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo">$ clang -arch armv7 -S -o test2.s -no-integrated-as test2.c </div><div style="margin:0px;font-size:11px;font-family:Menlo">$ clang -arch armv7 test2.s -c</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div>The attached patch fixes this discrepancy in clang's behavior by emitting directive ".code 16" before global inline-asm instructions when the target is thumb. Without this directive, clang assembles the global inline-asm instruction in ARM mode, since the assembler always starts in ARM mode and stays in that mode until it sees directives that instruct it to switch to thumb.</div>
<div><br></div><div><<a>rdar://problem/17757232</a>><br></div><div><br></div></div></div>
</div></div><span><code16.patch></span>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></blockquote></div><br></div></div></blockquote></div><br></div>