Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / X86 / gotpcrelx.s
blob090a433143156dc0267a769ac226b17774d5f231
1 # REQUIRES: system-linux
3 ## Check that BOLT correctly handles different types of instructions with
4 ## R_X86_64_GOTPCRELX or R_X86_64_REX_GOTPCRELX relocations and different
5 ## kinds of handling of the relocation by the linker (no relaxation, pic, and
6 ## non-pic).
8 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux \
9 # RUN: -relax-relocations %s -o %t.o
10 # RUN: ld.lld %t.o -o %t.exe -q
11 # RUN: ld.lld %t.o -o %t.pie.exe -q -pie
12 # RUN: ld.lld %t.o -o %t.no-relax.exe -q --no-relax
13 # RUN: llvm-bolt %t.exe --relocs -o %t.out --print-cfg --print-only=_start \
14 # RUN: |& FileCheck --check-prefix=BOLT %s
15 # RUN: llvm-bolt %t.pie.exe -o /dev/null --print-cfg --print-only=_start \
16 # RUN: |& FileCheck --check-prefix=PIE-BOLT %s
17 # RUN: llvm-bolt %t.no-relax.exe -o /dev/null --print-cfg --print-only=_start \
18 # RUN: |& FileCheck --check-prefix=NO-RELAX-BOLT %s
19 # RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
20 # RUN: %t.out | FileCheck --check-prefix=DISASM %s
22 ## Relocate foo only and check that code references from _start (that is
23 ## otherwise preserved) are updated.
25 # RUN: llvm-bolt %t.exe --relocs -o %t.lite.out --funcs=foo
26 # RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
27 # RUN: %t.lite.out | FileCheck --check-prefix=DISASM %s
29 .text
30 .globl _start
31 .type _start, %function
32 _start:
33 .cfi_startproc
34 # DISASM: <_start>:
36 call *foo@GOTPCREL(%rip)
37 # NO-RELAX-BOLT: callq *{{.*}}(%rip)
38 # BOLT: callq foo
39 # PIE-BOLT: callq foo
40 # DISASM-NEXT: callq 0x[[#%x,ADDR:]]
42 movq foo@GOTPCREL(%rip), %rdi
43 # NO-RELAX-BOLT-NEXT: movq {{.*}}(%rip), %rdi
44 # BOLT-NEXT: leaq foo(%rip), %rdi
45 # PIE-BOLT-NEXT: leaq foo(%rip), %rdi
46 # DISASM-NEXT: leaq {{.*}}(%rip), %rdi # 0x[[#ADDR]]
48 movl foo@GOTPCREL+4(%rip), %edi
49 # NO-RELAX-BOLT-NEXT: movl {{.*}}(%rip), %edi
50 # BOLT-NEXT: movl {{.*}}(%rip), %edi
51 # PIE-BOLT-NEXT: movl {{.*}}(%rip), %edi
52 # DISASM-NEXT: movl {{.*}}(%rip), %edi
54 test %rdi, foo@GOTPCREL(%rip)
55 # NO-RELAX-BOLT-NEXT: testq %rdi, DATA{{.*}}(%rip)
56 # BOLT-NEXT: testq $foo, %rdi
57 # PIE-BOLT-NEXT: testq %rdi, DATA{{.*}}(%rip)
58 # DISASM-NEXT: testq $0x[[#ADDR]], %rdi
60 cmpq foo@GOTPCREL(%rip), %rax
61 # NO-RELAX-BOLT-NEXT: cmpq DATA{{.*}}(%rip), %rax
62 # BOLT-NEXT: cmpq $foo, %rax
63 # PIE-BOLT-NEXT: cmpq DATA{{.*}}(%rip), %rax
64 # DISASM-NEXT: cmpq $0x[[#ADDR]], %rax
66 jmp *foo@GOTPCREL(%rip)
67 # NO-RELAX-BOLT-NEXT: jmpq *DATA{{.*}}(%rip)
68 # BOLT-NEXT: jmp foo
69 # PIE-BOLT-NEXT: jmp foo
70 # DISASM-NEXT: jmp 0x[[#ADDR]]
72 # DISASM: [[#ADDR]] <foo>:
74 ret
75 .cfi_endproc
76 .size _start, .-_start
78 .globl foo
79 .type foo, %function
80 foo:
81 .cfi_startproc
82 ret
83 .cfi_endproc
84 .size foo, .-foo