public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5936] Add -fipa-strict-aliasing
Date: Mon, 13 Dec 2021 16:30:30 +0000 (GMT)	[thread overview]
Message-ID: <20211213163030.A3EA8385803A@sourceware.org> (raw)

https://gcc.gnu.org/g:16c848090f237c2398930b8c0ef75acebf4fa44d

commit r12-5936-g16c848090f237c2398930b8c0ef75acebf4fa44d
Author: Jan Hubicka <jh@suse.cz>
Date:   Mon Dec 13 17:29:26 2021 +0100

    Add -fipa-strict-aliasing
    
    gcc/ChangeLog:
    
    2021-12-13  Jan Hubicka  <hubicka@ucw.cz>
    
            * common.opt: Add -fipa-strict-aliasing.
            * doc/invoke.texi: Document -fipa-strict-aliasing.
            * ipa-modref.c (modref_access_analysis::record_access): Honor
            -fipa-strict-aliasing.
            (modref_access_analysis::record_access_lto): Likewise.

Diff:
---
 gcc/common.opt      |  4 ++++
 gcc/doc/invoke.texi | 12 +++++++++++-
 gcc/ipa-modref.c    |  8 +++++---
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 445a53a265c..8f8fc2f9ee7 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1945,6 +1945,10 @@ fira-algorithm=
 Common Joined RejectNegative Enum(ira_algorithm) Var(flag_ira_algorithm) Init(IRA_ALGORITHM_CB) Optimization
 -fira-algorithm=[CB|priority]	Set the used IRA algorithm.
 
+fipa-strict-aliasing
+Common Var(flag_ipa_strict_aliasing) Init(1) Optimization
+Assume strict aliasing rules apply across (uninlined) function boundaries.
+
 Enum
 Name(ira_algorithm) Type(enum ira_algorithm) UnknownError(unknown IRA algorithm %qs)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 221c7c3ea48..80c36b9abe0 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -570,7 +570,7 @@ Objective-C and Objective-C++ Dialects}.
 -fsingle-precision-constant  -fsplit-ivs-in-unroller  -fsplit-loops@gol
 -fsplit-paths @gol
 -fsplit-wide-types  -fsplit-wide-types-early  -fssa-backprop  -fssa-phiopt @gol
--fstdarg-opt  -fstore-merging  -fstrict-aliasing @gol
+-fstdarg-opt  -fstore-merging  -fstrict-aliasing -fipa-strict-aliasing @gol
 -fthread-jumps  -ftracer  -ftree-bit-ccp @gol
 -ftree-builtin-call-dce  -ftree-ccp  -ftree-ch @gol
 -ftree-coalesce-vars  -ftree-copy-prop  -ftree-dce  -ftree-dominator-opts @gol
@@ -12423,6 +12423,16 @@ int f() @{
 The @option{-fstrict-aliasing} option is enabled at levels
 @option{-O2}, @option{-O3}, @option{-Os}.
 
+@item -fipa-strict-aliasing
+@opindex fipa-strict-aliasing
+Constrols whether rules of @option{-fstrict-aliasing} are applied across
+function boundaries.  Note that if multiple functions gets inlined into a
+signle function the memory accesses are no longer considred to be crossing a
+function bounday.
+
+The @option{-fipa-strict-aliasing} option is enabled by default and is
+effective only in combination with @option{-fstrict-aliasing}.
+
 @item -falign-functions
 @itemx -falign-functions=@var{n}
 @itemx -falign-functions=@var{n}:@var{m}
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index 2c89c63baf6..d6bd9d33278 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -999,9 +999,11 @@ modref_access_analysis::record_access (modref_records *tt,
 				       ao_ref *ref,
 				       modref_access_node &a)
 {
-  alias_set_type base_set = !flag_strict_aliasing ? 0
+  alias_set_type base_set = !flag_strict_aliasing
+			    || !flag_ipa_strict_aliasing ? 0
 			    : ao_ref_base_alias_set (ref);
-  alias_set_type ref_set = !flag_strict_aliasing ? 0
+  alias_set_type ref_set = !flag_strict_aliasing
+			   || !flag_ipa_strict_aliasing ? 0
 			    : (ao_ref_alias_set (ref));
   if (dump_file)
     {
@@ -1021,7 +1023,7 @@ modref_access_analysis::record_access_lto (modref_records_lto *tt, ao_ref *ref,
   /* get_alias_set sometimes use different type to compute the alias set
      than TREE_TYPE (base).  Do same adjustments.  */
   tree base_type = NULL_TREE, ref_type = NULL_TREE;
-  if (flag_strict_aliasing)
+  if (flag_strict_aliasing && flag_ipa_strict_aliasing)
     {
       tree base;


                 reply	other threads:[~2021-12-13 16:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211213163030.A3EA8385803A@sourceware.org \
    --to=hubicka@gcc.gnu.org \
    --cc=gcc-cvs@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).