public inbox for gcc-regression@sourceware.org
help / color / mirror / Atom feed
* [TCWG CI] Regression caused by gcc: Drop the fpic multilib for powerpc*-vxworks*
@ 2021-12-19  1:04 ci_notify
  0 siblings, 0 replies; only message in thread
From: ci_notify @ 2021-12-19  1:04 UTC (permalink / raw)
  To: Frederic Konrad; +Cc: gcc-regression

[TCWG CI] Regression caused by gcc: Drop the fpic multilib for powerpc*-vxworks*:
commit dff8ae8e839a5102aff266c8246864b610c066c9
Author: Frederic Konrad <konrad@adacore.com>

    Drop the fpic multilib for powerpc*-vxworks*

Results regressed to
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1 -- --set gcc_override_configure=--disable-libsanitizer --set gcc_override_configure=--disable-multilib --set gcc_override_configure=--with-cpu=cortex-m4 --set gcc_override_configure=--with-mode=thumb --set gcc_override_configure=--with-float=hard:
-8
# build_abe newlib:
-6
# build_abe stage2 -- --set gcc_override_configure=--disable-libsanitizer --set gcc_override_configure=--disable-multilib --set gcc_override_configure=--with-cpu=cortex-m4 --set gcc_override_configure=--with-mode=thumb --set gcc_override_configure=--with-float=hard:
-5
# benchmark -- -O3_mthumb artifacts/build-dff8ae8e839a5102aff266c8246864b610c066c9/results_id:
1

from
# reset_artifacts:
-10
# build_abe binutils:
-9
# build_abe stage1 -- --set gcc_override_configure=--disable-libsanitizer --set gcc_override_configure=--disable-multilib --set gcc_override_configure=--with-cpu=cortex-m4 --set gcc_override_configure=--with-mode=thumb --set gcc_override_configure=--with-float=hard:
-8
# build_abe newlib:
-6
# build_abe stage2 -- --set gcc_override_configure=--disable-libsanitizer --set gcc_override_configure=--disable-multilib --set gcc_override_configure=--with-cpu=cortex-m4 --set gcc_override_configure=--with-mode=thumb --set gcc_override_configure=--with-float=hard:
-5
# benchmark -- -O3_mthumb artifacts/build-baseline/results_id:
1

THIS IS THE END OF INTERESTING STUFF.  BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.

This commit has regressed these CI configurations:
 - tcwg_bmk_gnu_eabi_stm32/gnu_eabi-master-arm_eabi-coremark-O3

First_bad build: https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/build-dff8ae8e839a5102aff266c8246864b610c066c9/
Last_good build: https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/build-e163dbbc4433e598cad7e6011b255d1d6ad93a3b/
Baseline build: https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/build-baseline/
Even more details: https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/

Reproduce builds:
<cut>
mkdir investigate-gcc-dff8ae8e839a5102aff266c8246864b610c066c9
cd investigate-gcc-dff8ae8e839a5102aff266c8246864b610c066c9

# Fetch scripts
git clone https://git.linaro.org/toolchain/jenkins-scripts

# Fetch manifests and test.sh script
mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/manifests/build-baseline.sh --fail
curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/manifests/build-parameters.sh --fail
curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_bmk_ci_gnu_eabi-bisect-tcwg_bmk_stm32-gnu_eabi-master-arm_eabi-coremark-O3/13/artifact/artifacts/test.sh --fail
chmod +x artifacts/test.sh

# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_bmk-build.sh @@ artifacts/manifests/build-baseline.sh

# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /gcc/ ./ ./bisect/baseline/

cd gcc

# Reproduce first_bad build
git checkout --detach dff8ae8e839a5102aff266c8246864b610c066c9
../artifacts/test.sh

# Reproduce last_good build
git checkout --detach e163dbbc4433e598cad7e6011b255d1d6ad93a3b
../artifacts/test.sh

cd ..
</cut>

Full commit (up to 1000 lines):
<cut>
commit dff8ae8e839a5102aff266c8246864b610c066c9
Author: Frederic Konrad <konrad@adacore.com>
Date:   Thu Nov 12 12:39:25 2020 +0100

    Drop the fpic multilib for powerpc*-vxworks*
    
    The addition of fPIC for shared libraries is performed
    independently from multilibs and the fpic multilibs have
    no other particular purpose. They incur extra build time,
    complexify the install tree and are a bit tricky because
    -fpic is not supported for kernel mode.
    
    2020-11-06  Fred Konrad  <konrad@adacore.com>
    
    gcc/
            * config/rs6000/t-vxworks: Drop the fPIC multilib.
---
 gcc/config/rs6000/t-vxworks | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/t-vxworks b/gcc/config/rs6000/t-vxworks
index 68b241523e3..6da829d40b7 100644
--- a/gcc/config/rs6000/t-vxworks
+++ b/gcc/config/rs6000/t-vxworks
@@ -19,7 +19,7 @@
 # <http://www.gnu.org/licenses/>.
 
 # The base multilib is -mhard-float.
-MULTILIB_OPTIONS = mrtp fPIC msoft-float
+MULTILIB_OPTIONS = mrtp msoft-float
 MULTILIB_DIRNAMES =
-MULTILIB_MATCHES = fPIC=fpic
-MULTILIB_EXCEPTIONS = fPIC*
+MULTILIB_MATCHES =
+MULTILIB_EXCEPTIONS =
</cut>
>From ci_notify@linaro.org  Sun Dec 19 03:20:29 2021
Return-Path: <ci_notify@linaro.org>
X-Original-To: gcc-regression@gcc.gnu.org
Delivered-To: gcc-regression@gcc.gnu.org
Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com
 [IPv6:2a00:1450:4864:20::435])
 by sourceware.org (Postfix) with ESMTPS id 817B73858C27
 for <gcc-regression@gcc.gnu.org>; Sun, 19 Dec 2021 03:20:24 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 817B73858C27
Received: by mail-wr1-x435.google.com with SMTP id e5so12376693wrc.5
 for <gcc-regression@gcc.gnu.org>; Sat, 18 Dec 2021 19:20:24 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:date:to:cc:message-id:subject:mime-version
 :list-id;
 bh=JugT9uDzjfAhDdAxm8kRoE4LlP2knepPhZuEebJ71ko=;
 b=iNEfvmZ7/O0QvW0dQeD3Wnkg89gZy+6gbrYDjLv8ONlVWKwazEWP5lBjjE/jbnBZjv
 lPGn0b64tpliZheGFdUruXbX4ey0UcgwNXCtfitZHcmtkYTeCeytdi49vfGJ5Bynev2d
 DwFti7dFdqZ2YQ2/Hmr8qul3I7OleoYFpTJ6ZuTJMkAUqGO06u9/AhiCnFzNLu/G973K
 WPnylMtvqNx7KU8tfy3V++rG9Osaa/zWWSrGH9e66IkWyZKNkLgicD2d5cv5+lUQDyn6
 T6OS4r3jFWOoIywFJ5ZrpXS3i0xjXVZf+TCwmHwQhgLaod9AWtq3hVkoWsC9tCBepaVg
 gKnA==
X-Gm-Message-State: AOAM53216M9NM0bUsVOi0yDciTwUrq4oGyCOlTawCjC9kPXLZqWqaHnT
 k9jgvzPgNGQNTicD/44C/oFZKw==
X-Google-Smtp-Source: ABdhPJyfHUs/B/hmoKalxe002kmNGXTi019fvF/anT3EVWR0nqW95I///QAVs8UwsJIimoQtRFQlsw==
X-Received: by 2002:a05:6000:148:: with SMTP id
 r8mr7607425wrx.333.1639884023174; 
 Sat, 18 Dec 2021 19:20:23 -0800 (PST)
Received: from jenkins.jenkins (ci.linaro.org. [88.99.136.175])
 by smtp.gmail.com with ESMTPSA id f15sm14091639wmg.30.2021.12.18.19.20.22
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 18 Dec 2021 19:20:22 -0800 (PST)
From: ci_notify@linaro.org
X-Google-Original-From: linaro-infrastructure-errors@lists.linaro.org
Date: Sun, 19 Dec 2021 03:20:21 +0000 (UTC)
To: Siddhesh Poyarekar <siddhesh@gotplt.org>
Cc: gcc-regression@gcc.gnu.org
Message-ID: <1641865040.5969.1639884022674@jenkins.jenkins>
Subject: [TCWG CI] Regression caused by gcc: tree-object-size: Use trees and
 support negative offsets
MIME-Version: 1.0
X-Jenkins-Job: TCWG Bisect tcwg_gcc_bootstrap/master-arm-bootstrap_ubsan
X-Jenkins-Result: SUCCESS
X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_LOTSOFHASH,
 RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS,
 TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Content-Filtered-By: Mailman/MimeDel 2.1.29
X-BeenThere: gcc-regression@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-regression mailing list <gcc-regression.gcc.gnu.org>
List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=unsubscribe>
List-Archive: <https://gcc.gnu.org/pipermail/gcc-regression/>
List-Post: <mailto:gcc-regression@gcc.gnu.org>
List-Help: <mailto:gcc-regression-request@gcc.gnu.org?subject=help>
List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 19 Dec 2021 03:20:29 -0000

[TCWG CI] Regression caused by gcc: tree-object-size: Use trees and support negative offsets:
commit 422f9eb7011b76c12ff00ffaee2bcc9cdddf16d5
Author: Siddhesh Poyarekar <siddhesh@gotplt.org>

    tree-object-size: Use trees and support negative offsets

Results regressed to
# reset_artifacts:
-10
# true:
0
# build_abe binutils:
1
# First few build errors in logs:
# 00:08:45 make[3]: [Makefile:1775: armv8l-unknown-linux-gnueabihf/bits/largefile-config.h] Error 1 (ignored)
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/move.h:205:7: runtime error: load of address 0xffc9b718 with insufficient space for an object of type 'struct pattern_pos'
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/move.h:206:7: runtime error: store to address 0xffc9b718 with insufficient space for an object of type 'struct pattern_pos'
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/stl_algo.h:1791:4: runtime error: load of address 0xffc9b88c with insufficient space for an object of type 'struct pattern_pos'
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/move.h:205:7: runtime error: load of address 0xffc9b8a4 with insufficient space for an object of type 'struct pattern_pos'
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/move.h:206:7: runtime error: store to address 0xffc9b8a4 with insufficient space for an object of type 'struct pattern_pos'
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/move.h:205:7: runtime error: load of address 0xffc9b8a4 with insufficient space for an object of type 'struct pattern_pos'
# 00:23:40 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/builds/armv8l-unknown-linux-gnueabihf/armv8l-unknown-linux-gnueabihf/gcc-gcc.git~master-stage2/prev-armv8l-unknown-linux-gnueabihf/libstdc++-v3/include/bits/move.h:206:7: runtime error: store to address 0xffc9b8a4 with insufficient space for an object of type 'struct pattern_pos'
# 00:24:39 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/snapshots/gcc.git~master/libcpp/include/line-map.h:1225:19: runtime error: load of address 0x01a39b9c with insufficient space for an object of type 'const location_t'
# 00:24:39 /home/tcwg-buildslave/workspace/tcwg_gnu_13/abe/snapshots/gcc.git~master/libcpp/include/line-map.h:1213:19: runtime error: load of address 0x01a39b9c with insufficient space for an object of type 'const location_t'

from
# reset_artifacts:
-10
# true:
0
# build_abe binutils:
1
# build_abe bootstrap_ubsan:
2

THIS IS THE END OF INTERESTING STUFF.  BELOW ARE LINKS TO BUILDS, REPRODUCTION INSTRUCTIONS, AND THE RAW COMMIT.

This commit has regressed these CI configurations:
 - tcwg_gcc_bootstrap/master-arm-bootstrap_ubsan

First_bad build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/build-422f9eb7011b76c12ff00ffaee2bcc9cdddf16d5/
Last_good build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/build-871504b0dd5cd023d3a28cf9e5ccbda75928b102/
Baseline build: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/build-baseline/
Even more details: https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/

Reproduce builds:
<cut>
mkdir investigate-gcc-422f9eb7011b76c12ff00ffaee2bcc9cdddf16d5
cd investigate-gcc-422f9eb7011b76c12ff00ffaee2bcc9cdddf16d5

# Fetch scripts
git clone https://git.linaro.org/toolchain/jenkins-scripts

# Fetch manifests and test.sh script
mkdir -p artifacts/manifests
curl -o artifacts/manifests/build-baseline.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/manifests/build-baseline.sh --fail
curl -o artifacts/manifests/build-parameters.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/manifests/build-parameters.sh --fail
curl -o artifacts/test.sh https://ci.linaro.org/job/tcwg_gcc_bootstrap-bisect-master-arm-bootstrap_ubsan/6/artifact/artifacts/test.sh --fail
chmod +x artifacts/test.sh

# Reproduce the baseline build (build all pre-requisites)
./jenkins-scripts/tcwg_gnu-build.sh @@ artifacts/manifests/build-baseline.sh

# Save baseline build state (which is then restored in artifacts/test.sh)
mkdir -p ./bisect
rsync -a --del --delete-excluded --exclude /bisect/ --exclude /artifacts/ --exclude /gcc/ ./ ./bisect/baseline/

cd gcc

# Reproduce first_bad build
git checkout --detach 422f9eb7011b76c12ff00ffaee2bcc9cdddf16d5
../artifacts/test.sh

# Reproduce last_good build
git checkout --detach 871504b0dd5cd023d3a28cf9e5ccbda75928b102
../artifacts/test.sh

cd ..
</cut>

