]> granicus.if.org Git - llvm/commitdiff
Cleanup: Use DIExpression::prepend in buildDbgValueForSpill(). (NFC)
authorAdrian Prantl <aprantl@apple.com>
Fri, 28 Apr 2017 18:30:36 +0000 (18:30 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 28 Apr 2017 18:30:36 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301665 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/DebugInfoMetadata.h
lib/CodeGen/MachineInstr.cpp
lib/IR/DebugInfoMetadata.cpp

index 9bb2a7c6e20ec6bd77ab1ee11138738a19c894ee..e054fa0471311e6d0178f8b979fbe562c2f9929e 100644 (file)
@@ -2286,7 +2286,7 @@ public:
 
   /// Prepend \p DIExpr with a deref and offset operation and optionally turn it
   /// into a stack value.
-  static DIExpression *prepend(DIExpression *DIExpr, bool Deref,
+  static DIExpression *prepend(const DIExpression *DIExpr, bool Deref,
                                int64_t Offset = 0, bool StackValue = false);
 };
 
index 1faf6292a9c1a64bad322bc8905d117a6f143476..d665201a5d17c2eb2e969e8936e8fd83ad4a583b 100644 (file)
@@ -2350,7 +2350,7 @@ MachineInstr *llvm::buildDbgValueForSpill(MachineBasicBlock &BB,
                                           const MachineInstr &Orig,
                                           int FrameIndex) {
   const MDNode *Var = Orig.getDebugVariable();
-  auto *Expr = cast_or_null<DIExpression>(Orig.getDebugExpression());
+  const auto *Expr = cast_or_null<DIExpression>(Orig.getDebugExpression());
   bool IsIndirect = Orig.isIndirectDebugValue();
   uint64_t Offset = IsIndirect ? Orig.getOperand(1).getImm() : 0;
   DebugLoc DL = Orig.getDebugLoc();
@@ -2359,13 +2359,8 @@ MachineInstr *llvm::buildDbgValueForSpill(MachineBasicBlock &BB,
   // If the DBG_VALUE already was a memory location, add an extra
   // DW_OP_deref. Otherwise just turning this from a register into a
   // memory/indirect location is sufficient.
-  if (IsIndirect) {
-    SmallVector<uint64_t, 8> Ops;
-    Ops.push_back(dwarf::DW_OP_deref);
-    if (Expr)
-      Ops.append(Expr->elements_begin(), Expr->elements_end());
-    Expr = DIExpression::get(Expr->getContext(), Ops);
-  }
+  if (IsIndirect)
+    Expr = DIExpression::prepend(Expr, DIExpression::WithDeref);
   return BuildMI(BB, I, DL, Orig.getDesc())
       .addFrameIndex(FrameIndex)
       .addImm(Offset)
index 93d04ae9315c31d98a6774673c7f7d24dbdff766..82d6b05eb2333482dc58e3cf95dd8dc24a7d26ab 100644 (file)
@@ -672,11 +672,8 @@ void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
   }
 }
 
-DIExpression *DIExpression::prepend(DIExpression *Expr, bool Deref,
+DIExpression *DIExpression::prepend(const DIExpression *Expr, bool Deref,
                                     int64_t Offset, bool StackValue) {
-  if (!Deref && !Offset && !StackValue)
-    return Expr;
-
   SmallVector<uint64_t, 8> Ops;
   appendOffset(Ops, Offset);
   if (Deref)