<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">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>On Jul 24, 2014, at 3:02 PM, Akira Hatanaka <<a href="mailto:ahatanak@gmail.com">ahatanak@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div><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 class="" style="white-space:pre">       </span>.section<span class="" style="white-space:pre">  </span>__TEXT,__text,regular,pure_instructions</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">        </span>.ios_version_min 5, 0</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">  </span>.section<span class="" style="white-space:pre">  </span>__TEXT,__textcoal_nt,coalesced,pure_instructions</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">       </span>.section<span class="" style="white-space:pre">  </span>__TEXT,__const_coal,coalesced</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">  </span>.section<span class="" style="white-space:pre">  </span>__TEXT,__picsymbolstub4,symbol_stubs,none,16</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">   </span>.section<span class="" style="white-space:pre">  </span>__TEXT,__StaticInit,regular,pure_instructions</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">  </span>.section<span class="" style="white-space:pre">  </span>__TEXT,__cstring,cstring_literals</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><span class="" style="white-space:pre">      </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 href="rdar://problem/17757232">rdar://problem/17757232</a>><br></div><div><br></div></div></div>
<span><code16.patch></span>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></div></blockquote></div><br></div></body></html>