[llvm] r309831 - Remove the unused Offset field from MachineLocation (NFC)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 2 10:07:38 PDT 2017


Author: adrian
Date: Wed Aug  2 10:07:38 2017
New Revision: 309831

URL: http://llvm.org/viewvc/llvm-project?rev=309831&view=rev
Log:
Remove the unused Offset field from MachineLocation (NFC)

rdar://problem/33580047

Modified:
    llvm/trunk/include/llvm/MC/MachineLocation.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Modified: llvm/trunk/include/llvm/MC/MachineLocation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MachineLocation.h?rev=309831&r1=309830&r2=309831&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MachineLocation.h (original)
+++ llvm/trunk/include/llvm/MC/MachineLocation.h Wed Aug  2 10:07:38 2017
@@ -22,9 +22,8 @@ namespace llvm {
 
 class MachineLocation {
 private:
-  bool IsRegister = false;              // True if location is a register.
-  unsigned Register = 0;                // gcc/gdb register number.
-  int Offset = 0;                       // Displacement if not register.
+  bool IsRegister = false;              ///< True if location is a register.
+  unsigned Register = 0;                ///< gcc/gdb register number.
 
 public:
   enum : uint32_t {
@@ -35,15 +34,11 @@ public:
 
   MachineLocation() = default;
   /// Create a direct register location.
-  explicit MachineLocation(unsigned R) : IsRegister(true), Register(R) {}
-  /// Create a register-indirect location with an offset.
-  MachineLocation(unsigned R, int O) : Register(R), Offset(O) {
-    assert(O == 0 && "offset is expected to always be zero");
-  }
+  explicit MachineLocation(unsigned R, bool Indirect = false)
+      : IsRegister(!Indirect), Register(R) {}
 
   bool operator==(const MachineLocation &Other) const {
-      return IsRegister == Other.IsRegister && Register == Other.Register &&
-        Offset == Other.Offset;
+    return IsRegister == Other.IsRegister && Register == Other.Register;
   }
 
   // Accessors.
@@ -51,24 +46,8 @@ public:
   bool isIndirect()      const { return !IsRegister; }
   bool isReg()           const { return IsRegister; }
   unsigned getReg()      const { return Register; }
-  int getOffset()        const { return Offset; }
   void setIsRegister(bool Is)  { IsRegister = Is; }
   void setRegister(unsigned R) { Register = R; }
-
-  /// Make this location a direct register location.
-  void set(unsigned R) {
-    IsRegister = true;
-    Register = R;
-    Offset = 0;
-  }
-
-  /// Make this location a register-indirect+offset location.
-  void set(unsigned R, int O) {
-    IsRegister = false;
-    Register = R;
-    Offset = O;
-    assert(O == 0 && "offset is expected to always be zero");
-  }
 };
 
 inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=309831&r1=309830&r2=309831&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Aug  2 10:07:38 2017
@@ -483,12 +483,8 @@ DIE *DwarfCompileUnit::constructVariable
     if (DVInsn->getOperand(0).isReg()) {
       const MachineOperand RegOp = DVInsn->getOperand(0);
       // If the second operand is an immediate, this is an indirect value.
-      if (DVInsn->getOperand(1).isImm()) {
-        MachineLocation Location(RegOp.getReg(),
-                                 DVInsn->getOperand(1).getImm());
-        addVariableAddress(DV, *VariableDie, Location);
-      } else if (RegOp.getReg())
-        addVariableAddress(DV, *VariableDie, MachineLocation(RegOp.getReg()));
+      MachineLocation Location(RegOp.getReg(), DVInsn->getOperand(1).isImm());
+      addVariableAddress(DV, *VariableDie, Location);
     } else if (DVInsn->getOperand(0).isImm()) {
       // This variable is described by a single constant.
       // Check whether it has a DIExpression.

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=309831&r1=309830&r2=309831&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Aug  2 10:07:38 2017
@@ -831,13 +831,9 @@ static DebugLocEntry::Value getDebugLocV
 
   assert(MI->getNumOperands() == 4);
   if (MI->getOperand(0).isReg()) {
-    MachineLocation MLoc;
     // If the second operand is an immediate, this is a
     // register-indirect address.
-    if (!MI->getOperand(1).isImm())
-      MLoc.set(MI->getOperand(0).getReg());
-    else
-      MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
+    MachineLocation MLoc(MI->getOperand(0).getReg(), MI->getOperand(1).isImm());
     return DebugLocEntry::Value(Expr, MLoc);
   }
   if (MI->getOperand(0).isImm())




More information about the llvm-commits mailing list