]> granicus.if.org Git - llvm/commitdiff
Remove the unused Offset field from MachineLocation (NFC)
authorAdrian Prantl <aprantl@apple.com>
Wed, 2 Aug 2017 17:07:38 +0000 (17:07 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 2 Aug 2017 17:07:38 +0000 (17:07 +0000)
rdar://problem/33580047

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309831 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 94d752fc998a9507850dfbd568a0b3f53896a9e0..91ed661ebeab5d828b63c864003e73685bd04681 100644 (file)
@@ -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) {
index 6c5aa9667862fa4c1843b951439a40772c281c53..8820d21dd14d1fb5db8a98196b35428a9468f8ef 100644 (file)
@@ -483,12 +483,8 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
     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.
index 6e9afde0f28a0034780e6ba0bf0e2a1cfe87dcd8..b4bd470fe85a637ccfb58d9a7afa61f3960bb7eb 100644 (file)
@@ -831,13 +831,9 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
 
   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())