[PATCH] ARM: Emit ".code 16" before global inline-asm instructions in thumb mode
Akira Hatanaka
ahatanak at gmail.com
Thu Jul 24 15:02:57 PDT 2014
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:
$ cat test2.c
__asm__ ("stmib sp, {r0-r14};");
$ clang -arch armv7 -S -o - test2.c
.section __TEXT,__text,regular,pure_instructions
.ios_version_min 5, 0
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
.section __TEXT,__const_coal,coalesced
.section __TEXT,__picsymbolstub4,symbol_stubs,none,16
.section __TEXT,__StaticInit,regular,pure_instructions
.section __TEXT,__cstring,cstring_literals
.syntax unified
@ Start of file scope inline
assembly
*<inline asm>:1:1: **error: **instruction requires: arm-mode*
stmib sp, {r0-r14};
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.
$ clang -arch armv7 -S -o test2.s -no-integrated-as test2.c
$ clang -arch armv7 test2.s -c
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.
<rdar://problem/17757232>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140724/c328c6b3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: code16.patch
Type: application/octet-stream
Size: 924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140724/c328c6b3/attachment.obj>
More information about the llvm-commits
mailing list