Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / arm-fix-cortex-a8-nopatch.s
blob5b029e46782ce482becadd5d83b8ffe8df59746b
1 // REQUIRES: arm
2 // RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf --arm-add-build-attributes %s -o %t.o
3 // RUN: ld.lld --fix-cortex-a8 -verbose %t.o -o %t2
4 // RUN: llvm-objdump -d %t2 --start-address=0x21ffa --stop-address=0x22002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE1 %s
5 // RUN: llvm-objdump -d %t2 --start-address=0x22ffa --stop-address=0x23002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE2 %s
6 // RUN: llvm-objdump -d %t2 --start-address=0x23ffa --stop-address=0x24002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE3 %s
7 // RUN: llvm-objdump -d %t2 --start-address=0x24ffa --stop-address=0x25006 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE4 %s
8 // RUN: llvm-objdump -d %t2 --start-address=0x25ffe --stop-address=0x26002 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE5 %s
9 // RUN: llvm-objdump -d %t2 --start-address=0x27000 --stop-address=0x28004 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE6 %s
10 // RUN: llvm-objdump -d %t2 --start-address=0x28002 --stop-address=0x29006 --no-show-raw-insn | FileCheck --check-prefix=CALLSITE7 %s
12 /// Test boundary conditions of the cortex-a8 erratum. The following cases
13 /// should not trigger the Erratum
14 .syntax unified
15 .thumb
16 .text
17 .global _start
18 .balign 4096
19 .thumb_func
20 _start:
21 nop.w
22 .space 4086
23 .thumb_func
24 target:
25 /// 32-bit branch spans 2 4KiB regions, preceded by a 32-bit branch so no patch
26 /// expected.
27 b.w target
28 b.w target
30 // CALLSITE1: 00021ffa <target>:
31 // CALLSITE1-NEXT: 21ffa: b.w 0x21ffa <target>
32 // CALLSITE1-NEXT: 21ffe: b.w 0x21ffa <target>
34 .space 4088
35 .type target2, %function
36 target2:
37 /// 32-bit Branch and link spans 2 4KiB regions, preceded by a 16-bit
38 /// instruction so no patch expected.
39 nop
40 nop
41 bl target2
43 // CALLSITE2: 00022ffa <target2>:
44 // CALLSITE2-NEXT: 22ffa: nop
45 // CALLSITE2-NEXT: 22ffc: nop
46 // CALLSITE2-NEXT: 22ffe: bl 0x22ffa <target2>
48 .space 4088
49 .type target3, %function
50 target3:
51 /// 32-bit conditional branch spans 2 4KiB regions, preceded by a 32-bit
52 /// non branch instruction, branch is backwards but outside 4KiB region. So
53 /// expect no patch.
54 nop.w
55 beq.w target2
57 // CALLSITE3: 00023ffa <target3>:
58 // CALLSITE3-NEXT: 23ffa: nop.w
59 // CALLSITE3-NEXT: 23ffe: beq.w 0x22ffa <target2>
61 .space 4088
62 .type source4, %function
63 source4:
64 /// 32-bit conditional branch spans 2 4KiB regions, preceded by a 32-bit
65 /// non branch instruction, branch is forwards to 2nd region so expect no patch.
66 nop.w
67 beq.w target4
68 .thumb_func
69 target4:
70 nop.w
72 // CALLSITE4: 00024ffa <source4>:
73 // CALLSITE4-NEXT: 24ffa: nop.w
74 // CALLSITE4-NEXT: 24ffe: beq.w 0x25002 <target4>
75 // CALLSITE4: 00025002 <target4>:
76 // CALLSITE4-NEXT: 25002: nop.w
78 .space 4082
79 .type target5, %function
81 target5:
82 /// 32-bit conditional branch spans 2 4KiB regions, preceded by the encoding of
83 /// a 32-bit thumb instruction, but in ARM state (illegal instruction), we
84 /// should not decode and match it as Thumb, expect no patch.
85 .arm
86 .short 0xbf00 // nop encoding in Thumb for alignment
87 .inst 0xf3af8000 /// nop.w encoding in Thumb
88 .thumb
89 .thumb_func
90 source5:
91 beq.w target5
93 // CALLSITE5: 00025ffe <source5>:
94 // CALLSITE5-NEXT: 25ffe: beq.w 0x25ff8 <target5>
96 /// Edge case where two word sequence starts at offset 0xffc, check that
97 /// we don't match. In this case the branch will be completely in the 2nd
98 /// region and the branch will target the second region. This will pass a
99 /// branch destination in the same region test, but not the branch must have
100 /// and address of the form xxxxxffe.
101 .space 4090
102 .type target6, %function
103 nop.w
104 /// Make sure target of branch is in the same 4KiB region as the branch.
105 target6:
106 bl target6
108 // CALLSITE6: 00027000 <target6>:
109 // CALLSITE6-NEXT: 27000: bl 0x27000 <target6>
111 /// Edge case where two word sequence starts at offset 0xffe, check that
112 /// we don't match. In this case the branch will be completely in the 2nd
113 /// region and the branch will target the second region. This will pass a
114 /// branch destination in the same region test, but not the branch must have
115 /// and address of the form xxxxxffe.
116 .space 4090
117 .type target7, %function
118 nop.w
119 /// Make sure target of branch is in the same 4KiB region as the branch.
120 target7:
121 bl target7
123 // CALLSITE7: 00028002 <target7>:
124 // CALLSITE7: 28002: bl 0x28002 <target7>