]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sanitizer.def (BUILT_IN_ASAN_HANDLE_NO_RETURN): New builtin.
authorJakub Jelinek <jakub@redhat.com>
Tue, 11 Dec 2012 10:26:56 +0000 (11:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 11 Dec 2012 10:26:56 +0000 (11:26 +0100)
* sanitizer.def (BUILT_IN_ASAN_HANDLE_NO_RETURN): New builtin.
* asan.c (instrument_builtin_call): Change is_gimple_builtin_call
gcc_assert to gcc_checking_assert.
(maybe_instrument_call): Imit __builtin___asan_handle_no_return ()
before noreturn calls other than __builtin_trap () and
__builtin_unreachable ().

* c-c++-common/asan/clone-test-1.c: Remove bogus dg-shouldfail.

From-SVN: r194390

gcc/ChangeLog
gcc/asan.c
gcc/sanitizer.def

index db3b60f03e0954096f3ac3f9a6676c3b87554ab6..b670ba5d812052e36f9089c46fec0c6da4a83b7b 100644 (file)
@@ -1,3 +1,12 @@
+2012-12-11  Jakub Jelinek  <jakub@redhat.com>
+
+       * sanitizer.def (BUILT_IN_ASAN_HANDLE_NO_RETURN): New builtin.
+       * asan.c (instrument_builtin_call): Change is_gimple_builtin_call
+       gcc_assert to gcc_checking_assert.
+       (maybe_instrument_call): Imit __builtin___asan_handle_no_return ()
+       before noreturn calls other than __builtin_trap () and
+       __builtin_unreachable ().
+
 2012-12-11  Richard Biener  <rguenther@suse.de>
 
        PR other/54324
index 6c8ef187189b077aac8eed13568dcf1556d7e3a6..87d08d5490192629f1a98ca09a1421a8e7134120 100644 (file)
@@ -1072,7 +1072,7 @@ instrument_builtin_call (gimple_stmt_iterator *iter)
 {
   gimple call = gsi_stmt (*iter);
 
-  gcc_assert (is_gimple_builtin_call (call));
+  gcc_checking_assert (is_gimple_builtin_call (call));
 
   tree callee = gimple_call_fndecl (call);
   location_t loc = gimple_location (call);
@@ -1392,8 +1392,29 @@ instrument_assignment (gimple_stmt_iterator *iter)
 static bool
 maybe_instrument_call (gimple_stmt_iterator *iter)
 {
-  if (is_gimple_builtin_call (gsi_stmt (*iter)))
-    return instrument_builtin_call (iter);
+  gimple stmt = gsi_stmt (*iter);
+  bool is_builtin = is_gimple_builtin_call (stmt);
+  if (is_builtin
+      && instrument_builtin_call (iter))
+    return true;
+  if (gimple_call_noreturn_p (stmt))
+    {
+      if (is_builtin)
+       {
+         tree callee = gimple_call_fndecl (stmt);
+         switch (DECL_FUNCTION_CODE (callee))
+           {
+           case BUILT_IN_UNREACHABLE:
+           case BUILT_IN_TRAP:
+             /* Don't instrument these.  */
+             return false;
+           }
+       }
+      tree decl = builtin_decl_implicit (BUILT_IN_ASAN_HANDLE_NO_RETURN);
+      gimple g = gimple_build_call (decl, 0);
+      gimple_set_location (g, gimple_location (stmt));
+      gsi_insert_before (iter, g, GSI_SAME_STMT);
+    }
   return false;
 }
 
index 1739e7aa73cdb89cf7c85913cfb7c7bae9be5e69..0e5a9cb5724ba9d78e3672cfc99a723aa9998bc2 100644 (file)
@@ -55,6 +55,9 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_REGISTER_GLOBALS,
 DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_UNREGISTER_GLOBALS,
                      "__asan_unregister_globals",
                      BT_FN_VOID_PTR_PTRMODE, ATTR_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_HANDLE_NO_RETURN,
+                     "__asan_handle_no_return",
+                     BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
 
 /* Thread Sanitizer */
 DEF_SANITIZER_BUILTIN(BUILT_IN_TSAN_INIT, "__tsan_init",