On 11/19/21 22:36, Jakub Jelinek wrote:
On Wed, Nov 10, 2021 at 12:31:29AM +0530, Siddhesh Poyarekar wrote:
* 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
On 11/20/21 00:31, Siddhesh Poyarekar wrote:
This doesn't match what the code did and I'm surprised if it works at
all.
TREE_OPERAND (pt_var, 1), while it is an INTEGER_CST or POLY_INT_CST,
has in its type encoded the type for aliasing, so the type is some
pointer
type. Performing
On 11/22/21 16:01, Jakub Jelinek wrote:
On Mon, Nov 22, 2021 at 03:41:57PM +0530, Siddhesh Poyarekar wrote:
So I played around a bit with this. Basically:
char buf[8];
__SIZE_TYPE__ test (void)
{
char *p = &buf[0x9004];
return __builtin_object_size (p + 2, 0);
}
when built
On 11/22/21 17:30, Siddhesh Poyarekar wrote:
So I've got patch 10/10, which handles dynamic (and consequently
negative) offsets. It basically computes a "whole size", which then
gives the extent to which a negative offset is valid, making the
estimates a bit more precise. I d
On 11/23/21 17:28, Jakub Jelinek wrote:
On Mon, Nov 22, 2021 at 01:32:22PM +0100, Jakub Jelinek via Gcc-patches wrote:
On Mon, Nov 22, 2021 at 06:01:08PM +0530, Siddhesh Poyarekar wrote:
On 11/22/21 17:30, Siddhesh Poyarekar wrote:
So I've got patch 10/10, which handles dynamic
On 11/23/21 17:37, Jakub Jelinek wrote:
On Wed, Nov 10, 2021 at 12:31:30AM +0530, Siddhesh Poyarekar wrote:
Use SSA names as placeholders self-referencing variables to generate
expressions for object sizes and then reduce those size expressions
to constants instead of repeatedly walking through
On 11/23/21 18:11, Jakub Jelinek wrote:
On Wed, Nov 10, 2021 at 12:31:31AM +0530, Siddhesh Poyarekar wrote:
Recognize the __builtin_dynamic_object_size builtin and add paths in the
object size path to deal with it, but treat it like
__builtin_object_size for now. Also add tests to provide the
On 11/23/21 20:42, Jakub Jelinek wrote:
On Wed, Nov 10, 2021 at 12:31:32AM +0530, Siddhesh Poyarekar wrote:
(object_sizes_execute): Don't insert min/max for dynamic sizes.
I'm worried about this.
I'd say what we might want to do is in the early pass for __bdos
compute
On 11/23/21 21:06, Siddhesh Poyarekar wrote:
On 11/23/21 20:42, Jakub Jelinek wrote:
On Wed, Nov 10, 2021 at 12:31:32AM +0530, Siddhesh Poyarekar wrote:
(object_sizes_execute): Don't insert min/max for dynamic sizes.
I'm worried about this.
I'd say what we might want
On 11/23/21 21:22, Jakub Jelinek wrote:
Evaluating __bdos in both passes is undesirable, certainly for the same
SSA_NAME, but even for different SSA_NAMEs, if everything is done in a
single pass it can easily share temporaries (object sizes for SSA_NAMEs it
uses), while if some __bdos is evaluate
fset support (10/10 in v2) into 3/8 and support
static object sizes
- Merge dynamic offset (10/10 in v2) support into 8/8
Siddhesh Poyarekar (8):
tree-object-size: Replace magic numbers with enums
tree-object-size: Abstract object_sizes array
tree-object-size: Save sizes as t
,
collect_object_sizes_for, init_object_sizes, fini_object_sizes,
object_sizes_execute): Replace magic numbers with enums.
Signed-off-by: Siddhesh Poyarekar
---
Changes from v2:
- Incorporated review suggestions.
gcc/tree-object-size.c | 59
,
fini_object_sizes): Adjust.
Signed-off-by: Siddhesh Poyarekar
---
Changes from v2:
- Incorporated review suggestions.
gcc/tree-object-size.c | 177 +++--
1 file changed, 98 insertions(+), 79 deletions(-)
diff --git a/gcc/tree-object-size.c b/gcc/tree-object
.
* 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
---
Changes from v2:
- Incorporated review suggestions.
- Added support for negative offsets.
gcc
-dynamic-object-size-9.c: Likewise.
* gcc.dg/builtin-object-size-16.c: Adjust to allow inclusion
from builtin-dynamic-object-size-16.c.
* gcc.dg/builtin-object-size-17.c: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
Changes from v2:
- Incorporated review suggestions.
gcc
/builtin-dynamic-object-size-0.c (test_parmsz_simple):
New function.
(main): Call it.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 11
gcc/tree-object-size.c| 50 ++-
2 files changed, 60 insertions
.
* gcc.dg/builtin-object-size-3.c [__builtin_object_size]:
Likewise.
* gcc.dg/builtin-object-size-4.c [__builtin_object_size]:
Likewise.
* gcc.dg/builtin-object-size-5.c [__builtin_object_size]:
Likewise.
Signed-off-by: Siddhesh Poyarekar
---
Changes from
)
[__builtin_object_size]: Likewise.
* gcc.dg/builtin-object-size-3.c (test1)
[__builtin_object_size]: Likewise.
* gcc.dg/builtin-object-size-4.c (test1)
[__builtin_object_size]: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object
)
[__builtin_object_size]: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 158 ++
gcc/testsuite/gcc.dg/builtin-object-size-1.c | 30 +++-
gcc/testsuite/gcc.dg/builtin-object-size-2.c | 43 -
gcc/testsuite/gcc.dg/builtin-object
On 11/26/21 10:58, Siddhesh Poyarekar wrote:
sure it works) and saw no issues in any of those builds. I did some
rudimentary analysis of the generated binaries using fortify-metrics[1]
to confirm that there was a difference in coverage between the two
fortification levels.
Here is a summary of
On 11/26/21 22:16, Jakub Jelinek wrote:
On Fri, Nov 26, 2021 at 10:58:44AM +0530, Siddhesh Poyarekar wrote:
A simple cleanup to allow inserting dynamic size code more easily.
gcc/ChangeLog:
* tree-object-size.c: New enum.
(object_sizes, computed, addr_object_size
On 11/26/21 22:26, Jakub Jelinek wrote:
On Fri, Nov 26, 2021 at 10:58:46AM +0530, Siddhesh Poyarekar wrote:
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
On 11/26/21 23:34, Jakub Jelinek wrote:
On Fri, Nov 26, 2021 at 11:29:41PM +0530, Siddhesh Poyarekar wrote:
The trees in object_sizes are each a TREE_VEC with the first element
being the bytes from the pointer to the end of the object and the
second, the size of the whole object. This allows
authored-by: Martin Liška
Signed-off-by: Siddhesh Poyarekar
---
gcc/testsuite/gcc.dg/pr103456.c | 21 +
gcc/tree-object-size.c | 3 ++-
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr103456.c
diff --git a/gcc/testsuite/gcc.dg
456
* tree-object-size.c (merge_object_sizes): Update osi->changed
only if object_sizes_set succeeded.
gcc/testsuite/ChangeLog:
PR tree-optimization/103456
* gcc.dg/ubsan/pr103456.c: New test.
Co-authored-by: Martin Liška
Signed-off-by: Siddhesh Poyarekar
---
gcc/tes
/builtin-dynamic-object-size-0.c (test_parmsz_simple):
New function.
(main): Call it.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 11
gcc/tree-object-size.c| 50 ++-
2 files changed, 60 insertions
ges to individual patches have been mentioned in the patches
themselves.
- Dropped patch to remove check_for_plus_in_for_loops and osi->pass
- Merge negative offset support (10/10 in v2) into 3/8 and support
static object sizes
- Merge dynamic offset (10/10 in v2) support into 8/8
Siddhesh Poyare
-dynamic-object-size-9.c: Likewise.
* gcc.dg/builtin-object-size-16.c: Adjust to allow inclusion
from builtin-dynamic-object-size-16.c.
* gcc.dg/builtin-object-size-17.c: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
gcc/builtins.c| 11 +-
gcc
/builtin-object-size-4.c [__builtin_object_size]:
Likewise.
* gcc.dg/builtin-object-size-5.c [__builtin_object_size]:
Likewise.
Signed-off-by: Siddhesh Poyarekar
---
gcc/builtins.c| 6 +-
.../gcc.dg/builtin-dynamic-object-size-0.c| 72
)
[__builtin_object_size]: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 158 ++
gcc/testsuite/gcc.dg/builtin-object-size-1.c | 30 +++-
gcc/testsuite/gcc.dg/builtin-object-size-2.c | 43 -
gcc/testsuite/gcc.dg/builtin-object
)
[__builtin_object_size]: Likewise.
* gcc.dg/builtin-object-size-3.c (test1)
[__builtin_object_size]: Likewise.
* gcc.dg/builtin-object-size-4.c (test1)
[__builtin_object_size]: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object
): 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
---
gcc/builtins.c | 10 +-
gcc
On 2022-09-23 09:02, Jakub Jelinek wrote:
Oh, so can addr_object_size be simplified to use get_base_address too?
You can try. As you can see in get_base_address, that function
handles something that the above doesn't (looking through some MEM_REFs too).
I went down this rabbithole and it ac
Use string length of input to strdup to determine the usable size of the
resulting object. Avoid doing the same for strndup since there's a
chance that the input may be too large, resulting in an unnecessary
overhead or worse, the input may not be NULL terminated, resulting in a
crash where there
Ping!
On 2022-08-15 15:23, Siddhesh Poyarekar wrote:
Use string length of input to strdup to determine the usable size of the
resulting object. Avoid doing the same for strndup since there's a
chance that the input may be too large, resulting in an unnecessary
overhead or worse, the inpu
Ping!
On 2022-08-29 10:16, Siddhesh Poyarekar wrote:
Ping!
On 2022-08-15 15:23, Siddhesh Poyarekar wrote:
Use string length of input to strdup to determine the usable size of the
resulting object. Avoid doing the same for strndup since there's a
chance that the input may be too
On 07/02/2022 17:37, Jakub Jelinek wrote:
On Mon, Feb 07, 2022 at 05:31:58PM +0530, Siddhesh Poyarekar wrote:
Use __builtin_dynamic_object_size to get object sizes for ubsan.
gcc/ChangeLog:
middle-end/70090
* ubsan.cc (ubsan_expand_objsize_ifn): Allow non-constant SIZE
On 10/05/2022 16:16, Martin Liška wrote:
The revision caused:
$ ./xgcc -B.
/home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/ubsan/bind-c-intent-out-2.f90
-fsanitize=undefined -c -O
during GIMPLE pass: ubsan
/home/marxin/Programming/gcc/gcc/testsuite/gfortran.dg/ubsan/bind-c-intent-out-2.
ubsan/bind-c-intent-out-2.f90 does not crash anymore.
gcc/ChangeLog:
PR middle-end/70090
* asan.cc (initialize_sanitizer_builtins): Register
__builtin_dynamic_object_size if necessary.
Signed-off-by: Siddhesh Poyarekar
---
Testing:
- I realized that for some reason I was lo
where the pass keeps
track of nesting in the expression and either bail out or compute an
estimate if nesting crosses a threshold. I'll take this up once we
have more data on the nature of the bottlenecks.
Siddhesh Poyarekar (10):
tree-object-size: Replace magic numbers with enums
t
numbers
with enums.
Signed-off-by: Siddhesh Poyarekar
---
gcc/tree-object-size.c | 47 +-
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 4334e05ef70..f70f95a7b29 100644
--- a/gcc
,
fini_object_sizes): Adjust.
Signed-off-by: Siddhesh Poyarekar
---
gcc/tree-object-size.c | 176 +++--
1 file changed, 97 insertions(+), 79 deletions(-)
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index f70f95a7b29..7a22539cc43 100644
--- a/gcc
: Siddhesh Poyarekar
---
gcc/builtins.c | 10 +-
gcc/gimple-fold.c | 9 +-
gcc/tree-object-size.c | 253 ++---
gcc/tree-object-size.h | 2 +-
gcc/ubsan.c| 46
5 files changed, 168 insertions(+), 152 deletions(-)
diff --git a
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-object-size-1.c (test6): New test for
passthrough.
* gcc.dg/builtin-object-size-2.c: Likewise.
* gcc.dg/builtin-object-size-3.c: Likewise.
* gcc.dg/builtin-object-size-4.c: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
/builtin-dynamic-object-size-0.c (test_parmsz_simple):
New function.
(main): Call it.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 10
gcc/tree-object-size.c| 55 ++-
2 files changed, 64 insertions
-dynamic-object-size-8.c: Likewise.
* gcc.dg/builtin-dynamic-object-size-9.c: Likewise.
* gcc.dg/builtin-object-size-16.c: Adjust to allow inclusion
from builtin-dynamic-object-size-16.c.
* gcc.dg/builtin-object-size-17.c: Likewise.
Signed-off-by: Siddhesh Poyarekar
e-3.c [DYNAMIC_OBJECT_SIZE]:
Likewise.
* gcc.dg/builtin-object-size-4.c [DYNAMIC_OBJECT_SIZE]:
Likewise.
* gcc.dg/builtin-object-size-5.c [DYNAMIC_OBJECT_SIZE]:
Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c
/testsuite/ChangeLog:
* gcc.dg/builtin-dynamic-object-size-0.c: Add new tests.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 87
gcc/tree-object-size.c| 423 --
2 files changed, 383 insertions(+), 127 deletions
]:
Likewise.
* gcc.dg/builtin-object-size-4.c (test1) [DYNAMIC_OBJECT_SIZE]:
Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 71 ++
gcc/testsuite/gcc.dg/builtin-object-size-1.c | 30 +-
gcc/testsuite/gcc.dg
) [DYNAMIC_OBJECT_SIZE]:
Likewise.
* gcc.dg/builtin-object-size-3.c (test1) [DYNAMIC_OBJECT_SIZE]:
Likewise.
* gcc.dg/builtin-object-size-4.c (test1) [DYNAMIC_OBJECT_SIZE]:
Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 227
/ChangeLog:
* gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
* gcc.dg/builtin-chk-fold.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
Testing:
- gcc.dg shows no new regressions on x86_64, a full bootstrap and test
run are in progress.
gcc/gimple-fold.c
/ChangeLog:
* gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
* gcc.dg/builtin-chk-fold.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
Changes from v1:
- Update comment that incorrectly said that known_safe emits a warning.
- Add tests for strncpy and snprintf too.
gcc
On 11/10/21 16:15, Siddhesh Poyarekar wrote:
Instead of comparing LEN and SIZE only if they are constants, use their
ranges to decide if LEN will always be lower than or same as SIZE.
This change ends up putting the stringop-overflow warning line number
against the strcpy implementation, so
,
gimple_fold_builtin_stxncpy_chk): Use BUILT_IN_STRNCPY if return
value is not used.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-fold.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 74c9ce4bdc8..cadccfe3010 100644
--- a/gcc/gimple
On 11/11/21 02:06, Jeff Law wrote:
On 11/10/2021 10:47 AM, Siddhesh Poyarekar wrote:
Use the ignore flag to transform BUILT_IN_STPCPY_CHK to BUILT_IN_STRCPY
when set. This transformation will happen in a subsequent fold anyway
but do it right away and save the additional effort.
gcc
__memcpy_chk calls being
optimized away completely in addition to a couple of memmove and strcpy
chk variants being transformed into regular calls.
Siddhesh Poyarekar (3):
gimple-fold: Transform stp*cpy_chk to str*cpy directly
gimple-fold: Use ranges to simplify _chk calls
gimple-fold: Use ranges
actually happened.
gcc/ChangeLog:
* gimple-fold.c (gimple_fold_builtin_stxcpy_chk,
gimple_fold_builtin_stxncpy_chk): Use BUILT_IN_STRNCPY if return
value is not used.
gcc/testsuite/ChangeLog:
* gcc.dg/fold-stringops.c: New test.
Signed-off-by: Siddhesh Poyarekar
geLog:
* gcc.dg/fold-stringops-2.c: Define size_t.
(safe1): Adjust.
(safe4): New test.
* gcc.dg/fold-stringops-3.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-fold.c | 76 +
gcc/testsuite/gcc.dg/fold-stringops-2.c
,
gimple_fold_builtin_sprintf_chk): Use it.
gcc/testsuite/ChangeLog:
* gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
* gcc.dg/builtin-chk-fold.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-fold.c | 216 +---
gcc/testsuite/gcc.dg
On 11/12/21 22:46, Prathamesh Kulkarni wrote:
On Fri, 12 Nov 2021 at 01:12, Siddhesh Poyarekar wrote:
Avoid going through another folding cycle and use the ignore flag to
directly transform BUILT_IN_STPCPY_CHK to BUILT_IN_STRCPY when set,
likewise for BUILT_IN_STPNCPY_CHK to BUILT_IN_STPNCPY
On 11/12/21 01:11, Siddhesh Poyarekar wrote:
Remove the warnings for strncat since it is already handled (and even
the error messages look identical) in gimple-ssa-warn-access. Instead,
use len range to determine if it is within bounds of source and
destination and simplify it to strcat if it
ed to strcat.
- Renamed known_safe to known_lower
Siddhesh Poyarekar (3):
gimple-fold: Transform stp*cpy_chk to str*cpy directly
gimple-fold: Use ranges to simplify _chk calls
gimple-fold: Use ranges to simplify strncat and snprintf
gcc/gimple-fold.c
-stringops.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-fold.c | 55 -
gcc/testsuite/gcc.dg/fold-stringops-1.c | 23 +++
2 files changed, 58 insertions(+), 20 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/fold-stringops-1
,
gimple_fold_builtin_sprintf_chk): Use it.
gcc/testsuite/ChangeLog:
* gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
* gcc.dg/builtin-chk-fold.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-fold.c | 216 +---
gcc/testsuite/gcc.dg
.
(gimple_fold_builtin_snprintf): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/fold-stringops-2.c: Define size_t.
(safe1): Adjust.
(safe4): New test.
* gcc.dg/fold-stringops-3.c: New test.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-fold.c | 102
On 11/16/21 01:55, Jeff Law wrote:
On 11/15/2021 10:33 AM, Siddhesh Poyarekar wrote:
Instead of comparing LEN and SIZE only if they are constants, use their
ranges to decide if LEN will always be lower than or same as SIZE.
This change ends up putting the stringop-overflow warning line
Antoniu Pop
-Siddhesh Poyarekar
+Siddhesh Poyarekar
Vidya Praveen
Thomas Preud'homme
Vladimir
,
compute_builtin_object_size): Drop PDECL and POFF arguments.
(addr_object_size): Adjust calls.
* tree-object-size.h (compute_builtin_object_size): Drop PDECL
and POFF arguments.
Signed-off-by: Siddhesh Poyarekar
---
gcc/tree-object-size.c | 42
mpute an
estimate if nesting crosses a threshold. I'll take this up once we
have more data on the nature of the bottlenecks.
Siddhesh Poyarekar (8):
__builtin_dynamic_object_size: Recognize builtin name
tree-dynamic-object-size: New pass
tree-dynamic-object-size: Handle GIMPLE_PHI
Recognize the __builtin_dynamic_object_size builtin, but simply
replace it with -1 or 0 for now.
gcc/ChangeLog:
* builtins.c (expand_builtin, fold_builtin_2): Add
BUILT_IN_DYN_OBJECT_SIZE.
(fold_builtin_dyn_object_size): New function.
(valid_object_size_args): New
-off-by: Siddhesh Poyarekar
---
gcc/Makefile.in | 19 +-
gcc/builtins.c| 8 +
gcc/doc/extend.texi | 11 +
gcc/passes.def| 3 +
.../gcc.dg/builtin-dynamic-object-size-0.c
_malloc_condphi, test_builtin_malloc_condphi2,
test_builtin_malloc_condphi3, test_builtin_calloc_condphi,
test_deploop): New tests.
(main): Call them.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 92 +++
gcc/tree-dynamic-object-size.c
object_wholesizes and
object_wholesize_exprs.
gcc/testsuite/ChangeLog
* gcc.dg/builtin-dynamic-object-size-0.c (dynarray_struct):
New struct.
(test_dynarray_struct, test_substring,
test_substring_ptrplus): New tests.
(main): Call them.
Signed-off-by:
,
test_passthrough_nonssa): New tests.
(main): Call them.
Signed-off-by: Siddhesh Poyarekar
---
gcc/builtins.c| 2 +-
.../gcc.dg/builtin-dynamic-object-size-0.c| 37 +++
gcc/tree-dynamic-object-size.c| 255 +-
3
, gimplify_size_exprs): Adjust.
(parm_object_size): New function.
(collect_object_sizes_for): Handle GIMPLE_NOP.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-dynamic-object-size-0.c (test_parmsz): New
test.
(main): Call it.
Signed-off-by: Siddhesh Poyarekar
.
(addr_dyn_object_size): Call it. Support subobject size
computation.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-dynamic-object-size-0.c
(test_dynarray_struct_subobj): New test.
(main): Call it.
Signed-off-by: Siddhesh Poyarekar
---
.../gcc.dg/builtin-dynamic-object-size-0.c| 34
.
* gcc.dg/builtin-object-size-16.c: Likewise.
* gcc.dg/builtin-object-size-17.c: Likewise.
* gcc.dg/builtin-object-size-2.c: Likewise.
* gcc.dg/builtin-object-size-3.c: Likewise.
* gcc.dg/builtin-object-size-4.c: Likewise.
Signed-off-by: Siddhesh Poyarekar
---
.../g
On 10/8/21 03:44, Siddhesh Poyarekar wrote:
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 133b82eef38..082d167cd65 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12777,6 +12777,17 @@ assert (__builtin_object_size (q, 1) == sizeof
(var.b));
@end smallexample
On 10/8/21 03:44, Siddhesh Poyarekar wrote:
(from about 4% to 70% in bash), but that could well be due to the _chk
I should also clarify that this is for memcpy. For all fortifiable
functions, the coverage percentage went from 30.81% to 84.5% for bash.
Below is the full table. Please note
On 10/12/21 19:12, Jakub Jelinek wrote:
On Fri, Oct 08, 2021 at 03:44:25AM +0530, Siddhesh Poyarekar wrote:
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -180,6 +180,7 @@ static rtx expand_builtin_memory_chk (tree, rtx,
machine_mode,
static void maybe_emit_chk_warning (tree, enum
On 10/12/21 19:28, Jakub Jelinek wrote:
On Fri, Oct 08, 2021 at 03:44:26AM +0530, Siddhesh Poyarekar wrote:
A new pass is added to execute just before the tree-object-size pass
to recognize and simplify __builtin_dynamic_object_size. Some key
ideas (such as multipass object size collection to
:
* gcc.target/i386/addr-space-3.c: New test case.
Signed-off-by: Siddhesh Poyarekar
---
gcc/gimple-array-bounds.cc | 3 +++
gcc/testsuite/gcc.target/i386/addr-space-3.c | 5 +
2 files changed, 8 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/i386/addr-space-3.c
diff --git
On 10/13/21 00:36, Martin Sebor wrote:
On 10/12/21 12:33 PM, Siddhesh Poyarekar wrote:
The warning is falsely triggered for THREAD_SELF in glibc when
accessing TCB through the segment register.
Thanks for looking into it! The Glibc warning is being tracked
in PR 102630. The root cause
On 10/13/21 13:50, Richard Biener wrote:
On Tue, Oct 12, 2021 at 8:34 PM Siddhesh Poyarekar wrote:
The warning is falsely triggered for THREAD_SELF in glibc when
accessing TCB through the segment register.
I think this is a more generic bug - the warning is also bogus if the
general address
: Siddhesh Poyarekar
---
gcc/tree-object-size.c | 12 +---
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 6a4dc724f34..46a976dfe10 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -1298,6 +1298,10
ype).
gcc/ChangeLog:
* tree-object-size.c (unknown): Make into a function. Adjust
all uses.
(unknown_object_size): Remove function.
(collect_object_sizes_for): Set object_sizes directly.
Signed-off-by: Siddhesh Poyarekar
---
gcc/tree-object-si
On 10/19/21 12:28, Jakub Jelinek wrote:
On Tue, Oct 19, 2021 at 09:47:45AM +0530, Siddhesh Poyarekar wrote:
Compute the unknown size value as a function of the min/max bit of
object_size_type. This transforms into a neat little branchless
sequence on x86_64:
movl%edi, %eax
a function. Adjust
all uses.
(unknown_object_size): Simplify implementation.
Signed-off-by: Siddhesh Poyarekar
---
gcc/tree-object-size.c | 100 ++---
1 file changed, 43 insertions(+), 57 deletions(-)
diff --git a/gcc/tree-object-size.c b/gcc/t
On 10/19/21 13:15, Jakub Jelinek wrote:
Ok for trunk if it passes bootstrap/regtest.
Pushed now, no new issues seen in bootstrap and regtest.
Thanks,
Siddhesh
On 10/20/21 22:26, Martin Sebor wrote:
On 10/7/21 4:14 PM, Siddhesh Poyarekar wrote:
Handle either static sizes in function parameters or hints provided by
__attribute__ ((access (...))) to compute sizes for objects.
It's been my hope to eventually teach __builtin_object_size about
attr
Recognize __builtin_free as being equivalent to free when passed into
__attribute__((malloc ())), similar to how it is treated when it is
encountered as a call. This fixes spurious warnings in glibc where
xmalloc family of allocators as well as reallocarray, memalign,
etc. are declared to have __b
Consolidate allocator builtin handling and add support for
__builtin_strdup and __builtin_strndup.
gcc/analyzer/ChangeLog:
* analyzer.cc (is_named_call_p, is_std_named_call_p): Make
first argument a const_tree.
* analyzer.h (is_named_call_p, -s_std_named_call_p): Li
On 2024-02-16 14:47, Qing Zhao wrote:
'counted_by (COUNT)'
The 'counted_by' attribute may be attached to the C99 flexible
array member of a structure. It indicates that the number of the
elements of the array is given by the field named "COUNT" in the
same structure as th
On 2024-02-16 14:47, Qing Zhao wrote:
Including the following changes:
* The definition of the new internal function .ACCESS_WITH_SIZE
in internal-fn.def.
* C FE converts every reference to a FAM with a "counted_by" attribute
to a call to the internal function .ACCESS_WITH_SIZE.
(buil
On 2024-02-16 14:47, Qing Zhao wrote:
gcc/ChangeLog:
* tree-object-size.cc (access_with_size_object_size): New function.
(call_object_size): Call the new function.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT.
* gcc.d
On 2024-02-16 14:47, Qing Zhao wrote:
gcc/c-family/ChangeLog:
* c-ubsan.cc (get_bound_from_access_with_size): New function.
(ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE.
gcc/testsuite/ChangeLog:
* gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test
On 2024-03-18 12:28, Qing Zhao wrote:
This should probably bail out if object_size_type & OST_DYNAMIC == 0.
Okay. Will add this.
When add this into access_with_size_object_size, I found some old bugs
in early_object_sizes_execute_one, and fixed them as well.
Would you be able to isolate t
On 2024-03-29 12:07, Qing Zhao wrote:
gcc/ChangeLog:
* tree-object-size.cc (access_with_size_object_size): New function.
(call_object_size): Call the new function.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-object-size-common.h: Add a new macro EXPECT.
* gcc.dg/f
On 2024-03-29 12:07, Qing Zhao wrote:
gcc/c-family/ChangeLog:
* c-ubsan.cc (get_bound_from_access_with_size): New function.
(ubsan_instrument_bounds): Handle call to .ACCESS_WITH_SIZE.
gcc/testsuite/ChangeLog:
* gcc.dg/ubsan/flex-array-counted-by-bounds-2.c: New test.
On 2024-03-29 12:07, Qing Zhao wrote:
to carry the TYPE of the flexible array.
Such information is needed during tree-object-size.cc.
We cannot use the result type or the type of the 1st argument
of the routine .ACCESS_WITH_SIZE to decide the element type
of the original array due to possible t
101 - 200 of 390 matches
Mail list logo