From 06d6096edc78c6a7aa6ddad2fe81c74d5661e631 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 28 Apr 2017 18:30:36 +0000 Subject: [PATCH] Cleanup: Use DIExpression::prepend in buildDbgValueForSpill(). (NFC) llvm-svn: 301665 --- llvm/include/llvm/IR/DebugInfoMetadata.h | 2 +- llvm/lib/CodeGen/MachineInstr.cpp | 11 +++-------- llvm/lib/IR/DebugInfoMetadata.cpp | 5 +---- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 9bb2a7c..e054fa0 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -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); }; diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 1faf629..d665201 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -2350,7 +2350,7 @@ MachineInstr *llvm::buildDbgValueForSpill(MachineBasicBlock &BB, const MachineInstr &Orig, int FrameIndex) { const MDNode *Var = Orig.getDebugVariable(); - auto *Expr = cast_or_null(Orig.getDebugExpression()); + const auto *Expr = cast_or_null(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 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) diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index 93d04ae..82d6b05 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -672,11 +672,8 @@ void DIExpression::appendOffset(SmallVectorImpl &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 Ops; appendOffset(Ops, Offset); if (Deref) -- 2.7.4