public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/101419] [9/10/11/12 Regression] collapsing memset() calls can break __builtin_object_size()
Date: Mon, 12 Jul 2021 09:58:09 +0000	[thread overview]
Message-ID: <bug-101419-4-hjvz7Ej4EM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101419-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
--- gcc/tree-object-size.c.jj   2021-01-04 10:25:39.911221618 +0100
+++ gcc/tree-object-size.c      2021-07-12 11:28:51.328120222 +0200
@@ -1393,6 +1393,11 @@ pass_object_sizes::execute (function *fu
                        {
                          tree tem = make_ssa_name (type);
                          gimple_call_set_lhs (call, tem);
+                         if (object_size_type == 1)
+                           {
+                             ost = build_zero_cst (TREE_TYPE (ost));
+                             gimple_call_set_arg (call, 1, ost);
+                           }
                          enum tree_code code
                            = object_size_type == 1 ? MIN_EXPR : MAX_EXPR;
                          tree cst = build_int_cstu (type, bytes);
works, but unfortunately only for __builtin_object_size (, 1).
When I did that also for 3 (to turn it into 2), it breaks several
gcc.dg/builtin-object-size*.c tests.
0 is defined as an upper bound of the object size, subobjects not taken into
account
1 is defined similarly, but subobjects are taken into account
2 is defined as a lower bound of the object size, subobjects not taken into
account
3 is 2 with subobjects
-D_FORTIFY_SOURCE={1,2} typically only uses 0 and 1 modes, 2 and 3 are rare,
and are useful e.g. when somebody wants to find out if the object size is exact
or not (for exact case the upper and lower bounds are equal).

  parent reply	other threads:[~2021-07-12  9:58 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-11 14:45 [Bug c/101419] New: " kees at outflux dot net
2021-07-12  7:59 ` [Bug tree-optimization/101419] " rguenth at gcc dot gnu.org
2021-07-12  8:33 ` [Bug tree-optimization/101419] [9/10/11/12 Regression] " jakub at gcc dot gnu.org
2021-07-12  9:03 ` rguenth at gcc dot gnu.org
2021-07-12  9:58 ` jakub at gcc dot gnu.org [this message]
2021-07-12 10:37 ` jakub at gcc dot gnu.org
2021-07-12 10:50 ` rguenth at gcc dot gnu.org
2021-07-12 10:59 ` jakub at gcc dot gnu.org
2021-07-12 11:21 ` jakub at gcc dot gnu.org
2021-07-12 11:26 ` jakub at gcc dot gnu.org
2021-07-12 11:42 ` jakub at gcc dot gnu.org
2021-07-12 11:51 ` rguenth at gcc dot gnu.org
2021-07-12 11:52 ` rguenth at gcc dot gnu.org
2021-07-12 11:56 ` rguenth at gcc dot gnu.org
2021-07-12 12:04 ` jakub at gcc dot gnu.org
2021-07-12 12:07 ` jakub at gcc dot gnu.org
2021-07-12 13:20 ` rguenther at suse dot de
2021-07-12 13:24 ` rguenther at suse dot de
2021-07-12 13:32 ` jakub at gcc dot gnu.org
2021-07-12 14:39 ` rguenther at suse dot de
2021-07-12 15:59 ` jakub at gcc dot gnu.org
2021-07-13  9:05 ` cvs-commit at gcc dot gnu.org
2021-07-13 13:05 ` [Bug tree-optimization/101419] [9/10/11 " jakub at gcc dot gnu.org
2022-05-27  9:45 ` [Bug tree-optimization/101419] [10/11 " rguenth at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-07-07 10:40 ` [Bug tree-optimization/101419] [11 " rguenth at gcc dot gnu.org
2024-07-19  7:20 ` rguenth 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-101419-4-hjvz7Ej4EM@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).