From: Adrian Prantl Date: Wed, 17 Feb 2016 22:19:59 +0000 (+0000) Subject: DbgVariable: Add an accessor for the common case of a single expression X-Git-Tag: llvmorg-3.9.0-rc1~13887 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f4746b11aedb9de22c1b5c0ae936690ff67a432;p=platform%2Fupstream%2Fllvm.git DbgVariable: Add an accessor for the common case of a single expression belonging to a single DBG_VALUE instruction. NFC llvm-svn: 261167 --- diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 9dd5040ce81e..5febd9fb3806 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -771,8 +771,7 @@ void DwarfCompileUnit::addComplexAddress(const DbgVariable &DV, DIE &Die, const MachineLocation &Location) { DIELoc *Loc = new (DIEValueAllocator) DIELoc; DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc); - assert(DV.getExpression().size() == 1); - const DIExpression *Expr = DV.getExpression().back(); + const DIExpression *Expr = DV.getSingleExpression(); bool ValidReg; if (Location.getOffset()) { ValidReg = DwarfExpr.AddMachineRegIndirect(Location.getReg(), diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index 31303e4ba383..f0859ec1a8fe 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -111,6 +111,10 @@ public: const DILocalVariable *getVariable() const { return Var; } const DILocation *getInlinedAt() const { return IA; } ArrayRef getExpression() const { return Expr; } + const DIExpression *getSingleExpression() const { + assert(MInsn && Expr.size() <= 1); + return Expr.size() ? Expr[0] : nullptr; + } void setDIE(DIE &D) { TheDIE = &D; } DIE *getDIE() const { return TheDIE; } void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }