On 01/22/2017 04:52 PM, Martin Sebor wrote:
The attached simple patch removes the format_result::constant member
that is not used except in debugging dumps. Removing it makes
the handling of non-constant arguments simpler. Since this handling
increases in the substantive changes that follow this change reduces
the complexity of those changes.
In addition, this change simplifies the try_substitute_return_value
function to make the logic that controls the sprintf return value
optimization clearer. This change also benefits the subsequent
patches by simplifying the necessary changes.
Neither of these changes affects the tests.
gcc-78703-2.diff
commit 3802ab59aec722b25e9be85a0748138ef89e4aec
Author: Martin Sebor <mse...@redhat.com>
Date: Fri Jan 20 14:26:47 2017 -0700
2017-01-20 Martin Sebor <mse...@redhat.com>
* gimple-ssa-sprintf.c (struct format_result): Remove constant member.
(struct fmtresult, format_integer, format_floating): Adjust.
(get_string_length, format_string,format_directive): Same.
(pass_sprintf_length::compute_format_length): Same.
(try_substitute_return_value): Simplify slightly.
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 3464b45..38412b0 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -465,11 +458,10 @@ struct fmtresult
: argmin (), argmax (),
knownrange (min < HOST_WIDE_INT_MAX && max < HOST_WIDE_INT_MAX),
bounded (),
- constant (),
nullp ()
{
range.min = min;
- range.max = min;
+ range.max = max;
}
Yow! Probably deserves a mention in the ChangeLog.
@@ -2866,42 +2840,71 @@ try_substitute_return_value (gimple_stmt_iterator *gsi,
const pass_sprintf_length::call_info &info,
const format_result &res)
{
+ if (!res.bounded)
+ return false;
+
tree lhs = gimple_get_lhs (info.callstmt);
+ /* Set to true when the entire call has been removed. */
+ bool removed = false;
+
+ /* The minumum return value. */
s/minumum/minimum/
OK with those nits fixed. Like the prior patch, if this has been
bootstrapped and regression tested, then go ahead and install it now
rather than waiting.
jeff