From 56527dc804d2f6adc97d17a81e02d749c38ef3fe Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 2 Nov 2016 16:12:16 +0000 Subject: Emit DW_OP_piece also if the previous value was a constant. This fixes a bug in the DWARF backend. llvm-svn: 285826 --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'llvm/lib/CodeGen/AsmPrinter') diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index d4cc3f199bf..d98524b66cc 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1406,6 +1406,7 @@ static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, ByteStreamer &Streamer, const DebugLocEntry::Value &Value, unsigned PieceOffsetInBits) { + const DIExpression *Expr = Value.getExpression(); DebugLocDwarfExpression DwarfExpr(AP.getDwarfDebug()->getDwarfVersion(), Streamer); // Regular entry. @@ -1417,7 +1418,6 @@ static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, DwarfExpr.AddUnsignedConstant(Value.getInt()); } else if (Value.isLocation()) { MachineLocation Loc = Value.getLoc(); - const DIExpression *Expr = Value.getExpression(); if (!Expr || !Expr->getNumElements()) // Regular entry. AP.EmitDwarfRegOp(Streamer, Loc); @@ -1426,16 +1426,18 @@ static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const TargetRegisterInfo &TRI = *AP.MF->getSubtarget().getRegisterInfo(); if (Loc.getOffset()) { DwarfExpr.AddMachineRegIndirect(TRI, Loc.getReg(), Loc.getOffset()); - DwarfExpr.AddExpression(Expr->expr_op_begin(), Expr->expr_op_end(), - PieceOffsetInBits); - } else + } else { DwarfExpr.AddMachineRegExpression(TRI, Expr, Loc.getReg(), PieceOffsetInBits); + return; + } } } else if (Value.isConstantFP()) { APInt RawBytes = Value.getConstantFP()->getValueAPF().bitcastToAPInt(); DwarfExpr.AddUnsignedConstant(RawBytes); } + DwarfExpr.AddExpression(Expr->expr_op_begin(), Expr->expr_op_end(), + PieceOffsetInBits); } void DebugLocEntry::finalize(const AsmPrinter &AP, -- cgit v1.2.3