public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug sanitizer/66190] [5/6 Regression] ICE: tree code ‘call_expr’ is not supported in LTO streams with -fsanitize=null
Date: Thu, 21 May 2015 11:04:00 -0000	[thread overview]
Message-ID: <bug-66190-4-UXRXdTWyPw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-66190-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66190

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Ok, then maybe the following could work (only lightly tested so far).  Arguably
static_init_p could be renamed to e.g. no_sanitize_p.

diff --git gcc/cp/cp-gimplify.c gcc/cp/cp-gimplify.c
index d5a64fc..a90c8b7 100644
--- gcc/cp/cp-gimplify.c
+++ gcc/cp/cp-gimplify.c
@@ -906,6 +906,7 @@ struct cp_genericize_data
   vec<tree> bind_expr_stack;
   struct cp_genericize_omp_taskreg *omp_ctx;
   tree try_block;
+  bool static_init_p;
 };

 /* Perform any pre-gimplification lowering of C++ front end trees to
@@ -1150,6 +1151,21 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void
*data)
       *stmt_p = build1 (NOP_EXPR, void_type_node, integer_zero_node);
       *walk_subtrees = 0;
     }
+  else if ((flag_sanitize
+           & (SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR))
+          && TREE_CODE (stmt) == DECL_EXPR
+          && VAR_P (DECL_EXPR_DECL (stmt))
+          && TREE_STATIC (DECL_EXPR_DECL (stmt))
+          && DECL_INITIAL (DECL_EXPR_DECL (stmt)))
+    {
+      *walk_subtrees = 0;
+      /* The point here is to not sanitize static initializers.  */
+      bool static_init_p = wtd->static_init_p;
+      wtd->static_init_p = true;
+      cp_walk_tree (&DECL_INITIAL (DECL_EXPR_DECL (stmt)), cp_genericize_r,
+                   data, NULL);
+      wtd->static_init_p = static_init_p;
+    }
   else if (TREE_CODE (stmt) == OMP_PARALLEL || TREE_CODE (stmt) == OMP_TASK)
     {
       struct cp_genericize_omp_taskreg omp_ctx;
@@ -1275,9 +1291,10 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void
*data)
       if (*stmt_p == error_mark_node)
        *stmt_p = size_one_node;
       return NULL;
-    }    
-  else if (flag_sanitize
-          & (SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR))
+    }
+  else if ((flag_sanitize
+           & (SANITIZE_NULL | SANITIZE_ALIGNMENT | SANITIZE_VPTR))
+          && !wtd->static_init_p)
     {
       if ((flag_sanitize & (SANITIZE_NULL | SANITIZE_ALIGNMENT))
          && TREE_CODE (stmt) == NOP_EXPR
@@ -1319,6 +1336,7 @@ cp_genericize_tree (tree* t_p)
   wtd.bind_expr_stack.create (0);
   wtd.omp_ctx = NULL;
   wtd.try_block = NULL_TREE;
+  wtd.static_init_p = false;
   cp_walk_tree (t_p, cp_genericize_r, &wtd, NULL);
   delete wtd.p_set;
   wtd.bind_expr_stack.release ();


  parent reply	other threads:[~2015-05-21 11:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18  8:49 [Bug sanitizer/66190] New: " marxin at gcc dot gnu.org
2015-05-18 12:45 ` [Bug sanitizer/66190] " rguenth at gcc dot gnu.org
2015-05-18 13:02 ` mpolacek at gcc dot gnu.org
2015-05-18 13:06 ` mpolacek at gcc dot gnu.org
2015-05-18 13:40 ` mpolacek at gcc dot gnu.org
2015-05-18 16:55 ` mpolacek at gcc dot gnu.org
2015-05-19 13:34 ` marxin at gcc dot gnu.org
2015-05-19 14:18 ` jakub at gcc dot gnu.org
2015-05-21 11:04 ` mpolacek at gcc dot gnu.org [this message]
2015-06-03 16:55 ` mpolacek at gcc dot gnu.org
2015-06-03 17:00 ` mpolacek at gcc dot gnu.org
2015-06-04  8:39 ` mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66190-4-UXRXdTWyPw@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).