Full commit (up to 1000 lines):
<cut>
commit 422f9eb7011b76c12ff00ffaee2bcc9cdddf16d5
Author: Siddhesh Poyarekar <siddhesh@gotplt.org>
Date:   Fri Dec 17 07:07:18 2021 +0530

    tree-object-size: Use trees and support negative offsets
    
    Transform tree-object-size to operate on tree objects instead of host
    wide integers.  This makes it easier to extend to dynamic expressions
    for object sizes.
    
    The compute_builtin_object_size interface also now returns a tree
    expression instead of HOST_WIDE_INT, so callers have been adjusted to
    account for that.
    
    The trees in object_sizes are each an object_size object with members
    size (the bytes from the pointer to the end of the object) and wholesize
    (the size of the whole object).  This allows analysis of negative
    offsets, which can now be allowed to the extent of the object bounds.
    Tests have been added to verify that it actually works.
    
    gcc/ChangeLog:
    
            * tree-object-size.h (compute_builtin_object_size): Return tree
            instead of HOST_WIDE_INT.
            * builtins.c (fold_builtin_object_size): Adjust.
            * gimple-fold.c (gimple_fold_builtin_strncat): Likewise.
            * ubsan.c (instrument_object_size): Likewise.
            * tree-object-size.c (object_size): New structure.
            (object_sizes): Change type to vec<object_size>.
            (initval): New function.
            (unknown): Use it.
            (size_unknown_p, size_initval, size_unknown): New functions.
            (object_sizes_unknown_p): Use it.
            (object_sizes_get): Return tree.
            (object_sizes_initialize): Rename from object_sizes_set_force
            and set VAL parameter type as tree.  Add new parameter WHOLEVAL.
            (object_sizes_set): Set VAL parameter type as tree and adjust
            implementation.  Add new parameter WHOLEVAL.
            (size_for_offset): New function.
            (decl_init_size): Adjust comment.
            (addr_object_size): Change PSIZE parameter to tree and adjust
            implementation.  Add new parameter PWHOLESIZE.
            (alloc_object_size): Return tree.
            (compute_builtin_object_size): Return tree in PSIZE.
            (expr_object_size, call_object_size, unknown_object_size):
            Adjust for object_sizes_set change.
            (merge_object_sizes): Drop OFFSET parameter and adjust
            implementation for tree change.
            (plus_stmt_object_size): Call collect_object_sizes_for directly
            instead of merge_object_size and call size_for_offset to get net
            size.
            (cond_expr_object_size, collect_object_sizes_for,
            object_sizes_execute): Adjust for change of type from
            HOST_WIDE_INT to tree.
            (check_for_plus_in_loops_1): Likewise and skip non-positive
            offsets.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/builtin-object-size-1.c (test9): New test.
            (main): Call it.
            * gcc.dg/builtin-object-size-2.c (test8): New test.
            (main): Call it.
            * gcc.dg/builtin-object-size-3.c (test9): New test.
            (main): Call it.
            * gcc.dg/builtin-object-size-4.c (test8): New test.
            (main): Call it.
            * gcc.dg/builtin-object-size-5.c (test5, test6, test7): New
            tests.
    
    Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
---
 gcc/builtins.c                               |  10 +-
 gcc/gimple-fold.c                            |  11 +-
 gcc/testsuite/gcc.dg/builtin-object-size-1.c |  30 ++
 gcc/testsuite/gcc.dg/builtin-object-size-2.c |  30 ++
 gcc/testsuite/gcc.dg/builtin-object-size-3.c |  31 +++
 gcc/testsuite/gcc.dg/builtin-object-size-4.c |  30 ++
 gcc/testsuite/gcc.dg/builtin-object-size-5.c |  25 ++
 gcc/tree-object-size.c                       | 394 +++++++++++++++++----------
 gcc/tree-object-size.h                       |   2 +-
 gcc/ubsan.c                                  |   5 +-
 10 files changed, 409 insertions(+), 159 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index cd8947b4de2..abe342e111d 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -10255,7 +10255,7 @@ maybe_emit_sprintf_chk_warning (tree exp, enum built_in_function fcode)
 static tree
 fold_builtin_object_size (tree ptr, tree ost)
 {
-  unsigned HOST_WIDE_INT bytes;
+  tree bytes;
   int object_size_type;
 
   if (!validate_arg (ptr, POINTER_TYPE)
@@ -10280,8 +10280,8 @@ fold_builtin_object_size (tree ptr, tree ost)
   if (TREE_CODE (ptr) == ADDR_EXPR)
     {
       compute_builtin_object_size (ptr, object_size_type, &bytes);
-      if (wi::fits_to_tree_p (bytes, size_type_node))
-	return build_int_cstu (size_type_node, bytes);
+      if (int_fits_type_p (bytes, size_type_node))
+	return fold_convert (size_type_node, bytes);
     }
   else if (TREE_CODE (ptr) == SSA_NAME)
     {
@@ -10289,8 +10289,8 @@ fold_builtin_object_size (tree ptr, tree ost)
        later.  Maybe subsequent passes will help determining
        it.  */
       if (compute_builtin_object_size (ptr, object_size_type, &bytes)
-	  && wi::fits_to_tree_p (bytes, size_type_node))
-	return build_int_cstu (size_type_node, bytes);
+	  && int_fits_type_p (bytes, size_type_node))
+	return fold_convert (size_type_node, bytes);
     }
 
   return NULL_TREE;
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 1d8fd74f72c..64515aabc04 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -2493,17 +2493,16 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi)
   if (!src_len || known_lower (stmt, len, src_len, true))
     return false;
 
-  unsigned HOST_WIDE_INT dstsize;
-  bool found_dstsize = compute_builtin_object_size (dst, 1, &dstsize);
-
   /* Warn on constant LEN.  */
   if (TREE_CODE (len) == INTEGER_CST)
     {
       bool nowarn = warning_suppressed_p (stmt, OPT_Wstringop_overflow_);
+      tree dstsize;
 
-      if (!nowarn && found_dstsize)
+      if (!nowarn && compute_builtin_object_size (dst, 1, &dstsize)
+	  && TREE_CODE (dstsize) == INTEGER_CST)
 	{
-	  int cmpdst = compare_tree_int (len, dstsize);
+	  int cmpdst = tree_int_cst_compare (len, dstsize);
 
 	  if (cmpdst >= 0)
 	    {
@@ -2519,7 +2518,7 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi)
 				   ? G_("%qD specified bound %E equals "
 					"destination size")
 				   : G_("%qD specified bound %E exceeds "
-					"destination size %wu"),
+					"destination size %E"),
 				   fndecl, len, dstsize);
 	      if (nowarn)
 		suppress_warning (stmt, OPT_Wstringop_overflow_);
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-1.c b/gcc/testsuite/gcc.dg/builtin-object-size-1.c
index 8cdae49a6b1..0154f4e9695 100644
--- a/gcc/testsuite/gcc.dg/builtin-object-size-1.c
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-1.c
@@ -424,6 +424,35 @@ test8 (void)
     abort ();
 }
 
+void
+__attribute__ ((noinline))
+test9 (unsigned cond)
+{
+  char *buf2 = malloc (10);
+  char *p;
+
+  if (cond)
+    p = &buf2[8];
+  else
+    p = &buf2[4];
+
+  if (__builtin_object_size (&p[-4], 0) != 10)
+    abort ();
+
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 0) != 10)
+    abort ();
+
+  p = &y.c[8];
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 0) != sizeof (y))
+    abort ();
+}
+
 int
 main (void)
 {
@@ -437,5 +466,6 @@ main (void)
   test6 (4);
   test7 ();
   test8 ();
+  test9 (1);
   exit (0);
 }
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-2.c b/gcc/testsuite/gcc.dg/builtin-object-size-2.c
index ad2dd296a9a..5cf29291aff 100644
--- a/gcc/testsuite/gcc.dg/builtin-object-size-2.c
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-2.c
@@ -382,6 +382,35 @@ test7 (void)
     abort ();
 }
 
+void
+__attribute__ ((noinline))
+test8 (unsigned cond)
+{
+  char *buf2 = malloc (10);
+  char *p;
+
+  if (cond)
+    p = &buf2[8];
+  else
+    p = &buf2[4];
+
+  if (__builtin_object_size (&p[-4], 1) != 10)
+    abort ();
+
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 1) != 10)
+    abort ();
+
+  p = &y.c[8];
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 1) != sizeof (y.c))
+    abort ();
+}
+
 int
 main (void)
 {
@@ -394,5 +423,6 @@ main (void)
   test5 (4);
   test6 ();
   test7 ();
+  test8 (1);
   exit (0);
 }
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-3.c b/gcc/testsuite/gcc.dg/builtin-object-size-3.c
index d5ca5047ee9..3a692c4e3d2 100644
--- a/gcc/testsuite/gcc.dg/builtin-object-size-3.c
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-3.c
@@ -430,6 +430,36 @@ test8 (void)
     abort ();
 }
 
+void
+__attribute__ ((noinline))
+test9 (unsigned cond)
+{
+  char *buf2 = malloc (10);
+  char *p;
+
+  if (cond)
+    p = &buf2[8];
+  else
+    p = &buf2[4];
+
+  if (__builtin_object_size (&p[-4], 2) != 6)
+    abort ();
+
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 2) != 2)
+    abort ();
+
+  p = &y.c[8];
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 2)
+      != sizeof (y) - __builtin_offsetof (struct A, c) - 8)
+    abort ();
+}
+
 int
 main (void)
 {
@@ -443,5 +473,6 @@ main (void)
   test6 (4);
   test7 ();
   test8 ();
+  test9 (1);
   exit (0);
 }
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-4.c b/gcc/testsuite/gcc.dg/builtin-object-size-4.c
index 9f159e36a0f..87381620cc9 100644
--- a/gcc/testsuite/gcc.dg/builtin-object-size-4.c
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-4.c
@@ -395,6 +395,35 @@ test7 (void)
     abort ();
 }
 
+void
+__attribute__ ((noinline))
+test8 (unsigned cond)
+{
+  char *buf2 = malloc (10);
+  char *p;
+
+  if (cond)
+    p = &buf2[8];
+  else
+    p = &buf2[4];
+
+  if (__builtin_object_size (&p[-4], 3) != 6)
+    abort ();
+
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 3) != 2)
+    abort ();
+
+  p = &y.c[8];
+  for (unsigned i = cond; i > 0; i--)
+    p--;
+
+  if (__builtin_object_size (p, 3) != sizeof (y.c) - 8)
+    abort ();
+}
+
 int
 main (void)
 {
@@ -407,5 +436,6 @@ main (void)
   test5 (4);
   test6 ();
   test7 ();
+  test8 (1);
   exit (0);
 }
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-5.c b/gcc/testsuite/gcc.dg/builtin-object-size-5.c
index 7c274cdfd42..8e63d9c7a5e 100644
--- a/gcc/testsuite/gcc.dg/builtin-object-size-5.c
+++ b/gcc/testsuite/gcc.dg/builtin-object-size-5.c
@@ -53,4 +53,29 @@ test4 (size_t x)
     abort ();
 }
 
+void
+test5 (void)
+{
+  char *p = &buf[0x90000004];
+  if (__builtin_object_size (p + 2, 0) != 0)
+    abort ();
+}
+
+void
+test6 (void)
+{
+  char *p = &buf[-4];
+  if (__builtin_object_size (p + 2, 0) != 0)
+    abort ();
+}
+
+void
+test7 (void)
+{
+  char *buf2 = __builtin_malloc (8);
+  char *p = &buf2[0x90000004];
+  if (__builtin_object_size (p + 2, 0) != 0)
+    abort ();
+}
+
 /* { dg-final { scan-assembler-not "abort" } } */
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index b4881ef198f..32ef6dd5133 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -45,6 +45,14 @@ struct object_size_info
   unsigned int *stack, *tos;
 };
 
+struct GTY(()) object_size
+{
+  /* Estimate of bytes till the end of the object.  */
+  tree size;
+  /* Estimate of the size of the whole object.  */
+  tree wholesize;
+};
+
 enum
 {
   OST_SUBOBJECT = 1,
@@ -54,13 +62,12 @@ enum
 
 static tree compute_object_offset (const_tree, const_tree);
 static bool addr_object_size (struct object_size_info *,
-			      const_tree, int, unsigned HOST_WIDE_INT *);
-static unsigned HOST_WIDE_INT alloc_object_size (const gcall *, int);
+			      const_tree, int, tree *, tree *t = NULL);
+static tree alloc_object_size (const gcall *, int);
 static tree pass_through_call (const gcall *);
 static void collect_object_sizes_for (struct object_size_info *, tree);
 static void expr_object_size (struct object_size_info *, tree, tree);
-static bool merge_object_sizes (struct object_size_info *, tree, tree,
-				unsigned HOST_WIDE_INT);
+static bool merge_object_sizes (struct object_size_info *, tree, tree);
 static bool plus_stmt_object_size (struct object_size_info *, tree, gimple *);
 static bool cond_expr_object_size (struct object_size_info *, tree, gimple *);
 static void init_offset_limit (void);
@@ -68,13 +75,13 @@ static void check_for_plus_in_loops (struct object_size_info *, tree);
 static void check_for_plus_in_loops_1 (struct object_size_info *, tree,
 				       unsigned int);
 
-/* object_sizes[0] is upper bound for number of bytes till the end of
-   the object.
-   object_sizes[1] is upper bound for number of bytes till the end of
-   the subobject (innermost array or field with address taken).
-   object_sizes[2] is lower bound for number of bytes till the end of
-   the object and object_sizes[3] lower bound for subobject.  */
-static vec<unsigned HOST_WIDE_INT> object_sizes[OST_END];
+/* object_sizes[0] is upper bound for the object size and number of bytes till
+   the end of the object.
+   object_sizes[1] is upper bound for the object size and number of bytes till
+   the end of the subobject (innermost array or field with address taken).
+   object_sizes[2] is lower bound for the object size and number of bytes till
+   the end of the object and object_sizes[3] lower bound for subobject.  */
+static vec<object_size> object_sizes[OST_END];
 
 /* Bitmaps what object sizes have been computed already.  */
 static bitmap computed[OST_END];
