[llvm] 8060283 - [llvm-readobj] [ARMWinEH] Print set_fp/add_fp differently in epilogues
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 01:41:27 PDT 2020
Author: Martin Storsjö
Date: 2020-09-10T11:26:43+03:00
New Revision: 8060283ff8b73195c400e18acf947e04bf5ec980
URL: https://github.com/llvm/llvm-project/commit/8060283ff8b73195c400e18acf947e04bf5ec980
DIFF: https://github.com/llvm/llvm-project/commit/8060283ff8b73195c400e18acf947e04bf5ec980.diff
LOG: [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
Added:
Modified:
llvm/test/CodeGen/AArch64/wineh6.mir
llvm/test/CodeGen/AArch64/wineh7.mir
llvm/test/tools/llvm-readobj/COFF/arm64-unwind-opcodes.s
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/AArch64/wineh6.mir b/llvm/test/CodeGen/AArch64/wineh6.mir
index 3ea7c0f20d45..95a11aa3c4e8 100644
--- a/llvm/test/CodeGen/AArch64/wineh6.mir
+++ b/llvm/test/CodeGen/AArch64/wineh6.mir
@@ -20,7 +20,7 @@
# CHECK-NEXT: StartOffset: 20
# CHECK-NEXT: EpilogueStartIndex: 4
# CHECK-NEXT: Opcodes [
-# CHECK-NEXT: 0xe1 ; mov fp, sp
+# CHECK-NEXT: 0xe1 ; mov sp, fp
# CHECK-NEXT: 0x81 ; ldp x29, x30, [sp], #16
# CHECK-NEXT: 0xe4 ; end
# CHECK-NEXT: ]
diff --git a/llvm/test/CodeGen/AArch64/wineh7.mir b/llvm/test/CodeGen/AArch64/wineh7.mir
index c445cbfd6b00..da64b3c002f3 100644
--- a/llvm/test/CodeGen/AArch64/wineh7.mir
+++ b/llvm/test/CodeGen/AArch64/wineh7.mir
@@ -21,7 +21,7 @@
# CHECK-NEXT: StartOffset: 13
# CHECK-NEXT: EpilogueStartIndex: 8
# CHECK-NEXT: Opcodes [
-# CHECK-NEXT: 0xe204 ; add fp, sp, #32
+# CHECK-NEXT: 0xe204 ; sub sp, fp, #32
# CHECK-NEXT: 0x44 ; ldp x29, x30, [sp, #32]
# CHECK-NEXT: 0xc802 ; ldp x19, x20, [sp, #16]
# CHECK-NEXT: 0xcc85 ; ldp x21, x22, [sp], #48
diff --git a/llvm/test/tools/llvm-readobj/COFF/arm64-unwind-opcodes.s b/llvm/test/tools/llvm-readobj/COFF/arm64-unwind-opcodes.s
index 98e2da8fb226..8ac8f6c98e27 100644
--- a/llvm/test/tools/llvm-readobj/COFF/arm64-unwind-opcodes.s
+++ b/llvm/test/tools/llvm-readobj/COFF/arm64-unwind-opcodes.s
@@ -1,12 +1,25 @@
// REQUIRES: aarch64-registered-target
-// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o - \
-// RUN: | llvm-readobj --unwind - | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple aarch64-windows %s -o %t.o
+// RUN: llvm-readobj --unwind %t.o | FileCheck --strict-whitespace %s
// CHECK: Prologue [
+// CHECK-NEXT: 0xe202 ; add fp, sp, #16
+// CHECK-NEXT: 0xe1 ; mov fp, sp
// CHECK-NEXT: 0xdc01 ; str d8, [sp, #8]
// CHECK-NEXT: 0xd400 ; str x19, [sp, #-8]!
// CHECK-NEXT: 0xe4 ; end
// CHECK-NEXT: ]
+// CHECK-NEXT: EpilogueScopes [
+// CHECK-NEXT: EpilogueScope {
+// CHECK-NEXT: StartOffset:
+// CHECK-NEXT: EpilogueStartIndex:
+// CHECK-NEXT: Opcodes [
+// CHECK-NEXT: 0xe202 ; sub sp, fp, #16
+// CHECK-NEXT: 0xe1 ; mov sp, fp
+// CHECK-NEXT: 0xe4 ; end
+// CHECK-NEXT: ]
+// CHECK-NEXT: }
+// CHECK-NEXT: ]
.section .pdata,"dr"
.long func at IMGREL
@@ -16,9 +29,18 @@
.globl func
func:
str x19, [sp, #-8]!
- str d8, [sp, #8]
+ str d8, [sp, #8]
+ mov x29, sp
+ add x29, sp, #16
+ nop
+ sub sp, x29, #16
+ mov sp, x29
ret
.section .xdata,"dr"
"$unwind$func":
-.long 0x10000002, 0x00d401dc, 0xe3e3e3e4
+.byte 0x08, 0x00, 0x40, 0x18
+.byte 0x05, 0x00, 0x00, 0x02
+.byte 0xe2, 0x02, 0xe1, 0xdc
+.byte 0x01, 0xd4, 0x00, 0xe4
+.byte 0xe2, 0x02, 0xe1, 0xe4
diff --git a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
index d75318517705..c2a84e3ba483 100644
--- a/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
+++ b/llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
@@ -746,7 +746,9 @@ bool Decoder::opcode_alloc_l(const uint8_t *OC, unsigned &Offset,
bool Decoder::opcode_setfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
bool Prologue) {
- SW.startLine() << format("0x%02x ; mov fp, sp\n", OC[Offset]);
+ SW.startLine() << format("0x%02x ; mov %s, %s\n", OC[Offset],
+ static_cast<const char *>(Prologue ? "fp" : "sp"),
+ static_cast<const char *>(Prologue ? "sp" : "fp"));
++Offset;
return false;
}
@@ -754,8 +756,11 @@ bool Decoder::opcode_setfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
bool Decoder::opcode_addfp(const uint8_t *OC, unsigned &Offset, unsigned Length,
bool Prologue) {
unsigned NumBytes = OC[Offset + 1] << 3;
- SW.startLine() << format("0x%02x%02x ; add fp, sp, #%u\n",
- OC[Offset], OC[Offset + 1], NumBytes);
+ SW.startLine() << format(
+ "0x%02x%02x ; %s %s, %s, #%u\n", OC[Offset], OC[Offset + 1],
+ static_cast<const char *>(Prologue ? "add" : "sub"),
+ static_cast<const char *>(Prologue ? "fp" : "sp"),
+ static_cast<const char *>(Prologue ? "sp" : "fp"), NumBytes);
Offset += 2;
return false;
}
More information about the llvm-commits
mailing list