aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-03-20 10:52:02 +0100
committerRichard Biener <rguenther@suse.de>2020-03-20 10:52:45 +0100
commit8fefa21fcf67f30c467eb3cb73d09cb96d0ea6a8 (patch)
treeeb4a94c9ed28f177d9c7b73b1a1ebbfe22de7dc6 /gcc
parent719c864225e28c33a0737a331a772781ce8e6591 (diff)
downloadgcc-8fefa21fcf67f30c467eb3cb73d09cb96d0ea6a8.zip
gcc-8fefa21fcf67f30c467eb3cb73d09cb96d0ea6a8.tar.gz
gcc-8fefa21fcf67f30c467eb3cb73d09cb96d0ea6a8.tar.bz2
tree-optimization/94266 - fix object type extraction heuristics
This fixes the heuristic deriving an actual object type from a MEM_REFs pointer operand to use the more sensible type of an actual object instead of the pointed to type. 2020-03-20 Richard Biener <rguenther@suse.de> PR tree-optimization/94266 * gimple-ssa-sprintf.c (get_origin_and_offset): Use the type of the underlying object to adjust for the containing field if available.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/gimple-ssa-sprintf.c4
2 files changed, 10 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ded73b3..563be35 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-03-20 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/94266
+ * gimple-ssa-sprintf.c (get_origin_and_offset): Use the
+ type of the underlying object to adjust for the containing
+ field if available.
+
2020-03-20 Andre Vieira <andre.simoesdiasvieira@arm.com>
* config/arm/unspecs.md (UNSPEC_GET_FPSCR): Rename this to ...
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 13640e0..1879686 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -2331,7 +2331,9 @@ get_origin_and_offset (tree x, HOST_WIDE_INT *fldoff, HOST_WIDE_INT *off)
if (off)
{
- tree xtype = TREE_TYPE (TREE_TYPE (x));
+ tree xtype
+ = (TREE_CODE (x) == ADDR_EXPR
+ ? TREE_TYPE (TREE_OPERAND (x, 0)) : TREE_TYPE (TREE_TYPE (x)));
/* The byte offset of the most basic struct member the byte
offset *OFF corresponds to, or for a (multidimensional)