From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D7A3A3861969; Tue, 26 Jan 2021 18:57:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7A3A3861969 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBjLzk3MTcyXSBbMTEgUmVncmVzc2lvbl0gSUNFOiB0cmVl?= =?UTF-8?B?IGNvZGUg4oCYc3NhX25hbWXigJkgaXMgbm90IHN1cHBvcnRlZCBpbiBMVE8g?= =?UTF-8?B?c3RyZWFtcyBzaW5jZSByMTEtMzMwMy1nNjQ1MGYwNzM4OGY5ZmU1Nw==?= Date: Tue, 26 Jan 2021 18:57:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: ice-on-valid-code, lto, patch X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 18:57:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97172 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #24 from Jakub Jelinek --- Completely untested routine that would allow unsharing expressions including SAVE_EXPRs/TARGET_EXPRs, obviously then the result couldn't be used in the = IL for code generation, only for warnings. It is basically unshare_expr, which afterwards when it sees SAVE_EXPRs or TARGET_EXPRs for the first time copies those and unshares their subtrees and when it sees those second and following time just reuses what it did before. /* Helper function for fully_unshare_expr. Copy SAVE_EXPRs and TARGET_EXPRs including their subtrees, but do that only once. */ static tree fully_unshare_expr_r (tree *tp, int *walk_subtrees, void *data) { enum tree_code code =3D TREE_CODE (*tp); if (code =3D=3D SAVE_EXPR || code =3D=3D TARGET_EXPR) { hash_map **map =3D (hash_map **) data; *walk_subtrees =3D 0; if (*map =3D=3D NULL) *map =3D new hash_map; tree &cached =3D (*map)->get_or_insert (*tp); if (cached) { *tp =3D cached; return NULL_TREE; } tree t =3D copy_node (*tp); cached =3D t; int len =3D 1; if (code =3D=3D TARGET_EXPR) len =3D (TREE_OPERAND (t, 3) =3D=3D TREE_OPERAND (t, 1)) ? 3 : 4; for (int i =3D 0; i < len; i++) { TREE_OPERAND (t, i) =3D unshare_expr (TREE_OPERAND (t, i)); walk_tree (&TREE_OPERAND (t, i), fully_unshare_expr_r, data, NULL= ); } if (len =3D=3D 3) TREE_OPERAND (t, 3) =3D TREE_OPERAND (t, 1); return NULL_TREE; } /* Stop at types, decls, constants like copy_tree_r. */ else if (TREE_CODE_CLASS (code) =3D=3D tcc_type || TREE_CODE_CLASS (code) =3D=3D tcc_declaration || TREE_CODE_CLASS (code) =3D=3D tcc_constant) *walk_subtrees =3D 0; return NULL_TREE; } /* Like unshare_expr, but unshare also SAVE_EXPRs and TARGET_EXPRs. After unsharing SAVE_EXPRs and TARGET_EXPRs, the returned expression shouldn't be gimplified into the IL, as that could mean evaluating side-effects multiple times. */ tree fully_unshare_expr (tree expr) { hash_map *map =3D NULL; expr =3D unshare_expr (expr); walk_tree (&expr, fully_unshare_expr_r, &map, NULL); delete map; return expr; }=