re PR sanitizer/78708 ([ASAN][LTO] ICE in expand_ASAN_MARK, at internal-fn.c:380...
authorJakub Jelinek <jakub@gcc.gnu.org>
Sat, 10 Dec 2016 08:01:17 +0000 (09:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 10 Dec 2016 08:01:17 +0000 (09:01 +0100)
PR sanitizer/78708
* lto-streamer-in.c (input_function): In addition to debug stmts
without -g, remove IFN_*SAN_* calls if corresponding flag_sanitize
bit is not enabled.

From-SVN: r243514

gcc/ChangeLog
gcc/lto-streamer-in.c

index 8595b5763f210ee5773e6deab913c5e4308c7f52..93f4556e39f2179de0a712a0e5bdf8c21a62bb95 100644 (file)
@@ -1,3 +1,10 @@
+2016-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/78708
+       * lto-streamer-in.c (input_function): In addition to debug stmts
+       without -g, remove IFN_*SAN_* calls if corresponding flag_sanitize
+       bit is not enabled.
+
 2016-12-09  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * config/rs6000/rs6000-passes.def: New file.
@@ -10,8 +17,8 @@
 2016-12-09  Kugan Vivekanandarajah  <kuganv@linaro.org>
 
        PR ipa/78721
-       * ipa-cp.c (propagate_vr_accross_jump_function): drop_tree_overflow
-       after fold_convert.
+       * ipa-cp.c (propagate_vr_accross_jump_function): Call
+       drop_tree_overflow after fold_convert.
 
 2016-12-09  Jakub Jelinek  <jakub@redhat.com>
 
index 1f39e6b98767743c4f154a5d2a610e56a9597fe8..862e15664728c94947b6d1805a6b276bb9b402b9 100644 (file)
@@ -1110,15 +1110,59 @@ input_function (tree fn_decl, struct data_in *data_in,
       while (!gsi_end_p (bsi))
        {
          gimple *stmt = gsi_stmt (bsi);
+         bool remove = false;
          /* If we're recompiling LTO objects with debug stmts but
             we're not supposed to have debug stmts, remove them now.
             We can't remove them earlier because this would cause uid
             mismatches in fixups, but we can do it at this point, as
-            long as debug stmts don't require fixups.  */
-         if (!MAY_HAVE_DEBUG_STMTS && !flag_wpa && is_gimple_debug (stmt))
+            long as debug stmts don't require fixups.
+            Similarly remove all IFN_*SAN_* internal calls   */
+         if (!flag_wpa)
+           {
+             if (!MAY_HAVE_DEBUG_STMTS && is_gimple_debug (stmt))
+               remove = true;
+             if (is_gimple_call (stmt)
+                 && gimple_call_internal_p (stmt))
+               {
+                 switch (gimple_call_internal_fn (stmt))
+                   {
+                   case IFN_UBSAN_NULL:
+                     if ((flag_sanitize
+                         & (SANITIZE_NULL | SANITIZE_ALIGNMENT)) == 0)
+                       remove = true;
+                     break;
+                   case IFN_UBSAN_BOUNDS:
+                     if ((flag_sanitize & SANITIZE_BOUNDS) == 0)
+                       remove = true;
+                     break;
+                   case IFN_UBSAN_VPTR:
+                     if ((flag_sanitize & SANITIZE_VPTR) == 0)
+                       remove = true;
+                     break;
+                   case IFN_UBSAN_OBJECT_SIZE:
+                     if ((flag_sanitize & SANITIZE_OBJECT_SIZE) == 0)
+                       remove = true;
+                     break;
+                   case IFN_ASAN_MARK:
+                     if ((flag_sanitize & SANITIZE_ADDRESS) == 0)
+                       remove = true;
+                     break;
+                   case IFN_TSAN_FUNC_EXIT:
+                     if ((flag_sanitize & SANITIZE_THREAD) == 0)
+                       remove = true;
+                     break;
+                   default:
+                     break;
+                   }
+                 gcc_assert (!remove || gimple_call_lhs (stmt) == NULL_TREE);
+               }
+           }
+         if (remove)
            {
              gimple_stmt_iterator gsi = bsi;
              gsi_next (&bsi);
+             unlink_stmt_vdef (stmt);
+             release_defs (stmt);
              gsi_remove (&gsi, true);
            }
          else