[AArch64] [SEH] Rename pac_sign_return_address to pac_sign_lr
authorMartin Storsjö <martin@martin.st>
Wed, 12 Oct 2022 11:27:22 +0000 (14:27 +0300)
committerMartin Storsjö <martin@martin.st>
Wed, 12 Oct 2022 19:19:59 +0000 (22:19 +0300)
This new opcode was initially documented as "pac_sign_return_address"
in https://github.com/MicrosoftDocs/cpp-docs/pull/4202, but was
soon afterwards renamed into "pac_sign_lr" in
https://github.com/MicrosoftDocs/cpp-docs/pull/4209, as the other
name was unwieldy, and there were no other external references to
that name anywhere.

Rename our external .seh assembler directive - it hasn't been merged
for very long yet, so there's probably no external use to account for.

Rename all other internal references to the opcode similarly.

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

llvm/include/llvm/Support/Win64EH.h
llvm/lib/MC/MCWin64EH.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp
llvm/test/MC/AArch64/seh-packed-unwind.s
llvm/test/MC/AArch64/seh.s
llvm/tools/llvm-readobj/ARMWinEHPrinter.cpp
llvm/tools/llvm-readobj/ARMWinEHPrinter.h

index 4bc3d81..93401bd 100644 (file)
@@ -61,7 +61,7 @@ enum UnwindOpcodes {
   UOP_TrapFrame,
   UOP_Context,
   UOP_ClearUnwoundToCall,
-  UOP_PACSignReturnAddress,
+  UOP_PACSignLR,
   // The following set of unwind opcodes is for ARM.  They are documented at
   // https://docs.microsoft.com/en-us/cpp/build/arm-exception-handling
 
index d2afb9c..6992048 100644 (file)
@@ -377,7 +377,7 @@ static uint32_t ARM64CountOfUnwindCodes(ArrayRef<WinEH::Instruction> Insns) {
     case Win64EH::UOP_ClearUnwoundToCall:
       Count += 1;
       break;
-    case Win64EH::UOP_PACSignReturnAddress:
+    case Win64EH::UOP_PACSignLR:
       Count += 1;
       break;
     }
@@ -546,7 +546,7 @@ static void ARM64EmitUnwindCode(MCStreamer &streamer,
     b = 0xEC;
     streamer.emitInt8(b);
     break;
-  case Win64EH::UOP_PACSignReturnAddress:
+  case Win64EH::UOP_PACSignLR:
     b = 0xFC;
     streamer.emitInt8(b);
     break;
@@ -759,7 +759,7 @@ static bool tryARM64PackedUnwind(WinEH::FrameInfo *info, uint32_t FuncLength,
         return false;
       Location = Start2;
       break;
-    case Win64EH::UOP_PACSignReturnAddress:
+    case Win64EH::UOP_PACSignLR:
       if (Location != Start2)
         return false;
       PAC = true;
index ebc4e53..6dbc304 100644 (file)
@@ -218,7 +218,7 @@ private:
   bool parseDirectiveSEHMachineFrame(SMLoc L);
   bool parseDirectiveSEHContext(SMLoc L);
   bool parseDirectiveSEHClearUnwoundToCall(SMLoc L);
-  bool parseDirectiveSEHPACSignReturnAddress(SMLoc L);
+  bool parseDirectiveSEHPACSignLR(SMLoc L);
 
   bool validateInstruction(MCInst &Inst, SMLoc &IDLoc,
                            SmallVectorImpl<SMLoc> &Loc);
@@ -6100,8 +6100,8 @@ bool AArch64AsmParser::ParseDirective(AsmToken DirectiveID) {
       parseDirectiveSEHContext(Loc);
     else if (IDVal == ".seh_clear_unwound_to_call")
       parseDirectiveSEHClearUnwoundToCall(Loc);
-    else if (IDVal == ".seh_pac_sign_return_address")
-      parseDirectiveSEHPACSignReturnAddress(Loc);
+    else if (IDVal == ".seh_pac_sign_lr")
+      parseDirectiveSEHPACSignLR(Loc);
     else
       return true;
   } else
@@ -6778,10 +6778,10 @@ bool AArch64AsmParser::parseDirectiveSEHClearUnwoundToCall(SMLoc L) {
   return false;
 }
 
-/// parseDirectiveSEHPACSignReturnAddress
-/// ::= .seh_pac_sign_return_address
-bool AArch64AsmParser::parseDirectiveSEHPACSignReturnAddress(SMLoc L) {
-  getTargetStreamer().emitARM64WinCFIPACSignReturnAddress();
+/// parseDirectiveSEHPACSignLR
+/// ::= .seh_pac_sign_lr
+bool AArch64AsmParser::parseDirectiveSEHPACSignLR(SMLoc L) {
+  getTargetStreamer().emitARM64WinCFIPACSignLR();
   return false;
 }
 
index 983a384..ec09ca2 100644 (file)
@@ -107,8 +107,8 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
   void emitARM64WinCFIClearUnwoundToCall() override {
     OS << "\t.seh_clear_unwound_to_call\n";
   }
-  void emitARM64WinCFIPACSignReturnAddress() override {
-    OS << "\t.seh_pac_sign_return_address\n";
+  void emitARM64WinCFIPACSignLR() override {
+    OS << "\t.seh_pac_sign_lr\n";
   }
 
 public:
index bdccb99..0a13e85 100644 (file)
@@ -67,7 +67,7 @@ public:
   virtual void emitARM64WinCFIMachineFrame() {}
   virtual void emitARM64WinCFIContext() {}
   virtual void emitARM64WinCFIClearUnwoundToCall() {}
-  virtual void emitARM64WinCFIPACSignReturnAddress() {}
+  virtual void emitARM64WinCFIPACSignLR() {}
 
 private:
   std::unique_ptr<AssemblerConstantPools> ConstantPools;
@@ -121,7 +121,7 @@ public:
   void emitARM64WinCFIMachineFrame() override;
   void emitARM64WinCFIContext() override;
   void emitARM64WinCFIClearUnwoundToCall() override;
-  void emitARM64WinCFIPACSignReturnAddress() override;
+  void emitARM64WinCFIPACSignLR() override;
 
 private:
   void emitARM64WinUnwindCode(unsigned UnwindCode, int Reg, int Offset);
index 0188bb1..26c066c 100644 (file)
@@ -221,8 +221,8 @@ void AArch64TargetWinCOFFStreamer::emitARM64WinCFIClearUnwoundToCall() {
   emitARM64WinUnwindCode(Win64EH::UOP_ClearUnwoundToCall, -1, 0);
 }
 
-void AArch64TargetWinCOFFStreamer::emitARM64WinCFIPACSignReturnAddress() {
-  emitARM64WinUnwindCode(Win64EH::UOP_PACSignReturnAddress, -1, 0);
+void AArch64TargetWinCOFFStreamer::emitARM64WinCFIPACSignLR() {
+  emitARM64WinUnwindCode(Win64EH::UOP_PACSignLR, -1, 0);
 }
 
 MCWinCOFFStreamer *llvm::createAArch64WinCOFFStreamer(
index 4276c7f..ab2d27f 100644 (file)
@@ -729,7 +729,7 @@ func15:
 func16:
     .seh_proc func16
     pacibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     stp x29, lr,  [sp, #-32]!
     .seh_save_fplr_x 32
     mov x29, sp
@@ -740,7 +740,7 @@ func16:
     ldp x29, lr, [sp], #32
     .seh_save_fplr_x 32
     autibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     .seh_endepilogue
     ret
     .seh_endproc
@@ -748,7 +748,7 @@ func16:
 func17:
     .seh_proc func17
     pacibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     stp x19, x20, [sp, #-16]!
     .seh_save_r19r20_x 16
     stp x29, lr,  [sp, #-32]!
@@ -765,7 +765,7 @@ func17:
     ldp x19, x20, [sp], #16
     .seh_save_r19r20_x 16
     autibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     .seh_endepilogue
     ret
     .seh_endproc
@@ -773,7 +773,7 @@ func17:
 func18:
     .seh_proc func18
     pacibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     stp x19, x20, [sp, #-16]!
     .seh_save_r19r20_x 16
     sub sp,  sp,  #4080
@@ -798,7 +798,7 @@ func18:
     ldp x19, x20, [sp], #16
     .seh_save_r19r20_x 16
     autibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     .seh_endepilogue
     ret
     .seh_endproc
@@ -1075,7 +1075,7 @@ nonpacked14:
     // Can't be packed; a signed return address can only be expressed if
     // we save both x29 and lr on the stack.
     pacibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     str lr,       [sp, #-32]!
     .seh_save_reg_x lr, 32
     .seh_endprologue
@@ -1084,7 +1084,7 @@ nonpacked14:
     ldr lr,       [sp], #32
     .seh_save_reg_x lr, 32
     autibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     .seh_endepilogue
     ret
     .seh_endproc
@@ -1094,7 +1094,7 @@ nonpacked15:
     // Can't be packed; a signed return address can only be expressed if
     // we save both x29 and lr on the stack.
     pacibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     stp x19, x20, [sp, #-32]!
     .seh_save_r19r20_x 32
     stp x21, lr,  [sp, #16]
@@ -1111,7 +1111,7 @@ nonpacked15:
     ldp x19, x20, [sp], #32
     .seh_save_r19r20_x 32
     autibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     .seh_endepilogue
     ret
     .seh_endproc
index 23da04e..81569ba 100644 (file)
@@ -153,7 +153,7 @@ func:
     nop
     .seh_clear_unwound_to_call
     pacibsp
-    .seh_pac_sign_return_address
+    .seh_pac_sign_lr
     .seh_endprologue
     nop
     .seh_startepilogue
index d645345..88418e2 100644 (file)
@@ -172,7 +172,7 @@ const Decoder::RingEntry Decoder::Ring64[] = {
     {0xff, 0xe9, 1, &Decoder::opcode_machine_frame},
     {0xff, 0xea, 1, &Decoder::opcode_context},
     {0xff, 0xec, 1, &Decoder::opcode_clear_unwound_to_call},
-    {0xff, 0xfc, 1, &Decoder::opcode_pac_sign_return_address},
+    {0xff, 0xfc, 1, &Decoder::opcode_pac_sign_lr},
 };
 
 static void printRange(raw_ostream &OS, ListSeparator &LS, unsigned First,
@@ -977,9 +977,8 @@ bool Decoder::opcode_clear_unwound_to_call(const uint8_t *OC, unsigned &Offset,
   return false;
 }
 
-bool Decoder::opcode_pac_sign_return_address(const uint8_t *OC,
-                                             unsigned &Offset, unsigned Length,
-                                             bool Prologue) {
+bool Decoder::opcode_pac_sign_lr(const uint8_t *OC, unsigned &Offset,
+                                 unsigned Length, bool Prologue) {
   if (Prologue)
     SW.startLine() << format("0x%02x                ; pacibsp\n", OC[Offset]);
   else
index 745a9cb..0ffebe5 100644 (file)
@@ -131,8 +131,8 @@ class Decoder {
                       bool Prologue);
   bool opcode_clear_unwound_to_call(const uint8_t *Opcodes, unsigned &Offset,
                                     unsigned Length, bool Prologue);
-  bool opcode_pac_sign_return_address(const uint8_t *Opcodes, unsigned &Offset,
-                                      unsigned Length, bool Prologue);
+  bool opcode_pac_sign_lr(const uint8_t *Opcodes, unsigned &Offset,
+                          unsigned Length, bool Prologue);
 
   void decodeOpcodes(ArrayRef<uint8_t> Opcodes, unsigned Offset,
                      bool Prologue);