@@ -82,10 +89,46 @@ static bitmap computed[OST_END];
 /* Maximum value of offset we consider to be addition.  */
 static unsigned HOST_WIDE_INT offset_limit;
 
+/* Initial value of object sizes; zero for maximum and SIZE_MAX for minimum
+   object size.  */
+
+static inline unsigned HOST_WIDE_INT
+initval (int object_size_type)
+{
+  return (object_size_type & OST_MINIMUM) ? HOST_WIDE_INT_M1U : 0;
+}
+
+/* Unknown object size value; it's the opposite of initval.  */
+
 static inline unsigned HOST_WIDE_INT
 unknown (int object_size_type)
 {
-  return ((unsigned HOST_WIDE_INT) -((object_size_type >> 1) ^ 1));
+  return ~initval (object_size_type);
+}
+
+/* Return true if VAL is represents an unknown size for OBJECT_SIZE_TYPE.  */
+
+static inline bool
+size_unknown_p (tree val, int object_size_type)
+{
+  return (tree_fits_uhwi_p (val)
+	  && tree_to_uhwi (val) == unknown (object_size_type));
+}
+
+/* Return a tree with initial value for OBJECT_SIZE_TYPE.  */
+
+static inline tree
+size_initval (int object_size_type)
+{
+  return size_int (initval (object_size_type));
+}
+
+/* Return a tree with unknown value for OBJECT_SIZE_TYPE.  */
+
+static inline tree
+size_unknown (int object_size_type)
+{
+  return size_int (unknown (object_size_type));
 }
 
 /* Grow object_sizes[OBJECT_SIZE_TYPE] to num_ssa_names.  */
@@ -110,47 +153,57 @@ object_sizes_release (int object_size_type)
 static inline bool
 object_sizes_unknown_p (int object_size_type, unsigned varno)
 {
-  return (object_sizes[object_size_type][varno]
-	  == unknown (object_size_type));
+  return size_unknown_p (object_sizes[object_size_type][varno].size,
+			 object_size_type);
 }
 
-/* Return size for VARNO corresponding to OSI.  */
+/* Return size for VARNO corresponding to OSI.  If WHOLE is true, return the
+   whole object size.  */
 
-static inline unsigned HOST_WIDE_INT
-object_sizes_get (struct object_size_info *osi, unsigned varno)
+static inline tree
+object_sizes_get (struct object_size_info *osi, unsigned varno,
+		  bool whole = false)
 {
-  return object_sizes[osi->object_size_type][varno];
+  if (whole)
+    return object_sizes[osi->object_size_type][varno].wholesize;
+  else
+    return object_sizes[osi->object_size_type][varno].size;
 }
 
 /* Set size for VARNO corresponding to OSI to VAL.  */
 
-static inline bool
-object_sizes_set_force (struct object_size_info *osi, unsigned varno,
-			unsigned HOST_WIDE_INT val)
+static inline void
+object_sizes_initialize (struct object_size_info *osi, unsigned varno,
+			 tree val, tree wholeval)
 {
-  object_sizes[osi->object_size_type][varno] = val;
-  return true;
+  int object_size_type = osi->object_size_type;
+
+  object_sizes[object_size_type][varno].size = val;
+  object_sizes[object_size_type][varno].wholesize = wholeval;
 }
 
 /* Set size for VARNO corresponding to OSI to VAL if it is the new minimum or
    maximum.  */
 
 static inline bool
-object_sizes_set (struct object_size_info *osi, unsigned varno,
-		  unsigned HOST_WIDE_INT val)
+object_sizes_set (struct object_size_info *osi, unsigned varno, tree val,
+		  tree wholeval)
 {
   int object_size_type = osi->object_size_type;
-  if ((object_size_type & OST_MINIMUM) == 0)
-    {
-      if (object_sizes[object_size_type][varno] < val)
-	return object_sizes_set_force (osi, varno, val);
-    }
-  else
-    {
-      if (object_sizes[object_size_type][varno] > val)
-	return object_sizes_set_force (osi, varno, val);
-    }
-  return false;
+  object_size osize = object_sizes[object_size_type][varno];
+
+  tree oldval = osize.size;
+  tree old_wholeval = osize.wholesize;
+
+  enum tree_code code = object_size_type & OST_MINIMUM ? MIN_EXPR : MAX_EXPR;
+
+  val = size_binop (code, val, oldval);
+  wholeval = size_binop (code, wholeval, old_wholeval);
+
+  object_sizes[object_size_type][varno].size = val;
+  object_sizes[object_size_type][varno].wholesize = wholeval;
+  return (tree_int_cst_compare (oldval, val) != 0
+	  || tree_int_cst_compare (old_wholeval, wholeval) != 0);
 }
 
 /* Initialize OFFSET_LIMIT variable.  */
@@ -164,6 +217,48 @@ init_offset_limit (void)
   offset_limit /= 2;
 }
 
+/* Bytes at end of the object with SZ from offset OFFSET.  If WHOLESIZE is not
+   NULL_TREE, use it to get the net offset of the pointer, which should always
+   be positive and hence, be within OFFSET_LIMIT for valid offsets.  */
+
+static tree
+size_for_offset (tree sz, tree offset, tree wholesize = NULL_TREE)
+{
+  gcc_checking_assert (TREE_CODE (offset) == INTEGER_CST);
+  gcc_checking_assert (TREE_CODE (sz) == INTEGER_CST);
+  gcc_checking_assert (types_compatible_p (TREE_TYPE (sz), sizetype));
+
+  /* For negative offsets, if we have a distinct WHOLESIZE, use it to get a net
+     offset from the whole object.  */
+  if (wholesize && tree_int_cst_compare (sz, wholesize))
+    {
+      gcc_checking_assert (TREE_CODE (wholesize) == INTEGER_CST);
+      gcc_checking_assert (types_compatible_p (TREE_TYPE (wholesize),
+					       sizetype));
+
+      /* Restructure SZ - OFFSET as
+	 WHOLESIZE - (WHOLESIZE + OFFSET - SZ) so that the offset part, i.e.
+	 WHOLESIZE + OFFSET - SZ is only allowed to be positive.  */
+      tree tmp = size_binop (MAX_EXPR, wholesize, sz);
+      offset = fold_build2 (PLUS_EXPR, sizetype, tmp, offset);
+      offset = fold_build2 (MINUS_EXPR, sizetype, offset, sz);
+      sz = tmp;
+    }
+
+  /* Safe to convert now, since a valid net offset should be non-negative.  */
+  if (!types_compatible_p (TREE_TYPE (offset), sizetype))
+    fold_convert (sizetype, offset);
+
+  if (integer_zerop (offset))
+    return sz;
+
+  /* Negative or too large offset even after adjustment, cannot be within
+     bounds of an object.  */
+  if (compare_tree_int (offset, offset_limit) > 0)
+    return size_zero_node;
+
+  return size_binop (MINUS_EXPR, size_binop (MAX_EXPR, sz, offset), offset);
+}
 
 /* Compute offset of EXPR within VAR.  Return error_mark_node
    if unknown.  */
