https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63587

--- Comment #12 from Martin Liška <mliska at suse dot cz> ---
On 10/24/2014 10:44 AM, rguenther at suse dot de wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63587
>
> --- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> ---
> On Thu, 23 Oct 2014, marxin at gcc dot gnu.org wrote:
>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63587
>>
>> --- Comment #8 from Martin Liška <marxin at gcc dot gnu.org> ---
>> I added assert to cgraphunit.c (expand_thunk):1547:
>>
>>        /* Build call to the function being thunked.  */
>>        if (!VOID_TYPE_P (restype))
>>      {
>>        if (DECL_BY_REFERENCE (resdecl))
>>          restmp = gimple_fold_indirect_ref (resdecl);
>>        else if (!is_gimple_reg_type (restype))
>>          {
>>            restmp = resdecl;
>>            gcc_assert (TREE_CODE (restmp) == VAR_DECL);
>>            add_local_decl (cfun, restmp);
>>            BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp;
>>          }
>>        else
>>          restmp = create_tmp_reg (restype, "retval");
>>      }
>>
>> It's triggered quite often, one example of a thunk created by IPA ICF:
>
> Well, the bug is the add_local_decl being called with a RESULT_DECL.
> Thus you should try placing an assert into add_local_decl instead
> (need to move it out-of-line for that).

You are right, it would be good to place assert to add_local_decl function,
attachment contains suggested patch
that I will regtest.

Problematic is that one would like to place assert to function.h, but gengtype
does not include tree.h
for gencondmd.c:

In file included from build/gencondmd.c:5:0:
../../gcc/function.h: In function ‘void add_local_decl(function*, tree)’:
../../gcc/function.h:674:27: error: ‘TREE_CODE’ was not declared in this scope
    gcc_assert (TREE_CODE (d) == VAR_DECL);

Is it acceptable to put the implementation to function.c?

Thanks,
Martin

>
>> std::basic_streambuf<_CharT, _Traits>::pos_type std::basic_streambuf<_CharT,
>> _Traits>::seekpos(std::basic_streambuf<_CharT, _Traits>::pos_type,
>> std::ios_base::openmode) [with _CharT = char; _Traits = 
>> std::char_traits<char>;
>> std::basic_streambuf<_CharT, _Traits>::pos_type = std::fpos<__mbstate_t>;
>> std::ios_base::openmode = std::_Ios_Openmode] (struct basic_streambuf * const
>> this, struct pos_type D.23077, openmode D.23078)
>> {
>>    struct pos_type <retval>;
>>
>>    <bb 2>:
>>    <retval> = std::basic_streambuf<wchar_t>::seekpos (this_2(D), D.23077,
>> _3(D)); [tail call]
>>    return <retval>;
>>
>> }
>>
>> where std::basic_streambuf<_CharT, _Traits>::pos_type is:
>>   <result_decl 0x7ffff4eec708 D.39821
>>      type <record_type 0x7ffff59c2150 pos_type sizes-gimplified asm_written 
>> used
>> needs-constructing type_1 type_5 TI
>>          size <integer_cst 0x7ffff6c2fe40 constant 128>
>>          unit size <integer_cst 0x7ffff6c2fe58 constant 16>
>>          align 64 symtab -164402368 alias set -1 canonical type 
>> 0x7ffff614adc8
>>          fields <field_decl 0x7ffff51cd850 _M_off type <integer_type
>> 0x7ffff678c738 streamoff>
>>              used private nonlocal decl_3 DI file
>> /home/marxin/Programming/gcc/objdir/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/postypes.h
>> line 115 col 33
>>              size <integer_cst 0x7ffff6c2fdf8 constant 64>
>>              unit size <integer_cst 0x7ffff6c2fe10 constant 8>
>>              align 64 offset_align 128
>>              offset <integer_cst 0x7ffff6c2fe28 constant 0>
>>              bit offset <integer_cst 0x7ffff6c2fe70 constant 0> context
>> <record_type 0x7ffff614adc8 fpos> chain <field_decl 0x7ffff51cd8e8 _M_state>>
>> context <namespace_decl 0x7ffff6c4c098 std>
>>          full-name "std::basic_streambuf<char>::pos_type"
>>          needs-constructor X() has-type-conversion X(constX&) this=(X&)
>> n_parents=0 use_template=1 interface-unknown
>>          pointer_to_this <pointer_type 0x7ffff5224e70> chain <type_decl
>> 0x7ffff6146da8 fpos>>
>>      ignored TI file
>> /home/marxin/Programming/gcc/objdir/x86_64-unknown-linux-gnu/libstdc++-v3/include/streambuf
>> line 602 col 7 size <integer_cst 0x7ffff6c2fe40 128> unit size <integer_cst
>> 0x7ffff6c2fe58 16>
>>      align 64 context <function_decl 0x7ffff5797948 seekoff>>
>>
>> Is there a bug in expand_thunk or do I miss something?
>> Thanks,
>> Martin
>>
>>
>

Reply via email to