[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / basic-block-sections-pc32reloc.s
blobf276cd9fac731a822fe84b2c0d30f97bd3422adb
1 # REQUIRES: x86
2 ## basic-block-sections tests.
3 ## This simple test checks if redundant direct jumps are converted to
4 ## implicit fallthrus when PC32 reloc is present. The jcc's must be converted
5 ## to their inverted opcode, for instance jne to je and jmp must be deleted.
7 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
8 # RUN: llvm-objdump -dr %t.o| FileCheck %s --check-prefix=RELOC
9 # RUN: ld.lld --optimize-bb-jumps %t.o -o %t.out
10 # RUN: llvm-objdump -d %t.out| FileCheck %s
12 # RELOC: jmp
13 # RELOC-NEXT: R_X86_64_PC32
15 # CHECK: <foo>:
16 # CHECK-NEXT: nopl (%rax)
17 # CHECK-NEXT: jne 0x{{[[:xdigit:]]+}} <r.BB.foo>
18 # CHECK-NOT: jmp
21 .section .text,"ax",@progbits
22 .type foo,@function
23 foo:
24 nopl (%rax)
25 je a.BB.foo
26 # Encode a jmp r.BB.foo insn using a PC32 reloc
27 .byte 0xe9
28 .long r.BB.foo - . - 4
30 # CHECK: <a.BB.foo>:
31 # CHECK-NEXT: nopl (%rax)
33 .section .text,"ax",@progbits,unique,3
34 a.BB.foo:
35 nopl (%rax)
36 r.BB.foo:
37 ret