@@ -274,19 +369,22 @@ decl_init_size (tree decl, bool min)
 
 /* Compute __builtin_object_size for PTR, which is a ADDR_EXPR.
    OBJECT_SIZE_TYPE is the second argument from __builtin_object_size.
-   If unknown, return unknown (object_size_type).  */
+   If unknown, return size_unknown (object_size_type).  */
 
 static bool
 addr_object_size (struct object_size_info *osi, const_tree ptr,
-		  int object_size_type, unsigned HOST_WIDE_INT *psize)
+		  int object_size_type, tree *psize, tree *pwholesize)
 {
-  tree pt_var, pt_var_size = NULL_TREE, var_size, bytes;
+  tree pt_var, pt_var_size = NULL_TREE, pt_var_wholesize = NULL_TREE;
+  tree var_size, bytes, wholebytes;
 
   gcc_assert (TREE_CODE (ptr) == ADDR_EXPR);
 
   /* Set to unknown and overwrite just before returning if the size
      could be determined.  */
-  *psize = unknown (object_size_type);
+  *psize = size_unknown (object_size_type);
+  if (pwholesize)
+    *pwholesize = size_unknown (object_size_type);
 
   pt_var = TREE_OPERAND (ptr, 0);
   while (handled_component_p (pt_var))
@@ -297,13 +395,14 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
 
   if (TREE_CODE (pt_var) == MEM_REF)
     {
-      unsigned HOST_WIDE_INT sz;
+      tree sz, wholesize;
 
       if (!osi || (object_size_type & OST_SUBOBJECT) != 0
 	  || TREE_CODE (TREE_OPERAND (pt_var, 0)) != SSA_NAME)
 	{
 	  compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
 				       object_size_type & ~OST_SUBOBJECT, &sz);
+	  wholesize = sz;
 	}
       else
 	{
@@ -312,46 +411,47 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
 	    collect_object_sizes_for (osi, var);
 	  if (bitmap_bit_p (computed[object_size_type],
 			    SSA_NAME_VERSION (var)))
-	    sz = object_sizes_get (osi, SSA_NAME_VERSION (var));
+	    {
+	      sz = object_sizes_get (osi, SSA_NAME_VERSION (var));
+	      wholesize = object_sizes_get (osi, SSA_NAME_VERSION (var), true);
+	    }
 	  else
-	    sz = unknown (object_size_type);
+	    sz = wholesize = size_unknown (object_size_type);
 	}
-      if (sz != unknown (object_size_type))
+      if (!size_unknown_p (sz, object_size_type))
 	{
-	  offset_int mem_offset;
-	  if (mem_ref_offset (pt_var).is_constant (&mem_offset))
-	    {
-	      offset_int dsz = wi::sub (sz, mem_offset);
-	      if (wi::neg_p (dsz))
-		sz = 0;
-	      else if (wi::fits_uhwi_p (dsz))
-		sz = dsz.to_uhwi ();
-	      else
-		sz = unknown (object_size_type);
-	    }
+	  tree offset = TREE_OPERAND (pt_var, 1);
+	  if (TREE_CODE (offset) != INTEGER_CST
+	      || TREE_CODE (sz) != INTEGER_CST)
+	    sz = wholesize = size_unknown (object_size_type);
 	  else
-	    sz = unknown (object_size_type);
+	    sz = size_for_offset (sz, offset, wholesize);
 	}
 
-      if (sz != unknown (object_size_type) && sz < offset_limit)
-	pt_var_size = size_int (sz);
+      if (!size_unknown_p (sz, object_size_type)
+	  && TREE_CODE (sz) == INTEGER_CST
+	  && compare_tree_int (sz, offset_limit) < 0)
+	{
+	  pt_var_size = sz;
+	  pt_var_wholesize = wholesize;
+	}
     }
   else if (DECL_P (pt_var))
     {
-      pt_var_size = decl_init_size (pt_var, object_size_type & OST_MINIMUM);
+      pt_var_size = pt_var_wholesize
+	= decl_init_size (pt_var, object_size_type & OST_MINIMUM);
       if (!pt_var_size)
 	return false;
     }
   else if (TREE_CODE (pt_var) == STRING_CST)
-    pt_var_size = TYPE_SIZE_UNIT (TREE_TYPE (pt_var));
+    pt_var_size = pt_var_wholesize = TYPE_SIZE_UNIT (TREE_TYPE (pt_var));
   else
     return false;
 
   if (pt_var_size)
     {
       /* Validate the size determined above.  */
-      if (!tree_fits_uhwi_p (pt_var_size)
-	  || tree_to_uhwi (pt_var_size) >= offset_limit)
+      if (compare_tree_int (pt_var_size, offset_limit) >= 0)
 	return false;
     }
 
@@ -496,28 +596,35 @@ addr_object_size (struct object_size_info *osi, const_tree ptr,
 	      bytes = size_binop (MIN_EXPR, bytes, bytes2);
 	    }
 	}
+
+      wholebytes
+	= object_size_type & OST_SUBOBJECT ? var_size : pt_var_wholesize;
     }
   else if (!pt_var_size)
     return false;
   else
-    bytes = pt_var_size;
-
-  if (tree_fits_uhwi_p (bytes))
     {
-      *psize = tree_to_uhwi (bytes);
-      return true;
+      bytes = pt_var_size;
+      wholebytes = pt_var_wholesize;
     }
 
-  return false;
+  if (TREE_CODE (bytes) != INTEGER_CST
+      || TREE_CODE (wholebytes) != INTEGER_CST)
+    return false;
+
+  *psize = bytes;
+  if (pwholesize)
+    *pwholesize = wholebytes;
+  return true;
 }
 
 
 /* Compute __builtin_object_size for CALL, which is a GIMPLE_CALL.
    Handles calls to functions declared with attribute alloc_size.
    OBJECT_SIZE_TYPE is the second argument from __builtin_object_size.
-   If unknown, return unknown (object_size_type).  */
+   If unknown, return size_unknown (object_size_type).  */
 
-static unsigned HOST_WIDE_INT
+static tree
 alloc_object_size (const gcall *call, int object_size_type)
 {
   gcc_assert (is_gimple_call (call));
@@ -529,7 +636,7 @@ alloc_object_size (const gcall *call, int object_size_type)
     calltype = gimple_call_fntype (call);
 
   if (!calltype)
-    return unknown (object_size_type);
+    return size_unknown (object_size_type);
 
   /* Set to positions of alloc_size arguments.  */
   int arg1 = -1, arg2 = -1;
@@ -549,7 +656,7 @@ alloc_object_size (const gcall *call, int object_size_type)
       || (arg2 >= 0
 	  && (arg2 >= (int)gimple_call_num_args (call)
 	      || TREE_CODE (gimple_call_arg (call, arg2)) != INTEGER_CST)))
