On Wed, Jan 31, 2024 at 10:07:28AM +0100, Jakub Jelinek wrote: > Indeed. But what we could do is try to fold_stmt those .ASAN_MARK calls > away earlier (but sure, the asan.cc change would be still required because > that would be just an optimization). But that can be handled incrementally, > so I think the patch is ok as is (and I can handle the incremental part > myself).
Like this, so far just tested on the testcase. Ok for trunk if it passes bootstrap/regtest on top of Jason's patch? 2024-01-31 Jakub Jelinek <ja...@redhat.com> PR c++/113531 * gimple-fold.cc (gimple_fold_call): Remove .ASAN_MARK calls on variables which were promoted to TREE_STATIC. --- gcc/gimple-fold.cc.jj 2024-01-03 11:51:27.236790799 +0100 +++ gcc/gimple-fold.cc 2024-01-31 12:09:14.853348505 +0100 @@ -5722,6 +5722,21 @@ gimple_fold_call (gimple_stmt_iterator * } } break; + case IFN_ASAN_MARK: + { + tree base = gimple_call_arg (stmt, 1); + gcc_checking_assert (TREE_CODE (base) == ADDR_EXPR); + tree decl = TREE_OPERAND (base, 0); + if (VAR_P (decl) && TREE_STATIC (decl)) + { + /* Don't poison a variable with static storage; it might have + gotten marked before gimplify_init_constructor promoted it + to static. */ + replace_call_with_value (gsi, NULL_TREE); + return true; + } + } + break; case IFN_GOACC_DIM_SIZE: case IFN_GOACC_DIM_POS: result = fold_internal_goacc_dim (stmt); Jakub