public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/ARM/heads/morello)] cfgexpand: Fix uninitialized read in defer_stack_allocation
@ 2023-06-28 13:33 Alex Coplan
0 siblings, 0 replies; only message in thread
From: Alex Coplan @ 2023-06-28 13:33 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f8c1a0100575f373db07a45d81344f3983461546
commit f8c1a0100575f373db07a45d81344f3983461546
Author: Alex Coplan <alex.coplan@arm.com>
Date: Wed May 31 10:29:05 2023 +0100
cfgexpand: Fix uninitialized read in defer_stack_allocation
When introducing stack bounds narrowing we'd introduced the potential
for an uninitialized read since we unconditionally used the size
computed by poly_int_tree_p (to determine the CHERI alignment
requirement), and this triggered a bootstrap failure on x86_64 due to
the compiler diagnosing this.
On further inspection, it appears that poly_int_tree_p shouldn't ever
return false here, so in this patch we assert that this is the case.
This restores bootstrap on x86_64.
Diff:
---
gcc/cfgexpand.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 4aafeb22f36..ca68d1949eb 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1573,14 +1573,15 @@ defer_stack_allocation (tree var, bool toplevel)
tree size_unit = TREE_CODE (var) == SSA_NAME
? TYPE_SIZE_UNIT (TREE_TYPE (var))
: DECL_SIZE_UNIT (var);
+
poly_uint64 size;
+ if (!poly_int_tree_p (size_unit, &size))
+ gcc_unreachable ();
/* Whether the variable is small enough for immediate allocation not to be
a problem with regard to the frame size. */
bool smallish
- = (poly_int_tree_p (size_unit, &size)
- && (estimated_poly_value (size)
- < param_min_size_for_stack_sharing));
+ = (estimated_poly_value (size) < param_min_size_for_stack_sharing);
/* If stack protection is enabled, *all* stack variables must be deferred,
so that we can re-order the strings to the top of the frame.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-28 13:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-28 13:33 [gcc(refs/vendors/ARM/heads/morello)] cfgexpand: Fix uninitialized read in defer_stack_allocation Alex Coplan
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).