-    return unknown (object_size_type);
+    return size_unknown (object_size_type);
 
   tree bytes = NULL_TREE;
   if (arg2 >= 0)
@@ -559,10 +666,7 @@ alloc_object_size (const gcall *call, int object_size_type)
   else if (arg1 >= 0)
     bytes = fold_convert (sizetype, gimple_call_arg (call, arg1));
 
-  if (bytes && tree_fits_uhwi_p (bytes))
-    return tree_to_uhwi (bytes);
-
-  return unknown (object_size_type);
+  return bytes;
 }
 
 
@@ -598,13 +702,13 @@ pass_through_call (const gcall *call)
 
 bool
 compute_builtin_object_size (tree ptr, int object_size_type,
-			     unsigned HOST_WIDE_INT *psize)
+			     tree *psize)
 {
   gcc_assert (object_size_type >= 0 && object_size_type < OST_END);
 
   /* Set to unknown and overwrite just before returning if the size
      could be determined.  */
-  *psize = unknown (object_size_type);
+  *psize = size_unknown (object_size_type);
 
   if (! offset_limit)
     init_offset_limit ();
@@ -638,8 +742,7 @@ compute_builtin_object_size (tree ptr, int object_size_type,
 						  psize))
 		{
 		  /* Return zero when the offset is out of bounds.  */
-		  unsigned HOST_WIDE_INT off = tree_to_shwi (offset);
-		  *psize = off < *psize ? *psize - off : 0;
+		  *psize = size_for_offset (*psize, offset);
 		  return true;
 		}
 	    }
@@ -747,12 +850,13 @@ compute_builtin_object_size (tree ptr, int object_size_type,
 		print_generic_expr (dump_file, ssa_name (i),
 				    dump_flags);
 		fprintf (dump_file,
-			 ": %s %sobject size "
-			 HOST_WIDE_INT_PRINT_UNSIGNED "\n",
+			 ": %s %sobject size ",
 			 ((object_size_type & OST_MINIMUM) ? "minimum"
 			  : "maximum"),
-			 (object_size_type & OST_SUBOBJECT) ? "sub" : "",
-			 object_sizes_get (&osi, i));
+			 (object_size_type & OST_SUBOBJECT) ? "sub" : "");
+		print_generic_expr (dump_file, object_sizes_get (&osi, i),
+				    dump_flags);
+		fprintf (dump_file, "\n");
 	      }
 	}
 
@@ -761,7 +865,7 @@ compute_builtin_object_size (tree ptr, int object_size_type,
     }
 
   *psize = object_sizes_get (&osi, SSA_NAME_VERSION (ptr));
-  return *psize != unknown (object_size_type);
+  return !size_unknown_p (*psize, object_size_type);
 }
 
 /* Compute object_sizes for PTR, defined to VALUE, which is not an SSA_NAME.  */
@@ -771,7 +875,7 @@ expr_object_size (struct object_size_info *osi, tree ptr, tree value)
 {
   int object_size_type = osi->object_size_type;
   unsigned int varno = SSA_NAME_VERSION (ptr);
-  unsigned HOST_WIDE_INT bytes;
+  tree bytes, wholesize;
 
   gcc_assert (!object_sizes_unknown_p (object_size_type, varno));
   gcc_assert (osi->pass == 0);
@@ -784,11 +888,11 @@ expr_object_size (struct object_size_info *osi, tree ptr, tree value)
 	      || !POINTER_TYPE_P (TREE_TYPE (value)));
 
   if (TREE_CODE (value) == ADDR_EXPR)
-    addr_object_size (osi, value, object_size_type, &bytes);
+    addr_object_size (osi, value, object_size_type, &bytes, &wholesize);
   else
-    bytes = unknown (object_size_type);
+    bytes = wholesize = size_unknown (object_size_type);
 
-  object_sizes_set (osi, varno, bytes);
+  object_sizes_set (osi, varno, bytes, wholesize);
 }
 
 
@@ -799,16 +903,14 @@ call_object_size (struct object_size_info *osi, tree ptr, gcall *call)
 {
   int object_size_type = osi->object_size_type;
   unsigned int varno = SSA_NAME_VERSION (ptr);
-  unsigned HOST_WIDE_INT bytes;
 
   gcc_assert (is_gimple_call (call));
 
   gcc_assert (!object_sizes_unknown_p (object_size_type, varno));
   gcc_assert (osi->pass == 0);
+  tree bytes = alloc_object_size (call, object_size_type);
 
-  bytes = alloc_object_size (call, object_size_type);
-
-  object_sizes_set (osi, varno, bytes);
+  object_sizes_set (osi, varno, bytes, bytes);
 }
 
 
@@ -822,8 +924,9 @@ unknown_object_size (struct object_size_info *osi, tree ptr)
 
   gcc_checking_assert (!object_sizes_unknown_p (object_size_type, varno));
   gcc_checking_assert (osi->pass == 0);
+  tree bytes = size_unknown (object_size_type);
 
-  object_sizes_set (osi, varno, unknown (object_size_type));
+  object_sizes_set (osi, varno, bytes, bytes);
 }
 
 
@@ -831,30 +934,22 @@ unknown_object_size (struct object_size_info *osi, tree ptr)
    the object size might need reexamination later.  */
 
 static bool
-merge_object_sizes (struct object_size_info *osi, tree dest, tree orig,
-		    unsigned HOST_WIDE_INT offset)
+merge_object_sizes (struct object_size_info *osi, tree dest, tree orig)
 {
   int object_size_type = osi->object_size_type;
   unsigned int varno = SSA_NAME_VERSION (dest);
-  unsigned HOST_WIDE_INT orig_bytes;
+  tree orig_bytes, wholesize;
 
   if (object_sizes_unknown_p (object_size_type, varno))
     return false;
-  if (offset >= offset_limit)
-    {
-      object_sizes_set (osi, varno, unknown (object_size_type));
-      return false;
-    }
 
   if (osi->pass == 0)
     collect_object_sizes_for (osi, orig);
 
   orig_bytes = object_sizes_get (osi, SSA_NAME_VERSION (orig));
-  if (orig_bytes != unknown (object_size_type))
-    orig_bytes = (offset > orig_bytes)
-		 ? HOST_WIDE_INT_0U : orig_bytes - offset;
+  wholesize = object_sizes_get (osi, SSA_NAME_VERSION (orig), true);
 
-  if (object_sizes_set (osi, varno, orig_bytes))
+  if (object_sizes_set (osi, varno, orig_bytes, wholesize))
     osi->changed = true;
 
   return bitmap_bit_p (osi->reexamine, SSA_NAME_VERSION (orig));
@@ -870,8 +965,9 @@ plus_stmt_object_size (struct object_size_info *osi, tree var, gimple *stmt)
 {
   int object_size_type = osi->object_size_type;
   unsigned int varno = SSA_NAME_VERSION (var);
-  unsigned HOST_WIDE_INT bytes;
+  tree bytes, wholesize;
   tree op0, op1;
+  bool reexamine = false;
 
   if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
     {
@@ -896,31 +992,38 @@ plus_stmt_object_size (struct object_size_info *osi, tree var, gimple *stmt)
       && (TREE_CODE (op0) == SSA_NAME
 	  || TREE_CODE (op0) == ADDR_EXPR))
     {
-      if (! tree_fits_uhwi_p (op1))
-	bytes = unknown (object_size_type);
-      else if (TREE_CODE (op0) == SSA_NAME)
-	return merge_object_sizes (osi, var, op0, tree_to_uhwi (op1));
+      if (TREE_CODE (op0) == SSA_NAME)
+	{
+	  if (osi->pass == 0)
+	    collect_object_sizes_for (osi, op0);
+
+	  bytes = object_sizes_get (osi, SSA_NAME_VERSION (op0));
+	  wholesize = object_sizes_get (osi, SSA_NAME_VERSION (op0), true);
+	  reexamine = bitmap_bit_p (osi->reexamine, SSA_NAME_VERSION (op0));
+	}
       else
 	{
-	  unsigned HOST_WIDE_INT off = tree_to_uhwi (op1);
-
-          /* op0 will be ADDR_EXPR here.  */
-	  addr_object_size (osi, op0, object_size_type, &bytes);
-	  if (bytes == unknown (object_size_type))
-	    ;
-	  else if (off > offset_limit)
-	    bytes = unknown (object_size_type);
-	  else if (off > bytes)
-	    bytes = 0;
-	  else
-	    bytes -= off;
+	  /* op0 will be ADDR_EXPR here.  We should never come here during
+	     reexamination.  */
+	  gcc_checking_assert (osi->pass == 0);
+	  addr_object_size (osi, op0, object_size_type, &bytes, &wholesize);
 	}
+
+      /* In the first pass, do not compute size for offset if either the
+	 maximum size is unknown or the minimum size is not initialized yet;
+	 the latter indicates a dependency loop and will be resolved in
+	 subsequent passes.  We attempt to compute offset for 0 minimum size
+	 too because a negative offset could be within bounds of WHOLESIZE,
+	 giving a non-zero result for VAR.  */
+      if (osi->pass != 0 || !size_unknown_p (bytes, 0))
+	bytes = size_for_offset (bytes, op1, wholesize);
     }
   else
-    bytes = unknown (object_size_type);
</cut>
>From amodra@gmail.com  Sun Dec 19 05:14:31 2021
Return-Path: <amodra@gmail.com>
X-Original-To: gcc-regression@gcc.gnu.org
Delivered-To: gcc-regression@gcc.gnu.org
Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com
 [IPv6:2607:f8b0:4864:20::102d])
 by sourceware.org (Postfix) with ESMTPS id 6A0D23858401
 for <gcc-regression@gcc.gnu.org>; Sun, 19 Dec 2021 05:14:30 +0000 (GMT)
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A0D23858401
Received: by mail-pj1-x102d.google.com with SMTP id
 n15-20020a17090a160f00b001a75089daa3so9628512pja.1
 for <gcc-regression@gcc.gnu.org>; Sat, 18 Dec 2021 21:14:30 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:references
 :mime-version:content-disposition:in-reply-to;
 bh=3ZqgzRJNADevf6Jro3doCyK00eolYT7udfc6GfcKDDk=;
 b=vDKihdkzrwpLJyqPxsqYd0ycdx45eNQgaRsjI4otRLZYXBHs/xKliQDgdrlBa5Qdx9
 XNCIxwFHhwCT2VpmFwR6MdgwGQw/oHVeMmWdmbmqYBJl6gu7J+Byj8yv6DUzAlhIxp5N
 +Su19XTnqWrU5Z13nrX6BfL5chDKU5L7aL4XghukRsPPPtKzqD2rvKjzhUem8/cby/mU
 N895zveGroIqZn2RkWf5L+TEqoSzClwXw6RF3onFKfiXIyYo2x1iGGJCysRnFa/s2usF
 +fJpdTu6rAvxt3zUQobDdIMouXsHsm22qqOhkTzTNXN8ul8vbjQC2BRrAasV5RYHc+rN
 59fg==
X-Gm-Message-State: AOAM532hrq1xvXclDuGSLWqGfKQvO0Zyod5AMCTzalTBKcYO6SI0Reir
 HG85D7KcQRPTUiWWI8fwmVXWAEL6xbE=
X-Google-Smtp-Source: ABdhPJx7MKnJz5CNu5abXPa3pfxGSfsNExmebaxvp1I9FzZS3V8WjW0dG76tTn69lg8rioU1jDEePw==
X-Received: by 2002:a17:90a:950d:: with SMTP id
 t13mr12775260pjo.116.1639890869165; 
 Sat, 18 Dec 2021 21:14:29 -0800 (PST)
Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au.
 [58.96.106.158])
 by smtp.gmail.com with ESMTPSA id o62sm13989260pfb.211.2021.12.18.21.14.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 18 Dec 2021 21:14:28 -0800 (PST)
Received: by squeak.grove.modra.org (Postfix, from userid 1000)
 id 37ADF1140241; Sun, 19 Dec 2021 15:44:25 +1030 (ACDT)
Date: Sun, 19 Dec 2021 15:44:25 +1030
From: Alan Modra <amodra@gmail.com>
To: ci_notify@linaro.org
Cc: gcc-regression@gcc.gnu.org
Subject: Re: [TCWG CI] Regression caused by binutils: XCOFF C_STSYM test
 failure on 32-bit host
Message-ID: <Yb6/sV1dkhNSRWdH@squeak.grove.modra.org>
References: <775344759.5837.1639847853824@jenkins.jenkins>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <775344759.5837.1639847853824@jenkins.jenkins>
X-Spam-Status: No, score=-3032.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,
 SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 server2.sourceware.org
X-BeenThere: gcc-regression@gcc.gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Gcc-regression mailing list <gcc-regression.gcc.gnu.org>
List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=unsubscribe>
List-Archive: <https://gcc.gnu.org/pipermail/gcc-regression/>
List-Post: <mailto:gcc-regression@gcc.gnu.org>
List-Help: <mailto:gcc-regression-request@gcc.gnu.org?subject=help>
List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-regression>,
 <mailto:gcc-regression-request@gcc.gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 19 Dec 2021 05:14:31 -0000

On Sat, Dec 18, 2021 at 05:17:32PM +0000, ci_notify@linaro.org wrote:
> [TCWG CI] Regression caused by binutils: XCOFF C_STSYM test failure on 32-bit host:
> commit eda0ddeb26a117660f3c0f54572053117641c2c3

Don't be silly.  Your regression tester is broken.

-- 
Alan Modra
Australia Development Lab, IBM


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-19  1:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-19  1:04 [TCWG CI] Regression caused by gcc: Drop the fpic multilib for powerpc*-vxworks* ci_notify

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).