[llvm] e71b07e - [MC] [Win64EH] Wrap the epilog instructions in a struct. NFC.

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 01:26:34 PDT 2022


Author: Martin Storsjö
Date: 2022-06-01T11:25:48+03:00
New Revision: e71b07e468b34b18519102a58c20e32ee716976b

URL: https://github.com/llvm/llvm-project/commit/e71b07e468b34b18519102a58c20e32ee716976b
DIFF: https://github.com/llvm/llvm-project/commit/e71b07e468b34b18519102a58c20e32ee716976b.diff

LOG: [MC] [Win64EH] Wrap the epilog instructions in a struct. NFC.

For ARM SEH, the epilogs will need a little more associated data than
just the plain list of opcodes.

This is a preparatory refactoring for D125645.

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

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCWinEH.h
    llvm/lib/MC/MCWin64EH.cpp
    llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCWinEH.h b/llvm/include/llvm/MC/MCWinEH.h
index 5688255810d02..045bf586d1f15 100644
--- a/llvm/include/llvm/MC/MCWinEH.h
+++ b/llvm/include/llvm/MC/MCWinEH.h
@@ -54,7 +54,10 @@ struct FrameInfo {
   int LastFrameInst = -1;
   const FrameInfo *ChainedParent = nullptr;
   std::vector<Instruction> Instructions;
-  MapVector<MCSymbol*, std::vector<Instruction>> EpilogMap;
+  struct Epilog {
+    std::vector<Instruction> Instructions;
+  };
+  MapVector<MCSymbol *, Epilog> EpilogMap;
 
   FrameInfo() = default;
   FrameInfo(const MCSymbol *Function, const MCSymbol *BeginFuncEHLabel)
@@ -68,7 +71,7 @@ struct FrameInfo {
     if (!Instructions.empty())
       return false;
     for (const auto &E : EpilogMap)
-      if (!E.second.empty())
+      if (!E.second.Instructions.empty())
         return false;
     return true;
   }

diff  --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp
index bc7368567d2c2..8f9108a064f69 100644
--- a/llvm/lib/MC/MCWin64EH.cpp
+++ b/llvm/lib/MC/MCWin64EH.cpp
@@ -525,7 +525,7 @@ FindMatchingEpilog(const std::vector<WinEH::Instruction>& EpilogInstrs,
     auto InstrsIter = info->EpilogMap.find(EpilogStart);
     assert(InstrsIter != info->EpilogMap.end() &&
            "Epilog not found in EpilogMap");
-    const auto &Instrs = InstrsIter->second;
+    const auto &Instrs = InstrsIter->second.Instructions;
 
     if (Instrs.size() != EpilogInstrs.size())
       continue;
@@ -633,7 +633,7 @@ static int checkPackedEpilog(MCStreamer &streamer, WinEH::FrameInfo *info,
     return -1;
 
   const std::vector<WinEH::Instruction> &Epilog =
-      info->EpilogMap.begin()->second;
+      info->EpilogMap.begin()->second.Instructions;
 
   // Check that the epilog actually is at the very end of the function,
   // otherwise it can't be packed.
@@ -931,7 +931,7 @@ static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info,
 
   simplifyOpcodes(info->Instructions, false);
   for (auto &I : info->EpilogMap)
-    simplifyOpcodes(I.second, true);
+    simplifyOpcodes(I.second.Instructions, true);
 
   MCContext &context = streamer.getContext();
   MCSymbol *Label = context.createTempSymbol();
@@ -1003,7 +1003,7 @@ static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info,
 
   for (auto &I : info->EpilogMap) {
     MCSymbol *EpilogStart = I.first;
-    auto &EpilogInstrs = I.second;
+    auto &EpilogInstrs = I.second.Instructions;
     uint32_t CodeBytes = ARM64CountOfUnwindCodes(EpilogInstrs);
 
     MCSymbol* MatchingEpilog =
@@ -1085,7 +1085,7 @@ static void ARM64EmitUnwindInfo(MCStreamer &streamer, WinEH::FrameInfo *info,
 
   // Emit epilog unwind instructions
   for (auto &I : info->EpilogMap) {
-    auto &EpilogInstrs = I.second;
+    auto &EpilogInstrs = I.second.Instructions;
     for (const WinEH::Instruction &inst : EpilogInstrs)
       ARM64EmitUnwindCode(streamer, inst);
   }

diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp
index 975ed41809d74..820d940c1ed2d 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64WinCOFFStreamer.cpp
@@ -74,7 +74,7 @@ void AArch64TargetWinCOFFStreamer::emitARM64WinUnwindCode(unsigned UnwindCode,
     return;
   auto Inst = WinEH::Instruction(UnwindCode, /*Label=*/nullptr, Reg, Offset);
   if (InEpilogCFI)
-    CurFrame->EpilogMap[CurrentEpilog].push_back(Inst);
+    CurFrame->EpilogMap[CurrentEpilog].Instructions.push_back(Inst);
   else
     CurFrame->Instructions.push_back(Inst);
 }
@@ -201,7 +201,7 @@ void AArch64TargetWinCOFFStreamer::emitARM64WinCFIEpilogEnd() {
   InEpilogCFI = false;
   WinEH::Instruction Inst =
       WinEH::Instruction(Win64EH::UOP_End, /*Label=*/nullptr, -1, 0);
-  CurFrame->EpilogMap[CurrentEpilog].push_back(Inst);
+  CurFrame->EpilogMap[CurrentEpilog].Instructions.push_back(Inst);
   CurrentEpilog = nullptr;
 }
 


        


More information about the llvm-commits mailing list