[llvm-branch-commits] [llvm-branch] r295747 - Merging r295486 and r295490:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Feb 21 10:53:27 PST 2017
Author: hans
Date: Tue Feb 21 12:53:27 2017
New Revision: 295747
URL: http://llvm.org/viewvc/llvm-project?rev=295747&view=rev
Log:
Merging r295486 and r295490:
------------------------------------------------------------------------
r295486 | adrian | 2017-02-17 11:42:32 -0800 (Fri, 17 Feb 2017) | 6 lines
Debug Info: Sort frame index expressions before emitting them.
This fixes PR31381, which caused an assertion and/or invalid debug info.
This affects debug variables that have multiple fragments in the MMI
side (i.e.: in the stack frame) table.
rdar://problem/30571676
------------------------------------------------------------------------
------------------------------------------------------------------------
r295490 | adrian | 2017-02-17 12:02:26 -0800 (Fri, 17 Feb 2017) | 1 line
Fix windows bots by locking down the target triple on this testcase.
------------------------------------------------------------------------
Added:
llvm/branches/release_40/test/DebugInfo/X86/FrameIndexExprs.ll
- copied, changed from r295486, llvm/trunk/test/DebugInfo/X86/FrameIndexExprs.ll
Modified:
llvm/branches/release_40/ (props changed)
llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.h
Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb 21 12:53:27 2017
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293124,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295213,295215,295230,295512
+/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293124,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295213,295215,295230,295486,295490,295512
Modified: llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=295747&r1=295746&r2=295747&view=diff
==============================================================================
--- llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Tue Feb 21 12:53:27 2017
@@ -522,22 +522,19 @@ DIE *DwarfCompileUnit::constructVariable
}
// .. else use frame index.
- if (DV.getFrameIndex().empty())
+ if (!DV.hasFrameIndexExprs())
return VariableDie;
- auto Expr = DV.getExpression().begin();
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
- for (auto FI : DV.getFrameIndex()) {
+ for (auto &Fragment : DV.getFrameIndexExprs()) {
unsigned FrameReg = 0;
const TargetFrameLowering *TFI = Asm->MF->getSubtarget().getFrameLowering();
- int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
- assert(Expr != DV.getExpression().end() && "Wrong number of expressions");
- DwarfExpr.addFragmentOffset(*Expr);
+ int Offset = TFI->getFrameIndexReference(*Asm->MF, Fragment.FI, FrameReg);
+ DwarfExpr.addFragmentOffset(Fragment.Expr);
DwarfExpr.AddMachineRegIndirect(*Asm->MF->getSubtarget().getRegisterInfo(),
FrameReg, Offset);
- DwarfExpr.AddExpression(*Expr);
- ++Expr;
+ DwarfExpr.AddExpression(Fragment.Expr);
}
addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
Modified: llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=295747&r1=295746&r2=295747&view=diff
==============================================================================
--- llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Feb 21 12:53:27 2017
@@ -199,6 +199,15 @@ const DIType *DbgVariable::getType() con
return Ty;
}
+ArrayRef<DbgVariable::FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
+ std::sort(FrameIndexExprs.begin(), FrameIndexExprs.end(),
+ [](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool {
+ return A.Expr->getFragmentInfo()->OffsetInBits <
+ B.Expr->getFragmentInfo()->OffsetInBits;
+ });
+ return FrameIndexExprs;
+}
+
static const DwarfAccelTable::Atom TypeAtoms[] = {
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4),
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
Modified: llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=295747&r1=295746&r2=295747&view=diff
==============================================================================
--- llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/branches/release_40/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Feb 21 12:53:27 2017
@@ -54,7 +54,7 @@ class MachineModuleInfo;
///
/// Variables can be created from allocas, in which case they're generated from
/// the MMI table. Such variables can have multiple expressions and frame
-/// indices. The \a Expr and \a FrameIndices array must match.
+/// indices.
///
/// Variables can be created from \c DBG_VALUE instructions. Those whose
/// location changes over time use \a DebugLocListIndex, while those with a
@@ -64,11 +64,16 @@ class MachineModuleInfo;
class DbgVariable {
const DILocalVariable *Var; /// Variable Descriptor.
const DILocation *IA; /// Inlined at location.
- SmallVector<const DIExpression *, 1> Expr; /// Complex address.
DIE *TheDIE = nullptr; /// Variable DIE.
unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
- SmallVector<int, 1> FrameIndex; /// Frame index.
+
+ struct FrameIndexExpr {
+ int FI;
+ const DIExpression *Expr;
+ };
+ mutable SmallVector<FrameIndexExpr, 1>
+ FrameIndexExprs; /// Frame index + expression.
public:
/// Construct a DbgVariable.
@@ -80,21 +85,18 @@ public:
/// Initialize from the MMI table.
void initializeMMI(const DIExpression *E, int FI) {
- assert(Expr.empty() && "Already initialized?");
- assert(FrameIndex.empty() && "Already initialized?");
+ assert(FrameIndexExprs.empty() && "Already initialized?");
assert(!MInsn && "Already initialized?");
assert((!E || E->isValid()) && "Expected valid expression");
assert(~FI && "Expected valid index");
- Expr.push_back(E);
- FrameIndex.push_back(FI);
+ FrameIndexExprs.push_back({FI, E});
}
/// Initialize from a DBG_VALUE instruction.
void initializeDbgValue(const MachineInstr *DbgValue) {
- assert(Expr.empty() && "Already initialized?");
- assert(FrameIndex.empty() && "Already initialized?");
+ assert(FrameIndexExprs.empty() && "Already initialized?");
assert(!MInsn && "Already initialized?");
assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
@@ -103,16 +105,15 @@ public:
MInsn = DbgValue;
if (auto *E = DbgValue->getDebugExpression())
if (E->getNumElements())
- Expr.push_back(E);
+ FrameIndexExprs.push_back({0, E});
}
// Accessors.
const DILocalVariable *getVariable() const { return Var; }
const DILocation *getInlinedAt() const { return IA; }
- ArrayRef<const DIExpression *> getExpression() const { return Expr; }
const DIExpression *getSingleExpression() const {
- assert(MInsn && Expr.size() <= 1);
- return Expr.size() ? Expr[0] : nullptr;
+ assert(MInsn && FrameIndexExprs.size() <= 1);
+ return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
}
void setDIE(DIE &D) { TheDIE = &D; }
DIE *getDIE() const { return TheDIE; }
@@ -120,7 +121,9 @@ public:
unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
StringRef getName() const { return Var->getName(); }
const MachineInstr *getMInsn() const { return MInsn; }
- ArrayRef<int> getFrameIndex() const { return FrameIndex; }
+ /// Get the FI entries, sorted by fragment offset.
+ ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
+ bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
void addMMIEntry(const DbgVariable &V) {
assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
@@ -128,16 +131,15 @@ public:
assert(V.Var == Var && "conflicting variable");
assert(V.IA == IA && "conflicting inlined-at location");
- assert(!FrameIndex.empty() && "Expected an MMI entry");
- assert(!V.FrameIndex.empty() && "Expected an MMI entry");
- assert(Expr.size() == FrameIndex.size() && "Mismatched expressions");
- assert(V.Expr.size() == V.FrameIndex.size() && "Mismatched expressions");
-
- Expr.append(V.Expr.begin(), V.Expr.end());
- FrameIndex.append(V.FrameIndex.begin(), V.FrameIndex.end());
- assert(all_of(Expr, [](const DIExpression *E) {
- return E && E->isFragment();
- }) && "conflicting locations for variable");
+ assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
+ assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
+
+ FrameIndexExprs.append(V.FrameIndexExprs.begin(), V.FrameIndexExprs.end());
+ assert(all_of(FrameIndexExprs,
+ [](FrameIndexExpr &FIE) {
+ return FIE.Expr && FIE.Expr->isFragment();
+ }) &&
+ "conflicting locations for variable");
}
// Translate tag to proper Dwarf tag.
@@ -167,11 +169,11 @@ public:
bool hasComplexAddress() const {
assert(MInsn && "Expected DBG_VALUE, not MMI variable");
- assert(FrameIndex.empty() && "Expected DBG_VALUE, not MMI variable");
- assert(
- (Expr.empty() || (Expr.size() == 1 && Expr.back()->getNumElements())) &&
- "Invalid Expr for DBG_VALUE");
- return !Expr.empty();
+ assert((FrameIndexExprs.empty() ||
+ (FrameIndexExprs.size() == 1 &&
+ FrameIndexExprs[0].Expr->getNumElements())) &&
+ "Invalid Expr for DBG_VALUE");
+ return !FrameIndexExprs.empty();
}
bool isBlockByrefVariable() const;
const DIType *getType() const;
Copied: llvm/branches/release_40/test/DebugInfo/X86/FrameIndexExprs.ll (from r295486, llvm/trunk/test/DebugInfo/X86/FrameIndexExprs.ll)
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/DebugInfo/X86/FrameIndexExprs.ll?p2=llvm/branches/release_40/test/DebugInfo/X86/FrameIndexExprs.ll&p1=llvm/trunk/test/DebugInfo/X86/FrameIndexExprs.ll&r1=295486&r2=295747&rev=295747&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/FrameIndexExprs.ll (original)
+++ llvm/branches/release_40/test/DebugInfo/X86/FrameIndexExprs.ll Tue Feb 21 12:53:27 2017
@@ -1,6 +1,6 @@
; PR31381: An assertion in the DWARF backend when fragments in MMI slots are
; sorted by largest offset first.
-; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
+; RUN: llc -mtriple=x86_64-apple-darwin -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
; CHECK: DW_TAG_formal_parameter
; CHECK: DW_TAG_formal_parameter
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (<0xa> 91 78 93 03 93 06 91 7d 93 03 )
More information about the llvm-branch-commits
mailing list