[llvm-commits] [llvm-gcc-4.2] r81543 - in /llvm-gcc-4.2/trunk/gcc: ChangeLog.apple c-parser.c cp/parser.c llvm-debug.cpp tree.c
Caroline Tice
ctice at apple.com
Fri Sep 11 11:33:28 PDT 2009
Author: ctice
Date: Fri Sep 11 13:33:28 2009
New Revision: 81543
URL: http://llvm.org/viewvc/llvm-project?rev=81543&view=rev
Log:
Fix the debug line table information for Apple Blocks: Make sure no
source locations are emitted in the middle of the Blocks prologue, and
make sure the copy-helper & destroy-helper functions do not have source
locations.
Modified:
llvm-gcc-4.2/trunk/gcc/ChangeLog.apple
llvm-gcc-4.2/trunk/gcc/c-parser.c
llvm-gcc-4.2/trunk/gcc/cp/parser.c
llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
llvm-gcc-4.2/trunk/gcc/tree.c
Modified: llvm-gcc-4.2/trunk/gcc/ChangeLog.apple
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ChangeLog.apple?rev=81543&r1=81542&r2=81543&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/ChangeLog.apple (original)
+++ llvm-gcc-4.2/trunk/gcc/ChangeLog.apple Fri Sep 11 13:33:28 2009
@@ -1,3 +1,12 @@
+2009-09-11 Caroline Tice <ctice at apple.com>
+
+ Radar 6419781
+ * tree.c (annotate_with_file_line): Make sure "file" is non-NULL
+ before using it in strcmp.
+ * cp/parser.c (cp_parser_block_literal_expr): Give Blocks copy &
+ destroy helper functions a NULL/0 source location.
+ * c-parser.c (c_parser_block_literal_expr): Ditto.
+
2009-08-31 Caroline Tice <ctice at apple.com>
Radar 6419781
Modified: llvm-gcc-4.2/trunk/gcc/c-parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/c-parser.c?rev=81543&r1=81542&r2=81543&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/c-parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/c-parser.c Fri Sep 11 13:33:28 2009
@@ -10360,6 +10360,12 @@
cur_block->copy_helper_func_decl =
build_helper_func_decl (get_identifier (name), s_ftype);
synth_copy_helper_block_func (cur_block);
+ /* LLVM LOCAL begin Copy Helper function should not have source
+ location. */
+ DECL_SOURCE_FILE (cur_block->copy_helper_func_decl) = NULL;
+ DECL_SOURCE_LINE (cur_block->copy_helper_func_decl) = 0;
+ /* LLVM LOCAL end Copy Helper function should not have source
+ location. */
/* void destroy_helper_block (struct block*); */
s_ftype = build_function_type (void_type_node,
@@ -10369,6 +10375,12 @@
cur_block->destroy_helper_func_decl =
build_helper_func_decl (get_identifier (name), s_ftype);
synth_destroy_helper_block_func (cur_block);
+ /* LLVM LOCAL begin Destroy Helper function should not have source
+ location. */
+ DECL_SOURCE_FILE (cur_block->destroy_helper_func_decl) = NULL;
+ DECL_SOURCE_LINE (cur_block->destroy_helper_func_decl) = 0;
+ /* LLVM LOCAL end Destroy Helper function should not have source
+ location. */
}
block_impl = finish_block (block);
Modified: llvm-gcc-4.2/trunk/gcc/cp/parser.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/parser.c?rev=81543&r1=81542&r2=81543&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/cp/parser.c (original)
+++ llvm-gcc-4.2/trunk/gcc/cp/parser.c Fri Sep 11 13:33:28 2009
@@ -21587,6 +21587,12 @@
build_helper_func_decl (get_identifier (name), s_ftype);
DECL_CONTEXT (cur_block->copy_helper_func_decl) = current_function_decl;
synth_copy_helper_block_func (cur_block);
+ /* LLVM LOCAL begin Copy helper function should not have source
+ location. */
+ DECL_SOURCE_FILE (cur_block->copy_helper_func_decl) = NULL;
+ DECL_SOURCE_LINE (cur_block->copy_helper_func_decl) = 0;
+ /* LLVM LOCAL end Copy helper function should not have source
+ location. */
/* void destroy_helper_block (struct block*); */
s_ftype = build_function_type (void_type_node,
@@ -21597,6 +21603,12 @@
build_helper_func_decl (get_identifier (name), s_ftype);
DECL_CONTEXT (cur_block->destroy_helper_func_decl) = current_function_decl;
synth_destroy_helper_block_func (cur_block);
+ /* LLVM LOCAL begin Destroy helper function should not have source
+ location. */
+ DECL_SOURCE_FILE (cur_block->destroy_helper_func_decl) = NULL;
+ DECL_SOURCE_LINE (cur_block->destroy_helper_func_decl) = 0;
+ /* LLVM LOCAL end Destroy helper function should not have source
+ location. */
pop_lang_context ();
}
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=81543&r1=81542&r2=81543&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Fri Sep 11 13:33:28 2009
@@ -43,6 +43,7 @@
#include "toplev.h"
#include "tree.h"
#include "version.h"
+#include "function.h"
}
using namespace llvm;
@@ -210,6 +211,23 @@
, RegionStack()
{}
+/// isCopyOrDestroyHelper - Returns boolean indicating if FnDecl is for
+/// one of the compiler-generated "helper" functions for Apple Blocks
+/// (a copy helper or a destroy helper). Such functions should not have
+/// debug line table entries.
+bool isCopyOrDestroyHelper (tree FnDecl) {
+ const char *name = IDENTIFIER_POINTER(DECL_NAME(FnDecl));
+
+ if (!BLOCK_SYNTHESIZED_FUNC(FnDecl))
+ return false;
+
+ if (strstr(name, "_copy_helper_block_")
+ || strstr(name, "_destroy_helper_block_"))
+ return true;
+ else
+ return false;
+}
+
/// EmitFunctionStart - Constructs the debug code for entering a function -
/// "llvm.dbg.func.start."
void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn,
@@ -218,12 +236,16 @@
expanded_location Loc = GetNodeLocation(FnDecl, false);
const char *LinkageName = getLinkageName(FnDecl);
+ unsigned lineno = CurLineNo;
+ if (isCopyOrDestroyHelper(FnDecl))
+ lineno = 0;
+
DISubprogram SP =
DebugFactory.CreateSubprogram(findRegion(FnDecl),
lang_hooks.dwarf_name(FnDecl, 0),
lang_hooks.dwarf_name(FnDecl, 0),
LinkageName,
- getOrCreateCompileUnit(Loc.file), CurLineNo,
+ getOrCreateCompileUnit(Loc.file), lineno,
getOrCreateType(TREE_TYPE(FnDecl)),
Fn->hasInternalLinkage(),
true /*definition*/);
@@ -319,6 +341,30 @@
DebugFactory.InsertDeclare(AI, D, CurBB);
}
+
+/// isPartOfAppleBlockPrologue - Return boolean indicating if the line number
+/// passed in is part of the prologue of an Apple Block function. This assumes
+/// the line number passed in belongs to the "current" function.
+bool isPartOfAppleBlockPrologue (unsigned lineno) {
+ if (!cfun || !cfun->decl)
+ return false;
+
+ // In an earlier part of gcc, code that sets up Apple Block by-reference
+ // variables at the beginning of the function (which should be part of the
+ // prologue but isn't), is assigned a source location line of one before the
+ // function decl. So we check for that here:
+
+ if (BLOCK_SYNTHESIZED_FUNC(cfun->decl)) {
+ int fn_decl_line = DECL_SOURCE_LINE(cfun->decl);
+ if (lineno == (fn_decl_line - 1))
+ return true;
+ else
+ return false;
+ }
+
+ return false;
+}
+
/// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
/// source line - "llvm.dbg.stoppoint." Now enabled at -O.
void DebugInfo::EmitStopPoint(Function *Fn, BasicBlock *CurBB) {
@@ -334,10 +380,14 @@
PrevFullPath = CurFullPath;
PrevLineNo = CurLineNo;
PrevBB = CurBB;
-
- DebugFactory.InsertStopPoint(getOrCreateCompileUnit(CurFullPath),
- CurLineNo, 0 /*column no. */,
- CurBB);
+
+ // Don't set/allow source line breakpoints in Apple Block prologue code
+ // or in Apple Block helper functions.
+ if (!isPartOfAppleBlockPrologue(CurLineNo)
+ && !isCopyOrDestroyHelper(cfun->decl))
+ DebugFactory.InsertStopPoint(getOrCreateCompileUnit(CurFullPath),
+ CurLineNo, 0 /*column no. */,
+ CurBB);
}
/// EmitGlobalVariable - Emit information about a global variable.
Modified: llvm-gcc-4.2/trunk/gcc/tree.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.c?rev=81543&r1=81542&r2=81543&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/tree.c (original)
+++ llvm-gcc-4.2/trunk/gcc/tree.c Fri Sep 11 13:33:28 2009
@@ -3347,6 +3347,8 @@
entry cache can reduce the number of allocations by more
than half. */
if (last_annotated_node
+ /* LLVM LOCAL - Check for NULL file. */
+ && file
&& last_annotated_node->line == line
&& (last_annotated_node->file == file
|| !strcmp (last_annotated_node->file, file)))
More information about the llvm-commits
mailing list