summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-11-24 11:47:30 +0300
committerSlava Barinov <v.barinov@samsung.com>2016-11-24 12:18:07 +0300
commitb8ce9980ef82f1b68ec016cd3c80b31d80ecfd33 (patch)
treee598bd83ff60d8c1ded5aed0e6e8c5bed67e14d4
parent39f2b46347df63764f20e33ee29c6887c5ec7a90 (diff)
downloadlinaro-gcc-sandbox/vbarinov/ubsan.tar.gz
linaro-gcc-sandbox/vbarinov/ubsan.tar.bz2
linaro-gcc-sandbox/vbarinov/ubsan.zip
Import fix for ICE in LTO+ubsansandbox/vbarinov/ubsan
PR lto/69254 * sanitizer.def: Add BEGIN_SANITIZER_BUILTINS and END_SANITIZER_BUILTINS markers using DEF_BUILTIN_STUB. * asan.c (DEF_BUILTIN_STUB): Temporarily define. * tree-streamer-in.c: Include asan.h. (streamer_get_builtin_tree): For builtins in sanitizer range call initialize_sanitizer_builtins and retry. Change-Id: I927bd9cdfd2d8a6ff319cc1888c87b6ff53ceec8 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232891 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/asan.c3
-rw-r--r--gcc/sanitizer.def22
-rw-r--r--gcc/tree-streamer-in.c12
3 files changed, 36 insertions, 1 deletions
diff --git a/gcc/asan.c b/gcc/asan.c
index 3e24e620d71..9251a802e98 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -2436,6 +2436,8 @@ initialize_sanitizer_builtins (void)
/* ECF_COLD missing */ ATTR_CONST_NORETURN_NOTHROW_LEAF_LIST
#undef ATTR_PURE_NOTHROW_LEAF_LIST
#define ATTR_PURE_NOTHROW_LEAF_LIST ECF_PURE | ATTR_NOTHROW_LEAF_LIST
+#undef DEF_BUILTIN_STUB
+#define DEF_BUILTIN_STUB(ENUM, NAME)
#undef DEF_SANITIZER_BUILTIN
#define DEF_SANITIZER_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
decl = add_builtin_function ("__builtin_" NAME, TYPE, ENUM, \
@@ -2455,6 +2457,7 @@ initialize_sanitizer_builtins (void)
ATTR_PURE_NOTHROW_LEAF_LIST)
#undef DEF_SANITIZER_BUILTIN
+#undef DEF_BUILTIN_STUB
}
/* Called via htab_traverse. Count number of emitted
diff --git a/gcc/sanitizer.def b/gcc/sanitizer.def
index ae3352df899..85163fbcd30 100644
--- a/gcc/sanitizer.def
+++ b/gcc/sanitizer.def
@@ -20,12 +20,16 @@ along with GCC; see the file COPYING3. If not see
/* Before including this file, you should define a macro:
+ DEF_BUILTIN_STUB(ENUM, NAME)
DEF_SANITIZER_BUILTIN (ENUM, NAME, TYPE, ATTRS)
See builtins.def for details.
The builtins are created by the C-family of FEs in c-family/c-common.c,
for other FEs by asan.c. */
+/* This has to come before all the sanitizer builtins. */
+DEF_BUILTIN_STUB(BEGIN_SANITIZER_BUILTINS, (const char *)0)
+
/* Address Sanitizer */
DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_INIT, "__asan_init",
BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
@@ -163,7 +167,7 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_ASAN_AFTER_DYNAMIC_INIT,
BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
/* Thread Sanitizer */
-DEF_SANITIZER_BUILTIN(BUILT_IN_TSAN_INIT, "__tsan_init",
+DEF_SANITIZER_BUILTIN(BUILT_IN_TSAN_INIT, "__tsan_init",
BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
DEF_SANITIZER_BUILTIN(BUILT_IN_TSAN_FUNC_ENTRY, "__tsan_func_entry",
BT_FN_VOID_PTR, ATTR_NOTHROW_LEAF_LIST)
@@ -498,3 +502,19 @@ DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT,
"__ubsan_handle_nonnull_return_abort",
BT_FN_VOID_PTR,
ATTR_COLD_NORETURN_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS,
+ "__ubsan_handle_dynamic_type_cache_miss",
+ BT_FN_VOID_PTR_PTR_PTR,
+ ATTR_COLD_NOTHROW_LEAF_LIST)
+DEF_SANITIZER_BUILTIN(BUILT_IN_UBSAN_HANDLE_DYNAMIC_TYPE_CACHE_MISS_ABORT,
+ "__ubsan_handle_dynamic_type_cache_miss_abort",
+ BT_FN_VOID_PTR_PTR_PTR,
+ ATTR_COLD_NOTHROW_LEAF_LIST)
+
+/* Sanitizer coverage */
+DEF_SANITIZER_BUILTIN(BUILT_IN_SANITIZER_COV_TRACE_PC,
+ "__sanitizer_cov_trace_pc",
+ BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
+
+/* This has to come after all the sanitizer builtins. */
+DEF_BUILTIN_STUB(END_SANITIZER_BUILTINS, (const char *)0)
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index 1839f579e96..e1d092432f6 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -35,6 +35,9 @@ along with GCC; see the file COPYING3. If not see
#include "data-streamer.h"
#include "streamer-hooks.h"
#include "lto-streamer.h"
+#include "cgraph.h"
+#include "builtins.h"
+#include "asan.h"
/* Read a STRING_CST from the string table in DATA_IN using input
block IB. */
@@ -1124,6 +1127,15 @@ streamer_get_builtin_tree (struct lto_input_block *ib, struct data_in *data_in)
if (fcode >= END_BUILTINS)
fatal_error ("machine independent builtin code out of range");
result = builtin_decl_explicit (fcode);
+ if (!result)
+ {
+ if (fcode > BEGIN_SANITIZER_BUILTINS
+ && fcode < END_SANITIZER_BUILTINS)
+ {
+ initialize_sanitizer_builtins ();
+ result = builtin_decl_explicit (fcode);
+ }
+ }
gcc_assert (result);
}
else if (fclass == BUILT_IN_MD)