In this PR we ICEd because instrument_func_exit checked that
the last stmt of predecessors of EXIT_BLOCK_PTR is GIMPLE_RETURN,
but here we should allow BUILT_IN_RETURN function as well, as
it's basically the same as return.

I'm not sure about the testcase, but we don't have tsan testsuite
yet ...

Regtested on x86_64-linux, ok for trunk?

2013-04-03  Marek Polacek  <pola...@redhat.com>

        PR sanitizer/55702
        * tsan.c (instrument_func_exit): Allow BUILT_IN_RETURN
        functions.

        * gcc.dg/pr55702.c: New test.

--- gcc/tsan.c.mp       2013-04-03 15:20:20.525933474 +0200
+++ gcc/tsan.c  2013-04-03 16:06:36.482160964 +0200
@@ -681,7 +681,8 @@ instrument_func_exit (void)
     {
       gsi = gsi_last_bb (e->src);
       stmt = gsi_stmt (gsi);
-      gcc_assert (gimple_code (stmt) == GIMPLE_RETURN);
+      gcc_assert (gimple_code (stmt) == GIMPLE_RETURN
+                 || gimple_call_builtin_p (stmt, BUILT_IN_RETURN));
       loc = gimple_location (stmt);
       builtin_decl = builtin_decl_implicit (BUILT_IN_TSAN_FUNC_EXIT);
       g = gimple_build_call (builtin_decl, 0);
--- gcc/testsuite/gcc.dg/pr55702.c.mp   2013-04-03 16:06:02.650055814 +0200
+++ gcc/testsuite/gcc.dg/pr55702.c      2013-04-03 16:05:33.984962743 +0200
@@ -0,0 +1,9 @@
+/* PR sanitizer/55702 */
+/* { dg-do compile { target { x86_64-*-linux* && lp64 } } } */
+/* { dg-options "-fsanitize=thread" } */
+
+void
+foo ()
+{
+  __builtin_return (0);
+}

        Marek

Reply via email to