Commit 87a5e0e8 by Richard Biener Committed by Richard Biener

re PR sanitizer/83388 (reference statement index not found error with -fsanitize=null)

2017-12-15  Richard Biener  <rguenther@suse.de>

	PR lto/83388
	* internal-fn.def (IFN_NOP): Add.
	* internal-fn.c (expand_NOP): Do nothing.
	* lto-streamer-in.c (input_function): Instead of removing
	sanitizer calls replace them with IFN_NOP calls.

	* gcc.dg/lto/pr83388_0.c: New testcase.

From-SVN: r255694
parent fc47ef60
2017-12-15 Richard Biener <rguenther@suse.de>
PR lto/83388
* internal-fn.def (IFN_NOP): Add.
* internal-fn.c (expand_NOP): Do nothing.
* lto-streamer-in.c (input_function): Instead of removing
sanitizer calls replace them with IFN_NOP calls.
2017-12-15 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
......@@ -2722,6 +2722,14 @@ expand_DIVMOD (internal_fn, gcall *call_stmt)
target, VOIDmode, EXPAND_NORMAL);
}
/* Expand a NOP. */
static void
expand_NOP (internal_fn, gcall *)
{
/* Nothing. But it shouldn't really prevail. */
}
/* Expand a call to FN using the operands in STMT. FN has a single
output operand and NARGS input operands. */
......
......@@ -254,6 +254,9 @@ DEF_INTERNAL_FN (LAUNDER, ECF_LEAF | ECF_NOTHROW | ECF_NOVOPS, NULL)
/* Divmod function. */
DEF_INTERNAL_FN (DIVMOD, ECF_CONST | ECF_LEAF, NULL)
/* A NOP function with arbitrary arguments and return value. */
DEF_INTERNAL_FN (NOP, ECF_CONST | ECF_LEAF | ECF_NOTHROW, NULL)
#undef DEF_INTERNAL_INT_FN
#undef DEF_INTERNAL_FLT_FN
#undef DEF_INTERNAL_FLT_FLOATN_FN
......
......@@ -1136,41 +1136,47 @@ input_function (tree fn_decl, struct data_in *data_in,
if (is_gimple_call (stmt)
&& gimple_call_internal_p (stmt))
{
bool replace = false;
switch (gimple_call_internal_fn (stmt))
{
case IFN_UBSAN_NULL:
if ((flag_sanitize
& (SANITIZE_NULL | SANITIZE_ALIGNMENT)) == 0)
remove = true;
replace = true;
break;
case IFN_UBSAN_BOUNDS:
if ((flag_sanitize & SANITIZE_BOUNDS) == 0)
remove = true;
replace = true;
break;
case IFN_UBSAN_VPTR:
if ((flag_sanitize & SANITIZE_VPTR) == 0)
remove = true;
replace = true;
break;
case IFN_UBSAN_OBJECT_SIZE:
if ((flag_sanitize & SANITIZE_OBJECT_SIZE) == 0)
remove = true;
replace = true;
break;
case IFN_UBSAN_PTR:
if ((flag_sanitize & SANITIZE_POINTER_OVERFLOW) == 0)
remove = true;
replace = true;
break;
case IFN_ASAN_MARK:
if ((flag_sanitize & SANITIZE_ADDRESS) == 0)
remove = true;
replace = true;
break;
case IFN_TSAN_FUNC_EXIT:
if ((flag_sanitize & SANITIZE_THREAD) == 0)
remove = true;
replace = true;
break;
default:
break;
}
gcc_assert (!remove || gimple_call_lhs (stmt) == NULL_TREE);
if (replace)
{
gimple_call_set_internal_fn (as_a <gcall *> (stmt),
IFN_NOP);
update_stmt (stmt);
}
}
}
if (remove)
......
2017-12-15 Richard Biener <rguenther@suse.de>
PR lto/83388
* gcc.dg/lto/pr83388_0.c: New testcase.
2017-12-15 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/expr_func2.ads, gnat.dg/expr_func2.adb: New testcase.
......
/* { dg-lto-do link } */
/* { dg-lto-options { { -O2 -flto -fsanitize=null } { -O0 -flto -fsanitize=null } } } */
/* { dg-extra-ld-options { -fno-sanitize=null -r -nostdlib } } */
enum { a } e(void);
struct C {
int d;
} c;
long f;
void g(long);
static void i(_Bool h) {
struct C *a = ({ ({ &c; }); });
if (e()) {
int b = a->d;
g(f);
}
}
void j(void) { i(a); }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment