This patchset enhances the __builtin_dynamic_object_size builtin to produce dynamic expressions for object sizes to improve coverage of _FORTIFY_SOURCE.
Testing: -------- This series has been tested with build and test for i686, bootstrap with ubsan and bootstrap+test with x86_64. Additional testing plans (i.e. I've already started to do some of this): - Build packages to compare values returned by __builtin_object_size with the older pass and this new one. Also compare with __builtin_dynamic_object_size. - Expand the list of packages to get more coverage metrics. - Explore performance impact on applications on building with _FORTIFY_SOURCE=3. Changes from v5: - Address review comments - Add a couple more tests for object sizes of pointers passed as parameters. Siddhesh Poyarekar (4): tree-object-size: Support dynamic sizes in conditions tree-object-size: Handle function parameters tree-object-size: Handle GIMPLE_CALL tree-object-size: Dynamic sizes for ADDR_EXPR gcc/builtins.c | 6 +- .../gcc.dg/builtin-dynamic-object-size-0.c | 514 +++++++++++++ .../gcc.dg/builtin-dynamic-object-size-10.c | 2 + .../builtin-dynamic-object-size-5-main.c | 32 + .../gcc.dg/builtin-dynamic-object-size-5.c | 7 +- gcc/testsuite/gcc.dg/builtin-object-size-1.c | 154 +++- gcc/testsuite/gcc.dg/builtin-object-size-2.c | 133 ++++ gcc/testsuite/gcc.dg/builtin-object-size-3.c | 151 ++++ gcc/testsuite/gcc.dg/builtin-object-size-4.c | 93 +++ gcc/testsuite/gcc.dg/builtin-object-size-5.c | 22 +- gcc/tree-object-size.c | 689 +++++++++++++++--- 11 files changed, 1712 insertions(+), 91 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c create mode 100644 gcc/testsuite/gcc.dg/builtin-dynamic-object-size-5-main.c -- 2.33.1