This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Add a lexical block only when the callsite has source location info


During function inlining, a lexical block is added for each cloned
callee, and source info is attached to this block for addr2line to
derive the inline stack. However, some callsites do not have source
information attached to it. Adding a lexical block would be misleading
in this case. E.g. If a function is split, when the split callsite is
inlined back, the cloned callee should stay in the same lexical block
with its caller. This patch ensures that lexical blocks are only added
when the callsite has source location info in it.

Bootstrapped and passed gcc regression tests.

Is it ok for trunk?

Thanks,
Dehao

gcc/ChangeLog:
2012-06-25  Dehao Chen  <dehao@google.com>

	* tree-profile.c: (expand_call_inline): Make a new lexical block only
	when the call stmt has source location.

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 188926)
+++ gcc/tree-inline.c	(working copy)
@@ -3950,10 +3950,17 @@
      actual inline expansion of the body, and a label for the return
      statements within the function to jump to.  The type of the
      statement expression is the return type of the function call.  */
-  id->block = make_node (BLOCK);
-  BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
-  BLOCK_SOURCE_LOCATION (id->block) = input_location;
-  prepend_lexical_block (gimple_block (stmt), id->block);
+  if (gimple_has_location (stmt))
+    {
+      id->block = make_node (BLOCK);
+      BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
+      BLOCK_SOURCE_LOCATION (id->block) = input_location;
+      prepend_lexical_block (gimple_block (stmt), id->block);
+    }
+  else
+    {
+      id->block = gimple_block (stmt);
+    }

   /* Local declarations will be replaced by their equivalents in this
      map.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]