[llvm-readobj] [ARMWinEH] Clearly print an invalid case of packed unwind info as...
authorMartin Storsjö <martin@martin.st>
Sun, 15 Nov 2020 22:28:33 +0000 (00:28 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 8 Jan 2021 08:04:44 +0000 (10:04 +0200)
As the actual windows unwinder doesn't support this case, don't
pretend that it is supported when dumping the generated unwind info
either, even if it would be possible to interpret it as something
sensible.

This should reduce the risk of us emitting such a case in code
(although it's unlikely as long as the unwind info is generated
through the SEH opcodes, as the opcodes can't describe this case).

Differential Revision: https://reviews.llvm.org/D91529

llvm/test/tools/llvm-readobj/COFF/arm64-packed-unwind.s
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp

index f8c4d5e..155c292 100644 (file)
 // CHECK-NEXT:     FrameSize: 32
 // CHECK-NEXT:     Prologue [
 // CHECK-NEXT:       sub sp, sp, #16
-// CHECK-NEXT:       stp x19, lr, [sp, #-16]!
+// CHECK-NEXT:       INVALID!
 // CHECK-NEXT:       end
 // CHECK-NEXT:     ]
 // CHECK-NEXT:   }
index 46a949b..5995a09 100644 (file)
@@ -1223,10 +1223,12 @@ bool Decoder::dumpPackedARM64Entry(const object::COFFObjectFile &COFF,
     if (I == (RF.RegI() + 1) / 2 - 1 && RF.RegI() % 2 == 1) {
       // The last register, an odd register without a pair
       if (RF.CR() == 1) {
-        if (I == 0) // If this is the only register pair
-          SW.startLine() << format("stp x%d, lr, [sp, #-%d]!\n", 19 + 2 * I,
-                                   SavSZ);
-        else
+        if (I == 0) { // If this is the only register pair
+          // CR=1 combined with RegI=1 doesn't map to a documented case;
+          // it doesn't map to any regular unwind info opcode, and the
+          // actual unwinder doesn't support it.
+          SW.startLine() << "INVALID!\n";
+        } else
           SW.startLine() << format("stp x%d, lr, [sp, #%d]\n", 19 + 2 * I,
                                    16 * I);
       } else {