https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101824
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, so the underlying issue is that predcom uses the appropriate "GENERIC" way
of assessing if something is volatile:
static bool
suitable_reference_p (struct data_reference *a, enum ref_step_type *ref_step)
{
tree ref = DR_REF (a), step = DR_STEP (a);
if (!step
|| TREE_THIS_VOLATILE (ref)
|| !is_gimple_reg_type (TREE_TYPE (ref))
|| tree_could_throw_p (ref))
return false;
but we have
<component_ref 0x7ffff635c690
type <boolean_type 0x7ffff67189d8 logical(kind=4) volatile public unsigned
SI
size <integer_cst 0x7ffff6543df8 constant 32>
unit-size <integer_cst 0x7ffff6543e10 constant 4>
align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff67189d8 precision:1 min <integer_cst 0x7ffff6561168 0> max <integer_cst
0x7ffff6561198 1>>
arg:0 <var_decl 0x7ffff6367120 FRAME.8
type <record_type 0x7ffff67210a8 FRAME.wait_for_sigterm BLK
size <integer_cst 0x7ffff6720780 constant 576>
unit-size <integer_cst 0x7ffff67207b0 constant 72>
user align:64 warn_if_not_align:0 symtab:0 alias-set 10
canonical-type 0x7ffff67210a8 fields <field_decl 0x7ffff67167b8
interface_sigterm>
pointer_to_this <pointer_type 0x7ffff6721150>>
addressable used ignored BLK /tmp/t.f90:1:24 size <integer_cst
0x7ffff6720780 576> unit-size <integer_cst 0x7ffff67207b0 72>
align:128 warn_if_not_align:0 context <function_decl 0x7ffff6724000
main> abstract_origin <var_decl 0x7ffff6725a20 FRAME.8>>
arg:1 <field_decl 0x7ffff67167b8 interface_sigterm type <boolean_type
0x7ffff67189d8 logical(kind=4)>
volatile unsigned nonaddressable SI /tmp/t.f90:8:21 size <integer_cst
0x7ffff6543df8 32> unit-size <integer_cst 0x7ffff6543e10 4>
align:32 warn_if_not_align:0 offset_align 128
offset <integer_cst 0x7ffff6543be8 constant 0>
bit-offset <integer_cst 0x7ffff6543c30 constant 0> context <record_type
0x7ffff67210a8 FRAME.wait_for_sigterm>
chain <field_decl 0x7ffff6716720 interface_sigusr1 type <boolean_type
0x7ffff67189d8 logical(kind=4)>
volatile unsigned nonaddressable SI /tmp/t.f90:9:21 size
<integer_cst 0x7ffff6543df8 32> unit-size <integer_cst 0x7ffff6543e10 4>
align:32 warn_if_not_align:0 offset_align 128 offset <integer_cst
0x7ffff6543be8 0> bit-offset <integer_cst 0x7ffff6543df8 32> context
<record_type 0x7ffff67210a8 FRAME.wait_for_sigterm> chain <field_decl
0x7ffff6716980 catchsigusr1>>>>
somehow for the corresponding C testcase
int main()
{
struct X { volatile int y; } z;
while (z.y)
;
return 0;
}
it "works" but when doing
int main()
{
volatile int y;
void bar()
{
__builtin_printf ("%d", y);
}
while (y)
;
return 0;
}
it reproduces the issue pointing to a bug in tree-nested.c.