aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-03-03 10:09:25 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2025-05-12 13:22:22 +0200
commit67c8e777d466d3bed9830bf01841c96b6881b58d (patch)
treef486af9b1133ba684654369091b3b9285c61f300
parent9416969d795003c06714f7663bf670efd7efdd46 (diff)
downloadgcc-67c8e777d466d3bed9830bf01841c96b6881b58d.zip
gcc-67c8e777d466d3bed9830bf01841c96b6881b58d.tar.gz
gcc-67c8e777d466d3bed9830bf01841c96b6881b58d.tar.bz2
sync LTO streaming and hashing for accelerators and vector type mode
The following syncs up LTO tree hashing and streaming of TYPE_MODE and DECL_MODE which long had a discrepancy for vector types and recently got special-casing of streaming for offloading. Failure to handle this results in less possible type merging to occur. Note the compare step will still use TYPE_MODE and DECL_MODE. * lto-streamer-out.cc (hash_tree): Hash TYPE_MODE_RAW. When offloading hash modes as VOIDmode for aggregates and vectors.
-rw-r--r--gcc/lto-streamer-out.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index a055d12..86d3384 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -1256,7 +1256,17 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map,
if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
{
- hstate.add_hwi (DECL_MODE (t));
+ /* Similar to TYPE_MODE, avoid streaming out host-specific DECL_MODE
+ for aggregate type with offloading enabled, and while streaming-in
+ recompute appropriate DECL_MODE for accelerator. */
+ if (lto_stream_offload_p
+ && (VAR_P (t)
+ || TREE_CODE (t) == PARM_DECL
+ || TREE_CODE (t) == FIELD_DECL)
+ && AGGREGATE_TYPE_P (TREE_TYPE (t)))
+ hstate.add_hwi (VOIDmode);
+ else
+ hstate.add_hwi (DECL_MODE (t));
hstate.add_flag (DECL_NONLOCAL (t));
hstate.add_flag (DECL_VIRTUAL_P (t));
hstate.add_flag (DECL_IGNORED_P (t));
@@ -1354,7 +1364,19 @@ hash_tree (struct streamer_tree_cache_d *cache, hash_map<tree, hashval_t> *map,
if (CODE_CONTAINS_STRUCT (code, TS_TYPE_COMMON))
{
- hstate.add_hwi (TYPE_MODE (t));
+ /* For offloading, avoid streaming out TYPE_MODE for aggregate type since
+ it may be host-specific. For eg, aarch64 uses OImode for ARRAY_TYPE
+ whose size is 256-bits, which is not representable on accelerator.
+ Instead stream out VOIDmode, and while streaming-in, recompute
+ appropriate TYPE_MODE for accelerator. */
+ if (lto_stream_offload_p
+ && (AGGREGATE_TYPE_P (t) || VECTOR_TYPE_P (t)))
+ hstate.add_hwi (VOIDmode);
+ /* for VECTOR_TYPE, TYPE_MODE reevaluates the mode using target_flags
+ not necessary valid in a global context.
+ Use the raw value previously set by layout_type. */
+ else
+ hstate.add_hwi (TYPE_MODE_RAW (t));
/* TYPE_NO_FORCE_BLK is private to stor-layout and need
no streaming. */
hstate.add_flag (TYPE_PACKED (t));