From cba6e4a8ec3b8718de7857b90d0137ae82f381fb Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 15 Sep 2023 00:14:13 +0200 Subject: [PATCH] [WIP] Re-introduce 'TREE_USED' in tree streaming I have a nvptx back end expand-time transformation implemented, that's active 'if (!TREE_USED ([formal parameter]))'. Now I found that per one-decade-old commit ee03e71d472a3f73cbc1a132a284309f36565972 (Subversion r200151) "Re-write LTO type merging again, do tree merging", 'TREE_USED' has *intentionally been removed* from tree streaming. That means, in nvptx offloading compilation, every formal parameter (like for outlined '[...]._omp_fn.[...]' functions the one that's pointing to the "OMP blob", '.omp_data_i', for example) is considered unused, and thus mis-optimized. --- gcc/tree-streamer-in.cc | 1 + gcc/tree-streamer-out.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc index 5bead0c3c6a..f82374e60a5 100644 --- a/gcc/tree-streamer-in.cc +++ b/gcc/tree-streamer-in.cc @@ -132,6 +132,7 @@ unpack_ts_base_value_fields (struct bitpack_d *bp, tree expr) TYPE_ARTIFICIAL (expr) = (unsigned) bp_unpack_value (bp, 1); else TREE_NO_WARNING (expr) = (unsigned) bp_unpack_value (bp, 1); + TREE_USED (expr) = (unsigned) bp_unpack_value (bp, 1); TREE_NOTHROW (expr) = (unsigned) bp_unpack_value (bp, 1); TREE_STATIC (expr) = (unsigned) bp_unpack_value (bp, 1); if (TREE_CODE (expr) != TREE_BINFO) diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc index ff9694e17dd..74f969478cf 100644 --- a/gcc/tree-streamer-out.cc +++ b/gcc/tree-streamer-out.cc @@ -105,6 +105,7 @@ pack_ts_base_value_fields (struct bitpack_d *bp, tree expr) bp_pack_value (bp, TYPE_ARTIFICIAL (expr), 1); else bp_pack_value (bp, TREE_NO_WARNING (expr), 1); + bp_pack_value (bp, TREE_USED (expr), 1); bp_pack_value (bp, TREE_NOTHROW (expr), 1); bp_pack_value (bp, TREE_STATIC (expr), 1); if (TREE_CODE (expr) != TREE_BINFO) -- 2.34.1