[llvm] r219628 - Add an assertion about the integrity of the iterator.
Adrian Prantl
aprantl at apple.com
Mon Oct 13 13:44:59 PDT 2014
Author: adrian
Date: Mon Oct 13 15:44:58 2014
New Revision: 219628
URL: http://llvm.org/viewvc/llvm-project?rev=219628&view=rev
Log:
Add an assertion about the integrity of the iterator.
Broken parent scope pointers in inlined DIVariables can cause
ensureAbstractVariableIsCreated to insert new abstract scopes, thus
invalidating the iterator in this loop and leading to hard-to-debug
crashes. Useful when manually reducing IR for testcases.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=219628&r1=219627&r2=219628&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Oct 13 15:44:58 2014
@@ -1365,6 +1365,9 @@ void DwarfDebug::endFunction(const Machi
return;
}
+#ifndef NDEBUG
+ size_t NumAbstractScopes = LScopes.getAbstractScopesList().size();
+#endif
// Construct abstract scopes.
for (LexicalScope *AScope : LScopes.getAbstractScopesList()) {
DISubprogram SP(AScope->getScopeNode());
@@ -1377,6 +1380,8 @@ void DwarfDebug::endFunction(const Machi
if (!ProcessedVars.insert(DV))
continue;
ensureAbstractVariableIsCreated(DV, DV.getContext());
+ assert(LScopes.getAbstractScopesList().size() == NumAbstractScopes
+ && "ensureAbstractVariableIsCreated inserted abstract scopes");
}
constructAbstractSubprogramScopeDIE(AScope);
}
More information about the llvm-commits
mailing list