On Wed, Jul 15, 2020 at 9:30 AM Shuai Wang via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hello,
>
> I am using the following code to iterate different gimple statements:
>
> ...
>  gimple* stmt = gsi_stmt(gsi);
> if (gimple_assign_load_p(stmt)) {
>      tree rhs = gimple_assign_rhs1 (stmt);
>      if (!rhs) return;
>       gimple* def_stmt = SSA_NAME_DEF_STMT(rhs);
>       if (!def_stmt) return;
>
>      switch (gimple_code (def_stmt)) {
>          ....
>      }
> }
>
> While the above code works smoothly for most of the cases, to my surprise,
> the following statement (pointed by gsi) would cause a crash at
> gimple_code(def_stmt):
>
> stderr.9_1 = stderr;
>
> It seems that `stderr` is a special tree node; however, it successfully
> passes the two if checks and reaches the gimple_code(def_stmt), but still
> caused an exception:
>
> 0xb5cd5f crash_signal
>         ../../gcc-10.1.0/gcc/toplev.c:328
> 0x7f4214557838 gimple_code
>
> /export/d1/shuaiw/gcc-build-10/gcc-install/lib/gcc/x86_64-pc-linux-gnu/10.1.0/plugin/include/gimple.h:1783
> ....
>
> Am I missing anything?

I see you're working on 10.1, please make sure to configure your
development compiler with
--enable-checking which would have said that SSA_NAME_DEF_STMT expects
an SSA name
argument but you are passing it a VAR_DECL.

Richard.


> Best,
> Shuai

Reply via email to