+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>
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. */
/* 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
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.
--- /dev/null
+/* { 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); }