[PATCH] D104701: [ARMInstPrinter] Print the target address of a branch instruction
Peter Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 25 02:24:24 PDT 2021
peter.smith added a comment.
My apologies for the delay, it has been a busy week at work and I've not had any spare time to review.
The code changes LGTM. There are a few places in the test where we could simplify with llvm-objdump --no-show-raw-insn, but this patch is big enough already. I did get some test failures although I think that this is due to the filecheck commands used and not the code-changes, details below.
I applied the patch to main (as of d07f43641f98a8e0024cf8e94ef98c7c912221d9 <https://reviews.llvm.org/rGd07f43641f98a8e0024cf8e94ef98c7c912221d9>) as I wanted to see if I could look into the other two problems. I ran into some test failures that I don't quite now whether they are my environment or whether something else has changed since the patch was submitted. In each case it looks like llvm-objdump is doing what we'd expect but It looks like the {{.*}} may be matching other parts of the disassembly, or is doing something slightly different on my system Ubuntu 18.04.
If anyone else can run to see if it is just my system, or something that isn't stable between systems, I'd be grateful to know.
My results:
Failed Tests (10):
lld :: COFF/armnt-blx23t.test
lld :: COFF/armnt-branch24t.test
lld :: COFF/delayimports-armnt.yaml
lld :: ELF/arm-fix-cortex-a8-blx.s
lld :: ELF/arm-fix-cortex-a8-recognize.s
lld :: ELF/arm-thumb-no-undefined-thunk.s
lld :: ELF/arm-thumb-undefined-weak-narrow.test
lld :: ELF/arm-thumb-undefined-weak.s
lld :: ELF/arm-undefined-weak.s
================
Comment at: lld/test/COFF/armnt-blx23t.test:15
# BEFORE: a: 20 20 movs r0, #32
-# BEFORE: c: 00 f0 00 f8 bl #0
+# BEFORE: c: 00 f0 00 f8 bl {{.+}} @ imm = #0
# BEFORE: 10: 01 30 adds r0, #1
----------------
I get test failures on my system.
```
Command Output (stderr):
--
/ssd/llvm-project/lld/test/COFF/armnt-blx23t.test:15:11: error: BEFORE: expected string not found in input
# BEFORE: c: 00 f0 00 f8 bl {{.+}} @ imm = #0
^
<stdin>:13:23: note: scanning from here
a: 20 20 movs r0, #32
^
<stdin>:14:2: note: possible intended match here
c: 00 f0 00 f8 bl 0x10 <function+0xc>
^
```
================
Comment at: lld/test/COFF/armnt-branch24t.test:13
# BEFORE: 4: 20 20 movs r0, #32
-# BEFORE: 6: 00 f0 00 b8 b.w #0
+# BEFORE: 6: 00 f0 00 b8 b.w {{.+}} @ imm = #0
----------------
I get test failures on my system
```
# BEFORE: 6: 00 f0 00 b8 b.w {{.+}} @ imm = #0
^
<stdin>:11:23: note: scanning from here
4: 20 20 movs r0, #32
^
<stdin>:12:2: note: possible intended match here
6: 00 f0 00 b8 b.w 0xa <function+0x6>
^
```
================
Comment at: lld/test/COFF/delayimports-armnt.yaml:54
#
+# DISASM: 00401000 <.text>:
# DISASM: 40100c: 43 f2 08 0c movw r12, #12296
----------------
I get test failures:
```
/ssd/llvm-project/lld/test/COFF/delayimports-armnt.yaml:57:16: error: DISASM-NEXT: expected string not found in input
# DISASM-NEXT: 00 f0 00 b8 b.w {{.+}} @ imm = #0
^
<stdin>:12:35: note: scanning from here
401010: c0 f2 40 0c movt r12, #64
^
<stdin>:13:10: note: possible intended match here
401014: 00 f0 00 b8 b.w 0x401018 <.text+0x18>
^
```
================
Comment at: lld/test/ELF/arm-fix-cortex-a8-blx.s:30
// CHECK-PATCH: 21ffa: nop.w
+// CHECK-PATCH-NEXT: 21ffe: blx 0x22004 <__CortexA8657417_21FFE>
----------------
I get a test failure
```
/ssd/llvm-project/lld/test/ELF/arm-fix-cortex-a8-blx.s:34:22: error: CHECK-PATCH-NEXT: expected string not found in input
// CHECK-PATCH-NEXT: 22004: b 0x21004 <{{.+}}> @ imm = #-4104
^
<stdin>:11:35: note: scanning from here
00022004 <__CortexA8657417_21FFE>:
^
<stdin>:12:2: note: possible intended match here
22004: b 0x21004 <$d.1>
^
```
My disassembly is:
```
Disassembly of section .text:
00021ffa <$t.2>:
21ffa: nop.w
21ffe: blx 0x22004 <__CortexA8657417_21FFE>
22002: bmi 0x21fae <$d.1+0xfaa>
00022004 <__CortexA8657417_21FFE>:
22004: b 0x21004 <$d.1>
```
================
Comment at: lld/test/ELF/arm-fix-cortex-a8-recognize.s:58
// CALLSITE1-NEXT: 21ffa: nop.w
-// CALLSITE1-NEXT: 21ffe: b.w #28674
+// CALLSITE1-NEXT: 21ffe: b.w 0x29004 <__CortexA8657417_21FFE>
/// Expect no patch when doing a relocatable link ld -r.
----------------
I get a test failure with:
```
/ssd/llvm-project/lld/test/ELF/arm-fix-cortex-a8-recognize.s:62:28: error: CHECK-RELOCATABLE-NEXT: expected string not found in input
// CHECK-RELOCATABLE-NEXT: ffe: b.w {{.+}} @ imm = #-4
^
<stdin>:7:12: note: scanning from here
ffa: nop.w
^
<stdin>:8:2: note: possible intended match here
ffe: b.w 0xffe <target+0x4>
^
```
================
Comment at: lld/test/ELF/arm-thumb-no-undefined-thunk.s:22
// CHECK-NEXT: <_start>:
-// 0x110b8 = next instruction
-// CHECK: 200b4: {{.*}} bl #0
-// CHECK-NEXT: 200b8: {{.*}} b.w #0 <_start+0x8>
-// CHECK-NEXT: 200bc: {{.*}} b.w #0 <_start+0xc>
+// 0x200b8 = next instruction
+// CHECK: 200b4: {{.*}} bl 0x200b8 <_start+0x4> @ imm = #0
----------------
I get a test failure here:
```
// CHECK: 200b4: {{.*}} bl 0x200b8 <_start+0x4> @ imm = #0
^
<stdin>:6:19: note: scanning from here
000200b4 <_start>:
^
<stdin>:7:15: note: possible intended match here
200b4: 00 f0 00 f8 bl 0x200b8 <_start+0x4>
^
```
================
Comment at: lld/test/ELF/arm-thumb-undefined-weak-narrow.test:8
# CHECK-EMPTY:
# CHECK-NEXT: <_start>:
+# CHECK-NEXT: ff e7 b 0x200b6 <_start+0x2> @ imm = #-2
----------------
I get a test failure with a dissasembly of:
```
000200b4 <_start>:
200b4: ff e7 b 0x200b6 <_start+0x2>
```
Not sure why that isn't matching for me.
================
Comment at: lld/test/ELF/arm-thumb-undefined-weak.s:4
// RUN: ld.lld %t -o %t2
// RUN: llvm-objdump --triple=thumbv7a-none-linux-gnueabi -d %t2 | FileCheck %s
----------------
can add --no-show-raw-insn to miss out matched with {{.*}}
================
Comment at: lld/test/ELF/arm-thumb-undefined-weak.s:39
// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
+// CHECK: 200b4: {{.*}} beq.w 0x200b8 <_start+0x4> @ imm = #0
----------------
I see failures:
```
/ssd/llvm-project/lld/test/ELF/arm-thumb-undefined-weak.s:40:11: error: CHECK: expected string not found in input
// CHECK: 200b4: {{.*}} beq.w 0x200b8 <_start+0x4> @ imm = #0
^
<stdin>:5:1: note: scanning from here
^
<stdin>:7:15: note: possible intended match here
200b4: 00 f0 00 80 beq.w 0x200b8 <_start+0x4>
^
```
================
Comment at: lld/test/ELF/arm-undefined-weak.s:35
// CHECK-EMPTY:
// CHECK-NEXT: 100100b4 <_start>:
+// CHECK-NEXT: 100100b4: b {{.+}} @ imm = #-4
----------------
When I run the patch locally I get test failures, even though the disassembly is what I would expect, a branch to the next instruction
The test output is
```
/ssd/llvm-project/lld/test/ELF/arm-undefined-weak.s:37:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: 100100b4: b {{.+}} @ imm = #-4
^
<stdin>:6:19: note: scanning from here
100100b4 <_start>:
^
<stdin>:7:1: note: possible intended match here
100100b4: b 0x100100b8 <_start+0x4>
^
```
The disassembly I get is:
```
100100b4 <_start>:
100100b4: b 0x100100b8 <_start+0x4>
100100b8: bl 0x100100bc <_start+0x8>
100100bc: bl 0x100100c0 <_start+0xc>
100100c0: movt r0, #0
100100c4: movw r0, #0
100100c8 <$d.1>:
100100c8: 00 00 00 00 .word 0x00000000
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104701/new/
https://reviews.llvm.org/D104701
More information about the llvm-commits
mailing list