[Lldb-commits] [lldb] [lldb] Use UnwindPlan::Row as values (PR #131150)

via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 13 07:50:12 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)

<details>
<summary>Changes</summary>

In most places, the rows are copied anyway (because they are generated by cumulating modifications) immediately after adding them to the unwind plans. In others, they can be moved into the unwind plan. This lets us remove some backflip copies and make `const UnwindPlan` actually mean something.

I've split this patch into two (and temporarily left both APIs) as this patch was getting a bit big. This patch covers all the interesting cases. Part two all about converting "architecture default" unwind plans from ABI and InstructionEmulation plugins.

---

Patch is 65.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/131150.diff


10 Files Affected:

- (modified) lldb/include/lldb/Symbol/UnwindPlan.h (+4) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp (+13-13) 
- (modified) lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp (+37-38) 
- (modified) lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp (+12-15) 
- (modified) lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (+2-3) 
- (modified) lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp (+60-95) 
- (modified) lldb/source/Symbol/ArmUnwindInfo.cpp (+7-8) 
- (modified) lldb/source/Symbol/CompactUnwindInfo.cpp (+90-98) 
- (modified) lldb/source/Symbol/DWARFCallFrameInfo.cpp (+15-35) 
- (modified) lldb/unittests/UnwindAssembly/x86/Testx86AssemblyInspectionEngine.cpp (+66-99) 


