On Mon, Jan 28, 2019 at 01:18:43PM +0100, Richard Biener wrote: > Eww :/ That means they are not semantically the same which IMHO is > bad. If you make buf1 volatile does it trip over > maybe_canonicalize_mem_ref_addr and miscompile? Or are we somehow
If buf1 is volatile, then no clobbers are added for it for when it goes out of scope: if (VAR_P (t) && !is_global_var (t) && DECL_CONTEXT (t) == current_function_decl) { if (!DECL_HARD_REGISTER (t) && !TREE_THIS_VOLATILE (t) && !DECL_HAS_VALUE_EXPR_P (t) /* Only care for variables that have to be in memory. Others will be rewritten into SSA names, hence moved to the top-level. */ && !is_gimple_reg (t) && flag_stack_reuse != SR_NONE) { tree clobber = build_clobber (TREE_TYPE (t)); The clobbers from ctors and dtors are still there, but nothing folds them to non-MEM_REF anyway: volatile char buf2[128]; volatile char buf1[128]; <bb 2> [local count: 1073741824]: foo (&buf1); MEM[(struct &)&buf1] ={v} {CLOBBER}; memset (&MEM[(void *)&buf1], 32, 128); bar (&buf1); MEM[(struct &)&buf1] ={v} {CLOBBER}; baz (&buf2); return; in *.optimized. Jakub