[llvm-commits] [llvm-gcc-4.2] r104384 - /llvm-gcc-4.2/trunk/gcc/gimple-low.c

Stuart Hastings stuart at apple.com
Fri May 21 14:22:08 PDT 2010


Author: stuart
Date: Fri May 21 16:22:08 2010
New Revision: 104384

URL: http://llvm.org/viewvc/llvm-project?rev=104384&view=rev
Log:
Teach Gimplifier to preserve location info on solitry RETURN_EXPRs.  Radar 7789102.

Modified:
    llvm-gcc-4.2/trunk/gcc/gimple-low.c

Modified: llvm-gcc-4.2/trunk/gcc/gimple-low.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gimple-low.c?rev=104384&r1=104383&r2=104384&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/gimple-low.c (original)
+++ llvm-gcc-4.2/trunk/gcc/gimple-low.c Fri May 21 16:22:08 2010
@@ -50,6 +50,12 @@
      of the function.  */
   tree return_statements;
 
+  /* LLVM LOCAL begin 7789102 */
+  /* A TREE_LIST of return statements to be stripped of location
+     info.  */
+  tree returns_to_strip;
+  /* LLVM LOCAL end 7789102 */
+
   /* True if the function calls __builtin_setjmp.  */
   bool calls_builtin_setjmp;
 };
@@ -101,6 +107,7 @@
       tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
     }
 
+  /* LLVM LOCAL begin 7789102 */
   /* If we lowered any return statements, emit the representative
      at the end of the function.  */
   for (t = data.return_statements ; t ; t = TREE_CHAIN (t))
@@ -108,17 +115,31 @@
       x = build1 (LABEL_EXPR, void_type_node, TREE_PURPOSE (t));
       tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
 
+      /* This RETURN_EXPR was replaced with one or more GOTO_EXPRs to
+         the label we just placed above.  Now install this RETURN_EXPR
+         at the end of the function body:  */
+      x = TREE_VALUE (t);
+      tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
+    }
+
+  /* If we lowered any return statements, and any of those returns
+     were used by multiple GOTO_EXPRs, strip those RETURN_EXPRs of
+     their location information.  We're taking pains not to strip the
+     location info from any RETURN_EXPR referenced by only one
+     GOTO_EXPR.  */
+  for (t = data.returns_to_strip ; t ; t = TREE_CHAIN (t))
+    {
       /* Remove the line number from the representative return statement.
 	 It now fills in for many such returns.  Failure to remove this
 	 will result in incorrect results for coverage analysis.  */
-      x = TREE_VALUE (t);
+      x = TREE_PURPOSE (t);
 #ifdef USE_MAPPED_LOCATION
       SET_EXPR_LOCATION (x, UNKNOWN_LOCATION);
 #else
       SET_EXPR_LOCUS (x, NULL);
 #endif
-      tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
     }
+  /* LLVM LOCAL end 7789102 */
 
   /* If the function calls __builtin_setjmp, we need to emit the computed
      goto that will serve as the unique dispatcher for all the receivers.  */
@@ -588,6 +609,8 @@
       if (value == tvalue)
 	{
 	  label = TREE_PURPOSE (t);
+          /* LLVM LOCAL 7789102 */
+          data->returns_to_strip = tree_cons (stmt, NULL_TREE, data->returns_to_strip);
 	  goto found;
 	}
     }





More information about the llvm-commits mailing list