llvm-6502/lib
Bill Wendling 06866a72b0 Merging r195677:
------------------------------------------------------------------------
r195677 | dpeixott | 2013-11-25 11:11:13 -0800 (Mon, 25 Nov 2013) | 41 lines

ARM integrated assembler generates incorrect nop opcode

This patch fixes a bug in the assembler that was causing bad code to
be emitted.  When switching modes in an assembly file (e.g. arm to
thumb mode) we would always emit the opcode from the original mode.

Consider this small example:

$ cat align.s
.code 16
foo:
  add r0, r0
.align 3
  add r0, r0

$ llvm-mc -triple armv7-none-linux align.s -filetype=obj -o t.o
$ llvm-objdump -triple thumbv7 -d t.o
Disassembly of section .text:
foo:
       0:       00 44         add     r0, r0
       2:       00 f0 20 e3   blx #4195904
       6:       00 00         movs    r0, r0
       8:       00 44         add     r0, r0

This shows that we have actually emitted an arm nop (e320f000)
instead of a thumb nop. Unfortunately, this encodes to a thumb
branch which causes bad things to happen when compiling assembly
code with align directives.

The fix is to notify the ARMAsmBackend when we switch mode. The
MCMachOStreamer was already doing this correctly. This patch makes
the same change for the MCElfStreamer.

There is still a bug in the way nops are emitted for alignment
because the MCAlignment fragment does not store the correct mode.
The ARMAsmBackend will emit nops for the last mode it knew about. In
the example above, we still generate an arm nop if we add a `.code
32` to the end of the file.

PR18019

------------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196001 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-01 03:19:10 +00:00
..
Analysis The 'optnone' attribute means don't inline anything into this function 2013-11-18 21:44:03 +00:00
AsmParser Add addrspacecast instruction. 2013-11-15 01:34:59 +00:00
Bitcode Fix spacing, forward declare order. 2013-11-18 02:51:33 +00:00
CodeGen Merging r195798: 2013-11-27 06:44:45 +00:00
DebugInfo DebugInfo: Make pubnames header printing similar to unit header printing 2013-11-01 17:53:30 +00:00
ExecutionEngine Merging r195157: 2013-11-21 00:52:34 +00:00
IR [weak vtables] Remove a bunch of weak vtables 2013-11-19 00:57:56 +00:00
IRReader [llvm-c] Expose IRReader interface 2013-11-06 09:21:15 +00:00
Linker Revert "Move copying of global initializers below the cloning of functions." 2013-11-09 00:43:18 +00:00
LTO Use array_pod_sort instead of std::sort 2013-11-16 16:15:56 +00:00
MC Merging r195677: 2013-12-01 03:19:10 +00:00
Object Path: Recognize COFF import library file magic. 2013-11-15 21:22:02 +00:00
Option Use startswith_lower() where possible. 2013-11-04 19:22:50 +00:00
Support Merging r195632: 2013-11-26 11:09:08 +00:00
TableGen Fix most memory leaks in tablegen. 2013-10-31 04:07:41 +00:00
Target Merging r195881: 2013-12-01 03:15:22 +00:00
Transforms Merging r195787: 2013-12-01 03:03:42 +00:00
CMakeLists.txt Move LTO support library to a component, allowing it to be tested 2013-09-24 23:52:22 +00:00
LLVMBuild.txt Move LTO support library to a component, allowing it to be tested 2013-09-24 23:52:22 +00:00
Makefile Reformat Makefile. No other changes. 2013-10-30 04:03:03 +00:00