``````````diff
diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h
index 462c1a52b01db..e4199d5677035 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -463,8 +463,12 @@ class UnwindPlan {
   void Dump(Stream &s, Thread *thread, lldb::addr_t base_addr) const;
 
   void AppendRow(const RowSP &row_sp);
+  void AppendRow(Row row) { AppendRow(std::make_shared<Row>(std::move(row))); }
 
   void InsertRow(const RowSP &row_sp, bool replace_existing = false);
+  void InsertRow(Row row, bool replace_existing = false) {
+    InsertRow(std::make_shared<Row>(std::move(row)), replace_existing);
+  }
 
   // Returns a pointer to the best row for the given offset into the function's
   // instructions. If offset is -1 it indicates that the function start is
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp
index 9bd48f2b9f60f..459abe417035e 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/PECallFrameInfo.cpp
@@ -351,7 +351,7 @@ class EHProgramRange {
   EHProgramRange(EHProgram::const_iterator begin,
                  EHProgram::const_iterator end);
 
-  std::unique_ptr<UnwindPlan::Row> BuildUnwindPlanRow() const;
+  UnwindPlan::Row BuildUnwindPlanRow() const;
 
 private:
   int32_t GetCFAFrameOffset() const;
@@ -364,11 +364,11 @@ EHProgramRange::EHProgramRange(EHProgram::const_iterator begin,
                                EHProgram::const_iterator end)
     : m_begin(begin), m_end(end) {}
 
-std::unique_ptr<UnwindPlan::Row> EHProgramRange::BuildUnwindPlanRow() const {
-  std::unique_ptr<UnwindPlan::Row> row = std::make_unique<UnwindPlan::Row>();
+UnwindPlan::Row EHProgramRange::BuildUnwindPlanRow() const {
+  UnwindPlan::Row row;
 
   if (m_begin != m_end)
-    row->SetOffset(m_begin->offset);
+    row.SetOffset(m_begin->offset);
 
   int32_t cfa_frame_offset = GetCFAFrameOffset();
 
@@ -376,8 +376,8 @@ std::unique_ptr<UnwindPlan::Row> EHProgramRange::BuildUnwindPlanRow() const {
   for (EHProgram::const_iterator it = m_begin; it != m_end; ++it) {
     switch (it->type) {
     case EHInstruction::Type::SET_FRAME_POINTER_REGISTER:
-      row->GetCFAValue().SetIsRegisterPlusOffset(it->reg, cfa_frame_offset -
-                                                              it->frame_offset);
+      row.GetCFAValue().SetIsRegisterPlusOffset(it->reg, cfa_frame_offset -
+                                                             it->frame_offset);
       frame_pointer_found = true;
       break;
     default:
@@ -387,14 +387,14 @@ std::unique_ptr<UnwindPlan::Row> EHProgramRange::BuildUnwindPlanRow() const {
       break;
   }
   if (!frame_pointer_found)
-    row->GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64,
-                                               cfa_frame_offset);
+    row.GetCFAValue().SetIsRegisterPlusOffset(lldb_rsp_x86_64,
+                                              cfa_frame_offset);
 
   int32_t rsp_frame_offset = 0;
   for (EHProgram::const_iterator it = m_begin; it != m_end; ++it) {
     switch (it->type) {
     case EHInstruction::Type::PUSH_REGISTER:
-      row->SetRegisterLocationToAtCFAPlusOffset(
+      row.SetRegisterLocationToAtCFAPlusOffset(
           it->reg, rsp_frame_offset - cfa_frame_offset, false);
       rsp_frame_offset += it->frame_offset;
       break;
@@ -402,7 +402,7 @@ std::unique_ptr<UnwindPlan::Row> EHProgramRange::BuildUnwindPlanRow() const {
       rsp_frame_offset += it->frame_offset;
       break;
     case EHInstruction::Type::SAVE_REGISTER:
-      row->SetRegisterLocationToAtCFAPlusOffset(
+      row.SetRegisterLocationToAtCFAPlusOffset(
           it->reg, it->frame_offset - cfa_frame_offset, false);
       break;
     default:
@@ -410,7 +410,7 @@ std::unique_ptr<UnwindPlan::Row> EHProgramRange::BuildUnwindPlanRow() const {
     }
   }
 
-  row->SetRegisterLocationToIsCFAPlusOffset(lldb_rsp_x86_64, 0, false);
+  row.SetRegisterLocationToIsCFAPlusOffset(lldb_rsp_x86_64, 0, false);
 
   return row;
 }
@@ -477,7 +477,7 @@ bool PECallFrameInfo::GetUnwindPlan(const AddressRange &range,
   if (!builder.Build())
     return false;
 
-  std::vector<UnwindPlan::RowSP> rows;
+  std::vector<UnwindPlan::Row> rows;
 
   uint32_t last_offset = UINT32_MAX;
   for (auto it = builder.GetProgram().begin(); it != builder.GetProgram().end();
@@ -493,7 +493,7 @@ bool PECallFrameInfo::GetUnwindPlan(const AddressRange &range,
   }
 
   for (auto it = rows.rbegin(); it != rows.rend(); ++it)
-    unwind_plan.AppendRow(*it);
+    unwind_plan.AppendRow(std::move(*it));
 
   unwind_plan.SetPlanValidAddressRange(AddressRange(
       m_object_file.GetAddress(runtime_function->StartAddress),
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 13465986f49c5..9db2c83acc125 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -210,8 +210,7 @@ static lldb::UnwindPlanSP GetAArch64TrapHandlerUnwindPlan(ConstString name) {
   if (name != "__kernel_rt_sigreturn")
     return unwind_plan_sp;
 
-  UnwindPlan::RowSP row = std::make_shared<UnwindPlan::Row>();
-  row->SetOffset(0);
+  UnwindPlan::Row row;
 
   // In the signal trampoline frame, sp points to an rt_sigframe[1], which is:
   //  - 128-byte siginfo struct
@@ -235,48 +234,48 @@ static lldb::UnwindPlanSP GetAArch64TrapHandlerUnwindPlan(ConstString name) {
 
   // Skip fault address
   offset += 8;
-  row->GetCFAValue().SetIsRegisterPlusOffset(arm64_dwarf::sp, offset);
-
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x0, 0 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x1, 1 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x2, 2 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x3, 3 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x4, 4 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x5, 5 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x6, 6 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x7, 7 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x8, 8 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x9, 9 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x10, 10 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x11, 11 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x12, 12 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x13, 13 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x14, 14 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x15, 15 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x16, 16 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x17, 17 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x18, 18 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x19, 19 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x20, 20 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x21, 21 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x22, 22 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x23, 23 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x24, 24 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x25, 25 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x26, 26 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x27, 27 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x28, 28 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::fp, 29 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x30, 30 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::sp, 31 * 8, false);
-  row->SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::pc, 32 * 8, false);
+  row.GetCFAValue().SetIsRegisterPlusOffset(arm64_dwarf::sp, offset);
+
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x0, 0 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x1, 1 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x2, 2 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x3, 3 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x4, 4 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x5, 5 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x6, 6 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x7, 7 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x8, 8 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x9, 9 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x10, 10 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x11, 11 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x12, 12 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x13, 13 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x14, 14 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x15, 15 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x16, 16 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x17, 17 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x18, 18 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x19, 19 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x20, 20 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x21, 21 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x22, 22 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x23, 23 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x24, 24 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x25, 25 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x26, 26 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x27, 27 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x28, 28 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::fp, 29 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::x30, 30 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::sp, 31 * 8, false);
+  row.SetRegisterLocationToAtCFAPlusOffset(arm64_dwarf::pc, 32 * 8, false);
 
   // The sigcontext may also contain floating point and SVE registers.
   // However this would require a dynamic unwind plan so they are not included
   // here.
 
   unwind_plan_sp = std::make_shared<UnwindPlan>(eRegisterKindDWARF);
-  unwind_plan_sp->AppendRow(row);
+  unwind_plan_sp->AppendRow(std::move(row));
   unwind_plan_sp->SetSourceName("AArch64 Linux sigcontext");
   unwind_plan_sp->SetSourcedFromCompiler(eLazyBoolYes);
   // Because sp is the same throughout the function
diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index dee5a7ce2876d..222e04a6a3464 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -660,11 +660,10 @@ SymbolFileBreakpad::ParseCFIUnwindPlan(const Bookmark &bookmark,
       AddressRange(base + init_record->Address, *init_record->Size,
                    m_objfile_sp->GetModule()->GetSectionList()));
 
-  auto row_sp = std::make_shared<UnwindPlan::Row>();
-  row_sp->SetOffset(0);
-  if (!ParseCFIUnwindRow(init_record->UnwindRules, resolver, *row_sp))
+  UnwindPlan::Row row;
+  if (!ParseCFIUnwindRow(init_record->UnwindRules, resolver, row))
     return nullptr;
-  plan_sp->AppendRow(row_sp);
+  plan_sp->AppendRow(row);
   for (++It; It != End; ++It) {
     std::optional<StackCFIRecord> record = StackCFIRecord::parse(*It);
     if (!record)
@@ -672,11 +671,10 @@ SymbolFileBreakpad::ParseCFIUnwindPlan(const Bookmark &bookmark,
     if (record->Size)
       break;
 
-    row_sp = std::make_shared<UnwindPlan::Row>(*row_sp);
-    row_sp->SetOffset(record->Address - init_record->Address);
-    if (!ParseCFIUnwindRow(record->UnwindRules, resolver, *row_sp))
+    row.SetOffset(record->Address - init_record->Address);
+    if (!ParseCFIUnwindRow(record->UnwindRules, resolver, row))
       return nullptr;
-    plan_sp->AppendRow(row_sp);
+    plan_sp->AppendRow(row);
   }
   return plan_sp;
 }
@@ -702,8 +700,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
       AddressRange(base + record->RVA, record->CodeSize,
                    m_objfile_sp->GetModule()->GetSectionList()));
 
-  auto row_sp = std::make_shared<UnwindPlan::Row>();
-  row_sp->SetOffset(0);
+  UnwindPlan::Row row;
 
   llvm::BumpPtrAllocator node_alloc;
   std::vector<std::pair<llvm::StringRef, postfix::Node *>> program =
@@ -732,8 +729,8 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
   // clang will use T1, if it needs to realign the stack.
   auto *symbol = llvm::dyn_cast<postfix::SymbolNode>(it->second);
   if (symbol && symbol->GetName() == ".raSearch") {
-    row_sp->GetCFAValue().SetRaSearch(record->LocalSize +
-                                      record->SavedRegisterSize);
+    row.GetCFAValue().SetRaSearch(record->LocalSize +
+                                  record->SavedRegisterSize);
   } else {
     if (!postfix::ResolveSymbols(it->second, symbol_resolver)) {
       LLDB_LOG(log, "Resolving symbols in `{0}` failed.",
@@ -741,7 +738,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
       return nullptr;
     }
     llvm::ArrayRef<uint8_t> saved  = SaveAsDWARF(*it->second);
-    row_sp->GetCFAValue().SetIsDWARFExpression(saved.data(), saved.size());
+    row.GetCFAValue().SetIsDWARFExpression(saved.data(), saved.size());
   }
 
   // Replace the node value with InitialValueNode, so that subsequent
@@ -766,10 +763,10 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
     llvm::ArrayRef<uint8_t> saved = SaveAsDWARF(*it->second);
     UnwindPlan::Row::AbstractRegisterLocation loc;
     loc.SetIsDWARFExpression(saved.data(), saved.size());
-    row_sp->SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
+    row.SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
   }
 
-  plan_sp->AppendRow(row_sp);
+  plan_sp->AppendRow(std::move(row));
   return plan_sp;
 }
 
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index c54eb659e1744..397c693fc498a 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -209,9 +209,8 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
       }
     }
     for (auto &[_, state] : saved_unwind_states) {
-      unwind_plan.InsertRow(
-          std::make_shared<UnwindPlan::Row>(std::move(state.row)),
-          /*replace_existing=*/true);
+      unwind_plan.InsertRow(std::move(state.row),
+                            /*replace_existing=*/true);
     }
   }
 
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index 84f37ebe52492..298111a496104 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -916,32 +916,27 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
   int current_sp_bytes_offset_from_fa = 0;
   bool is_aligned = false;
   UnwindPlan::Row::AbstractRegisterLocation initial_regloc;
-  UnwindPlan::RowSP row(new UnwindPlan::Row);
+  UnwindPlan::Row row;
 
   unwind_plan.SetPlanValidAddressRange(func_range);
   unwind_plan.SetRegisterKind(eRegisterKindLLDB);
 
   // At the start of the function, find the CFA by adding wordsize to the SP
   // register
-  row->SetOffset(current_func_text_offset);
-  row->GetCFAValue().SetIsRegisterPlusOffset(m_lldb_sp_regnum, m_wordsize);
+  row.SetOffset(current_func_text_offset);
+  row.GetCFAValue().SetIsRegisterPlusOffset(m_lldb_sp_regnum, m_wordsize);
 
   // caller's stack pointer value before the call insn is the CFA address
   initial_regloc.SetIsCFAPlusOffset(0);
-  row->SetRegisterInfo(m_lldb_sp_regnum, initial_regloc);
+  row.SetRegisterInfo(m_lldb_sp_regnum, initial_regloc);
 
   // saved instruction pointer can be found at CFA - wordsize.
   current_sp_bytes_offset_from_fa = m_wordsize;
   initial_regloc.SetAtCFAPlusOffset(-current_sp_bytes_offset_from_fa);
-  row->SetRegisterInfo(m_lldb_ip_regnum, initial_regloc);
+  row.SetRegisterInfo(m_lldb_ip_regnum, initial_regloc);
 
   unwind_plan.AppendRow(row);
 
-  // Allocate a new Row, populate it with the existing Row contents.
-  UnwindPlan::Row *newrow = new UnwindPlan::Row;
-  *newrow = *row.get();
-  row.reset(newrow);
-
   // Track which registers have been saved so far in the prologue. If we see
   // another push of that register, it's not part of the prologue. The register
   // numbers used here are the machine register #'s (i386_register_numbers,
@@ -953,7 +948,8 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
   // that epilogue we'll reinstate the unwind setup -- we assume that some code
   // path jumps over the mid-function epilogue
 
-  UnwindPlan::RowSP prologue_completed_row; // copy of prologue row of CFI
+  std::optional<UnwindPlan::Row>
+      prologue_completed_row; // copy of prologue row of CFI
   int prologue_completed_sp_bytes_offset_from_cfa = 0; // The sp value before the
                                                    // epilogue started executed
   bool prologue_completed_is_aligned = false;
@@ -978,8 +974,8 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
       break;
     }
 
-    auto &cfa_value = row->GetCFAValue();
-    auto &afa_value = row->GetAFAValue();
+    auto &cfa_value = row.GetCFAValue();
+    auto &afa_value = row.GetAFAValue();
     auto fa_value_ptr = is_aligned ? &afa_value : &cfa_value;
 
     if (mov_rsp_rbp_pattern_p()) {
@@ -1063,7 +1059,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
             regloc.SetAtAFAPlusOffset(-current_sp_bytes_offset_from_fa);
         else
             regloc.SetAtCFAPlusOffset(-current_sp_bytes_offset_from_fa);
-        row->SetRegisterInfo(lldb_regno, regloc);
+        row.SetRegisterInfo(lldb_regno, regloc);
         saved_registers[machine_regno] = true;
         row_updated = true;
       }
@@ -1077,7 +1073,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
           machine_regno_to_lldb_regno(machine_regno, lldb_regno) &&
           saved_registers[machine_regno]) {
         saved_registers[machine_regno] = false;
-        row->RemoveRegisterInfo(lldb_regno);
+        row.RemoveRegisterInfo(lldb_regno);
 
         if (lldb_regno == fa_value_ptr->GetRegisterNumber()) {
           fa_value_ptr->SetIsRegisterPlusOffset(
@@ -1113,7 +1109,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
     else if (leave_pattern_p()) {
       if (saved_registers[m_machine_fp_regnum]) {
         saved_registers[m_machine_fp_regnum] = false;
-        row->RemoveRegisterInfo(m_lldb_fp_regnum);
+        row.RemoveRegisterInfo(m_lldb_fp_regnum);
 
         row_updated = true;
       }
@@ -1164,7 +1160,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
       else
           regloc.SetAtCFAPlusOffset(-(stack_offset + fa_value_ptr->GetOffset()));
 
-      row->SetRegisterInfo(lldb_regno, regloc);
+      row.SetRegisterInfo(lldb_regno, regloc);
 
       row_updated = true;
     }
@@ -1238,9 +1234,10 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPl...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/131150


More information about the lldb-commits mailing list