[llvm-branch-commits] [llvm] 71635ea - MCDwarf: Delete uneeded parameter

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jan 21 00:59:23 PST 2021


Author: Fangrui Song
Date: 2021-01-21T00:55:07-08:00
New Revision: 71635ea5ffd62a7de91c759c0dfb7bb40c16fd94

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

LOG: MCDwarf: Delete uneeded parameter

And change signature

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCDwarf.h
    llvm/lib/MC/MCAssembler.cpp
    llvm/lib/MC/MCDwarf.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCDwarf.h b/llvm/include/llvm/MC/MCDwarf.h
index 70da5f76e766..5bf6496806d8 100644
--- a/llvm/include/llvm/MC/MCDwarf.h
+++ b/llvm/include/llvm/MC/MCDwarf.h
@@ -25,6 +25,7 @@
 #include <cassert>
 #include <cstdint>
 #include <string>
+#include <tuple>
 #include <utility>
 #include <vector>
 
@@ -387,11 +388,11 @@ class MCDwarfLineAddr {
                      int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS);
 
   /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas using
-  /// fixed length operands.
-  static bool FixedEncode(MCContext &Context,
-                          MCDwarfLineTableParams Params,
-                          int64_t LineDelta, uint64_t AddrDelta,
-                          raw_ostream &OS, uint32_t *Offset, uint32_t *Size);
+  /// fixed length operands. Returns (Offset, Size, SetDelta).
+  static std::tuple<uint32_t, uint32_t, bool> fixedEncode(MCContext &Context,
+                                                          int64_t LineDelta,
+                                                          uint64_t AddrDelta,
+                                                          raw_ostream &OS);
 
   /// Utility function to emit the encoding to a streamer.
   static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,

diff  --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index d8b8b505bf5b..ce296d7faa45 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -1119,10 +1119,9 @@ bool MCAssembler::relaxDwarfLineAddr(MCAsmLayout &Layout,
   } else {
     uint32_t Offset;
     uint32_t Size;
-    bool SetDelta = MCDwarfLineAddr::FixedEncode(Context,
-                                                 getDWARFLinetableParams(),
-                                                 LineDelta, AddrDelta,
-                                                 OSE, &Offset, &Size);
+    bool SetDelta;
+    std::tie(Offset, Size, SetDelta) =
+        MCDwarfLineAddr::fixedEncode(Context, LineDelta, AddrDelta, OSE);
     // Add Fixups for address delta or new address.
     const MCExpr *FixupExpr;
     if (SetDelta) {

diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 12a7d9b6e589..410ca296eaf2 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -766,11 +766,10 @@ void MCDwarfLineAddr::Encode(MCContext &Context, MCDwarfLineTableParams Params,
   }
 }
 
-bool MCDwarfLineAddr::FixedEncode(MCContext &Context,
-                                  MCDwarfLineTableParams Params,
-                                  int64_t LineDelta, uint64_t AddrDelta,
-                                  raw_ostream &OS,
-                                  uint32_t *Offset, uint32_t *Size) {
+std::tuple<uint32_t, uint32_t, bool>
+MCDwarfLineAddr::fixedEncode(MCContext &Context, int64_t LineDelta,
+                             uint64_t AddrDelta, raw_ostream &OS) {
+  uint32_t Offset, Size;
   if (LineDelta != INT64_MAX) {
     OS << char(dwarf::DW_LNS_advance_line);
     encodeSLEB128(LineDelta, OS);
@@ -790,15 +789,15 @@ bool MCDwarfLineAddr::FixedEncode(MCContext &Context,
     encodeULEB128(1 + AddrSize, OS);
     OS << char(dwarf::DW_LNE_set_address);
     // Generate fixup for the address.
-    *Offset = OS.tell();
-    *Size = AddrSize;
+    Offset = OS.tell();
+    Size = AddrSize;
     SetDelta = false;
     OS.write_zeros(AddrSize);
   } else {
     OS << char(dwarf::DW_LNS_fixed_advance_pc);
     // Generate fixup for 2-bytes address delta.
-    *Offset = OS.tell();
-    *Size = 2;
+    Offset = OS.tell();
+    Size = 2;
     SetDelta = true;
     OS << char(0);
     OS << char(0);
@@ -812,7 +811,7 @@ bool MCDwarfLineAddr::FixedEncode(MCContext &Context,
     OS << char(dwarf::DW_LNS_copy);
   }
 
-  return SetDelta;
+  return {Offset, Size, SetDelta};
 }
 
 // Utility function to write a tuple for .debug_abbrev.


        


More information about the llvm-branch-commits mailing list