Comment 11 for bug 736661

Revision history for this message
In , Michael K. Edwards (m-k-edwards) wrote :

The problem seems to be that promote_decl_mode() is changing the value returned from the pair constructor from HImode to BLKmode:

(gdb) p debug_tree(decl)
 <result_decl 0x2aaaab61ea80 D.2836
    type <record_type 0x2aaaab5d9930 pair no-force-blk type_5 type_6 BLK
        size <integer_cst 0x2aaaaaaf05f0 constant 16>
        unit size <integer_cst 0x2aaaaaaf0618 constant 2>
        align 8 symtab 0 alias set -1 canonical type 0x2aaaab5d9930
        fields <field_decl 0x2aaaab5f1d10 first type <boolean_type 0x2aaaaab08888 bool>
            unsigned nonlocal decl_3 QI file PR48660.cpp line 6 col 7
            size <integer_cst 0x2aaaaaaf04b0 constant 8>
            unit size <integer_cst 0x2aaaaaaf04d8 constant 1>
            align 8 offset_align 64
            offset <integer_cst 0x2aaaaaaf0410 constant 0>
            bit offset <integer_cst 0x2aaaaaaf0e38 constant 0> context <record_type 0x2aaaab5d9930 pair> chain <field_decl 0x2aaaab5f1da8 second>> context <translation_unit_decl 0x2aaaaaafb508 D.1>
        full-name "struct pair<bool, bool>"
        X() X(constX&) this=(X&) n_parents=0 use_template=1 interface-unknown
        pointer_to_this <pointer_type 0x2aaaab603150> chain <type_decl 0x2aaaab5ce958 pair>>
    used ignored regdecl BLK file PR48660.cpp line 31 col 1 size <integer_cst 0x2aaaaaaf05f0 16> unit size <integer_cst 0x2aaaaaaf0618 2>
    align 8
    (reg:HI 140 [ <retval> ])>

This is in turn happening because DECL_MODE (decl) == BLKmode, while in the caller, GET_MODE (decl_rtl) == HImode. It's not clear to me whether the rtx expression should have been in BLKmode in the first place, or whether expand_expr_real_1() should tolerate the conversion. The context in expand_expr_real_1() suggests that the point of the call to promote_decl_mode() was to get the signedness of the result, and the only use of its return value is in the gcc_assert(). I will check whether moving the gcc_assert() inside the results in promote_function_mode() branch results in correct code; however, that may just be papering over a real problem.