[llvm-commits] [llvm-gcc-4.2] r107931 - in /llvm-gcc-4.2/trunk/gcc: cp/pt.c llvm-convert.cpp llvm-debug.cpp
Stuart Hastings
stuart at apple.com
Thu Jul 8 16:26:10 PDT 2010
Author: stuart
Date: Thu Jul 8 18:26:10 2010
New Revision: 107931
URL: http://llvm.org/viewvc/llvm-project?rev=107931&view=rev
Log:
Reverting r107918 and r107919. Radar 8063111.
Modified:
llvm-gcc-4.2/trunk/gcc/cp/pt.c
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
Modified: llvm-gcc-4.2/trunk/gcc/cp/pt.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/pt.c?rev=107931&r1=107930&r2=107931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/pt.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/pt.c Thu Jul 8 18:26:10 2010
@@ -6696,6 +6696,8 @@
template, and in any case are considered separate under the
discrete model. */
r = copy_decl (t);
+ /* LLVM LOCAL 7514620 */
+ DECL_SOURCE_LOCATION(r) = saved_loc;
DECL_USE_TEMPLATE (r) = 0;
TREE_TYPE (r) = type;
/* Clear out the mangled name and RTL for the instantiation. */
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=107931&r1=107930&r2=107931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Jul 8 18:26:10 2010
@@ -960,20 +960,19 @@
Value *Result = 0;
- bool emitdebuginfo = EmitDebugInfo();
-
- if (emitdebuginfo && EXPR_HAS_LOCATION(exp)) {
- // Set new location on the way up the tree.
- TheDebugInfo->setLocationFile(EXPR_FILENAME(exp));
- TheDebugInfo->setLocationLine(EXPR_LINENO(exp));
- }
-
// If we've just changed lexical blocks, emit any local variables
// declared in the new block.
TreeToLLVM::switchLexicalBlock(exp);
- if (emitdebuginfo)
+ if (EmitDebugInfo()) {
+ if (EXPR_HAS_LOCATION(exp)) {
+ // Set new location on the way up the tree.
+ TheDebugInfo->setLocationFile(EXPR_FILENAME(exp));
+ TheDebugInfo->setLocationLine(EXPR_LINENO(exp));
+ }
+
TheDebugInfo->EmitStopPoint(Fn, Builder.GetInsertBlock(), Builder);
+ }
switch (TREE_CODE(exp)) {
default:
Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=107931&r1=107930&r2=107931&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Jul 8 18:26:10 2010
@@ -288,7 +288,13 @@
RegionStack.pop_back();
}
DebugInfo::push_regions(desired, grand);
- setCurrentLexicalBlock(desired);
+ // There's no point in declaring an empty (declares no variables)
+ // lexical BLOCK as the current lexical BLOCK. Locate nearest
+ // non-empty ancestor BLOCK and declare that.
+ for (t = desired; TREE_CODE(t) == BLOCK; t = BLOCK_SUPERCONTEXT(t))
+ if (BLOCK_VARS(t))
+ break;
+ setCurrentLexicalBlock(t);
}
/// CreateSubprogramFromFnDecl - Constructs the debug code for
@@ -469,41 +475,11 @@
return false;
}
-/// findRegion - Find the region (context) of a GCC tree.
-DIDescriptor DebugInfo::findRegion(tree exp) {
- if (exp == NULL_TREE)
+/// findRegion - Find tree_node N's region.
+DIDescriptor DebugInfo::findRegion(tree Node) {
+ if (Node == NULL_TREE)
return getOrCreateFile(main_input_filename);
- tree Node = exp;
- location_t *p_locus = 0;
- tree_code code = TREE_CODE(exp);
- enum tree_code_class tree_cc = TREE_CODE_CLASS(code);
- switch (tree_cc) {
- case tcc_declaration: /* A decl node */
- p_locus = &DECL_SOURCE_LOCATION(exp);
- break;
-
- case tcc_expression: /* an expression */
- case tcc_comparison: /* a comparison expression */
- case tcc_unary: /* a unary arithmetic expression */
- case tcc_binary: /* a binary arithmetic expression */
- Node = TREE_BLOCK(exp);
- p_locus = EXPR_LOCUS(exp);
- break;
-
- case tcc_exceptional:
- switch (code) {
- case BLOCK:
- p_locus = &BLOCK_SOURCE_LOCATION(Node);
- break;
- default:
- gcc_unreachable ();
- }
- break;
- default:
- break;
- }
-
std::map<tree_node *, WeakVH>::iterator I = RegionMap.find(Node);
if (I != RegionMap.end())
if (MDNode *R = dyn_cast_or_null<MDNode>(I->second))
@@ -528,23 +504,56 @@
}
}
} else if (TREE_CODE(Node) == BLOCK) {
- // Recursively establish ancestor scopes.
- DIDescriptor context = findRegion(BLOCK_SUPERCONTEXT(Node));
- // If we don't have a location, use the last-seen info.
- unsigned int line;
- const char *fullpath;
- if (LOCATION_FILE(*p_locus) == (char*)0) {
- fullpath = CurFullPath;
- line = CurLineNo;
+ // TREE_BLOCK is GCC's lexical block.
+ tree scopeToDeclare, step;
+
+#if 0
+ // GDB Kludge
+ // This code section is devoted to eliminating as many lexical
+ // blocks as possible, in order to mimic GCC debug output. In a
+ // perfect world, the debugger would not be adversely affected by
+ // a few extra lexical scopes. Ideally this stuff could be
+ // drastically simplified when LLDB replaces GDB.
+ if (nonemptySibling(Node)) {
+ // If any sibling BLOCK declares anything, use this scope.
+ scopeToDeclare = Node;
} else {
- fullpath = LOCATION_FILE(*p_locus);
- line = LOCATION_LINE(*p_locus);
+ tree upper = supercontextWithDecls(Node);
+ if (TREE_CODE(upper) == FUNCTION_DECL) {
+ scopeToDeclare = upper;
+ } else if (TREE_CODE(upper) == BLOCK && BLOCK_VARS(upper) && BLOCK_VARS(Node) &&
+ upper != Node) {
+ // We can't use upper because it declares something. Find the
+ // uppermost empty BLOCK /between/ Node and upper.
+ for (step = BLOCK_SUPERCONTEXT(Node);
+ TREE_CODE(step) == BLOCK && !BLOCK_VARS(step) &&
+ BLOCK_SUPERCONTEXT(step);
+ step = BLOCK_SUPERCONTEXT(step))
+ ;
+ scopeToDeclare = step;
+ } else
+ // Either or both of upper and Node are empty (declare
+ // nothing); fuse Node's scope with upper.
+ scopeToDeclare = upper;
+ }
+#else
+ scopeToDeclare = Node;
+#endif
+
+ switch (TREE_CODE(scopeToDeclare)) {
+ default:
+ assert("non-BLOCK, non-FUNCTION_DECL scope!");
+ case FUNCTION_DECL:
+ return CreateSubprogramFromFnDecl(scopeToDeclare);
+ case BLOCK:
+ // Recursively establish ancestor scopes.
+ DIDescriptor context = findRegion(BLOCK_SUPERCONTEXT(scopeToDeclare));
+ DILexicalBlock lexical_block =
+ DebugFactory.CreateLexicalBlock(context, CurLineNo);
+ RegionMap[scopeToDeclare] = WeakVH(lexical_block);
+ return DIDescriptor(lexical_block);
}
- DIFile F(getOrCreateFile(fullpath));
- DILexicalBlock lexical_block =
- DebugFactory.CreateLexicalBlock(context, F, line, 0U);
- RegionMap[Node] = WeakVH(lexical_block);
- return DIDescriptor(lexical_block);
+ // GDB Kludge end
}
// Otherwise main compile unit covers everything.
More information about the llvm-commits
mailing list