mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-03 14:08:57 +00:00
cdb105b62f
Summary: Currently when emitting a label, a new data fragment is created for it if the current fragment isn't a data fragment. This change instead enqueues the label and attaches it to the next fragment (e.g. created for the next instruction) if possible. When bundle alignment is not enabled, this has no functionality change (it just results in fewer extra fragments being created). For bundle alignment, previously labels would point to the beginning of the bundle padding instead of the beginning of the emitted instruction. This was not only less efficient (e.g. jumping to the nops instead of past them) but also led to miscalculation of the address of the GOT (since MC uses a label difference rather than emitting a "." symbol). Fixes https://code.google.com/p/nativeclient/issues/detail?id=3982 Test Plan: regression test attached Reviewers: jvoung, eliben Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D5915 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220439 91177308-0d34-0410-b5e6-96231b3b80d8
84 lines
2.2 KiB
ArmAsm
84 lines
2.2 KiB
ArmAsm
# RUN: llvm-mc -triple=i686-linux -filetype=obj %s -o - | \
|
|
# RUN: llvm-objdump -disassemble -no-show-raw-insn -r - | FileCheck %s
|
|
# RUN: llvm-mc -triple=i686-nacl -filetype=obj %s -o - | \
|
|
# RUN: llvm-objdump -disassemble -no-show-raw-insn -r - | FileCheck %s
|
|
|
|
.bundle_align_mode 5
|
|
.text
|
|
.globl main
|
|
.align 32, 0x90
|
|
.type main,@function
|
|
main: # @main
|
|
# CHECK-LABEL: main:
|
|
# Call + pop sequence for determining the PIC base.
|
|
.bundle_lock align_to_end
|
|
calll .L0$pb
|
|
.bundle_unlock
|
|
.L0$pb:
|
|
popl %eax
|
|
# CHECK: 20: popl
|
|
# 26 bytes of instructions between the pop and the use of the pic base symbol.
|
|
movl $3, 2(%ebx, %ebx)
|
|
movl $3, 2(%ebx, %ebx)
|
|
movl $3, 2(%ebx, %ebx)
|
|
hlt
|
|
hlt
|
|
# CHECK: nop
|
|
.Ltmp0:
|
|
addl (.Ltmp0-.L0$pb), %eax
|
|
# The addl has bundle padding to push it from 0x3b to 0x40.
|
|
# The difference between the labels should be 0x20 (0x40-0x20) not 0x1b
|
|
# (0x3b-0x20)
|
|
# CHECK: 40: addl 32, %eax
|
|
popl %ecx
|
|
jmp *%ecx
|
|
|
|
|
|
# Also make sure it works with a non-relaxable instruction (cmp vs add)
|
|
# and for 2 adjacent labels that both point to the correct instruction
|
|
.section .text.bar, "ax"
|
|
.globl bar
|
|
.align 32, 0x90
|
|
.type bar,@function
|
|
bar:
|
|
# CHECK-LABEL: bar:
|
|
.bundle_lock align_to_end
|
|
calll .L1$pb
|
|
.bundle_unlock
|
|
.L1$pb:
|
|
popl %eax
|
|
# CHECK: 20: popl
|
|
# 26 bytes of instructions between the pop and the use of the pic base symbol.
|
|
movl $3, 2(%ebx, %ebx)
|
|
movl $3, 2(%ebx, %ebx)
|
|
movl $3, 2(%ebx, %ebx)
|
|
hlt
|
|
hlt
|
|
# CHECK: nop
|
|
.Ltmp1:
|
|
.Ltmp2:
|
|
cmpl %eax, .Ltmp1
|
|
# CHECK: 40: cmpl %eax, 64
|
|
cmpl %eax, (.Ltmp2-.L1$pb)
|
|
# CHECK: 46: cmpl %eax, 32
|
|
popl %ecx
|
|
jmp *%ecx
|
|
|
|
|
|
# Switch sections in the middle of a function
|
|
.section .text.foo, "ax"
|
|
.globl foo
|
|
.align 32, 0x90
|
|
.type foo,@function
|
|
# CHECK-LABEL: foo:
|
|
foo:
|
|
inc %eax
|
|
tmp3:
|
|
.rodata
|
|
.type obj,@object
|
|
.comm obj,4,4
|
|
.section .text.foo
|
|
inc %eax
|
|
# CHECK: tmp3:
|
|
# CHECK-NEXT: 1: incl
|