Skip to content

Commit 8060283

Browse files
committed
[llvm-readobj] [ARMWinEH] Print set_fp/add_fp differently in epilogues
This matches how e.g. stp/ldp and other opcodes are printed differently for epilogues. Also add a missing --strict-whitespace in an existing test that was added explicitly for testing vertical alignment, and change to using temp files for the generated object files. Differential Revision: https://reviews.llvm.org/D87363
1 parent 3c42c0d commit 8060283

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

llvm/test/CodeGen/AArch64/wineh6.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# CHECK-NEXT: StartOffset: 20
2121
# CHECK-NEXT: EpilogueStartIndex: 4
2222
# CHECK-NEXT: Opcodes [
23-
# CHECK-NEXT: 0xe1 ; mov fp, sp
23+
# CHECK-NEXT: 0xe1 ; mov sp, fp
2424
# CHECK-NEXT: 0x81 ; ldp x29, x30, [sp], #16
2525
# CHECK-NEXT: 0xe4 ; end
2626
# CHECK-NEXT: ]

llvm/test/CodeGen/AArch64/wineh7.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# CHECK-NEXT: StartOffset: 13
2222
# CHECK-NEXT: EpilogueStartIndex: 8
2323
# CHECK-NEXT: Opcodes [
24-
# CHECK-NEXT: 0xe204 ; add fp, sp, #32
24+
# CHECK-NEXT: 0xe204 ; sub sp, fp, #32
2525
# CHECK-NEXT: 0x44 ; ldp x29, x30, [sp, #32]
2626
# CHECK-NEXT: 0xc802 ; ldp x19, x20, [sp, #16]
2727
# CHECK-NEXT: 0xcc85 ; ldp x21, x22, [sp], #48
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
// REQUIRES: aarch64-registered-target
2-
// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o - \
3-
// RUN: | llvm-readobj --unwind - | FileCheck %s
2+
// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o %t.o
3+
// RUN: llvm-readobj --unwind %t.o | FileCheck --strict-whitespace %s
44

55
// CHECK: Prologue [
6+
// CHECK-NEXT: 0xe202 ; add fp, sp, #16
7+
// CHECK-NEXT: 0xe1 ; mov fp, sp
68
// CHECK-NEXT: 0xdc01 ; str d8, [sp, #8]
79
// CHECK-NEXT: 0xd400 ; str x19, [sp, #-8]!
810
// CHECK-NEXT: 0xe4 ; end
911
// CHECK-NEXT: ]
12+
// CHECK-NEXT: EpilogueScopes [
13+
// CHECK-NEXT: EpilogueScope {
14+
// CHECK-NEXT: StartOffset:
15+
// CHECK-NEXT: EpilogueStartIndex:
16+
// CHECK-NEXT: Opcodes [
17+
// CHECK-NEXT: 0xe202 ; sub sp, fp, #16
18+
// CHECK-NEXT: 0xe1 ; mov sp, fp
19+
// CHECK-NEXT: 0xe4 ; end
20+
// CHECK-NEXT: ]
21+
// CHECK-NEXT: }
22+
// CHECK-NEXT: ]
1023

1124
.section .pdata,"dr"
1225
.long func@IMGREL
@@ -16,9 +29,18 @@
1629
.globl func
1730
func:
1831
str x19, [sp, #-8]!
19-
str d8, [sp, #8]
32+
str d8, [sp, #8]
33+
mov x29, sp
34+
add x29, sp, #16
35+
nop
36+
sub sp, x29, #16
37+
mov sp, x29
2038
ret
2139

2240
.section .xdata,"dr"
2341
"$unwind$func":
24-
.long 0x10000002, 0x00d401dc, 0xe3e3e3e4
42+
.byte 0x08, 0x00, 0x40, 0x18
43+
.byte 0x05, 0x00, 0x00, 0x02
44+
.byte 0xe2, 0x02, 0xe1, 0xdc
45+
.byte 0x01, 0xd4, 0x00, 0xe4
46+
.byte 0xe2, 0x02, 0xe1, 0xe4

llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,16 +746,21 @@ bool Decoder::opcode_alloc_l(const uint8_t *OC, unsigned &Offset,
746746

747747
bool Decoder::opcode_setfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
748748
bool Prologue) {
749-
SW.startLine() << format("0x%02x ; mov fp, sp\n", OC[Offset]);
749+
SW.startLine() << format("0x%02x ; mov %s, %s\n", OC[Offset],
750+
static_cast<const char *>(Prologue ? "fp" : "sp"),
751+
static_cast<const char *>(Prologue ? "sp" : "fp"));
750752
++Offset;
751753
return false;
752754
}
753755

754756
bool Decoder::opcode_addfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
755757
bool Prologue) {
756758
unsigned NumBytes = OC[Offset + 1] << 3;
757-
SW.startLine() << format("0x%02x%02x ; add fp, sp, #%u\n",
758-
OC[Offset], OC[Offset + 1], NumBytes);
759+
SW.startLine() << format(
760+
"0x%02x%02x ; %s %s, %s, #%u\n", OC[Offset], OC[Offset + 1],
761+
static_cast<const char *>(Prologue ? "add" : "sub"),
762+
static_cast<const char *>(Prologue ? "fp" : "sp"),
763+
static_cast<const char *>(Prologue ? "sp" : "fp"), NumBytes);
759764
Offset += 2;
760765
return false;
761766
}

0 commit comments

Comments
 (0)