summaryrefslogtreecommitdiff
path: root/gcc/asan.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-11 10:26:56 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2012-12-11 10:26:56 +0000
commit494f4883193c753f475838019e59f8ab056f9c2f (patch)
tree8e60fd8543bd4d759ad6427455b8332b261445fa /gcc/asan.c
parentab63d9fb109ceab42b21b763628522940d900a7f (diff)
downloadgcc-494f4883193c753f475838019e59f8ab056f9c2f.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194390 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/asan.c')
-rw-r--r--gcc/asan.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index 6c8ef187189..87d08d54901 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -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;
}