Yes,  TREE_CODE (op1) != SSA_NAME shows that op1 is by no means SSA names
(although I don't know why). But how can I backwardly identify its
initialization statement _17 = (signed char *) _16? Thanks!

Shuai

On Tue, Jun 16, 2020 at 10:32 AM Shuai Wang <wangshuai...@gmail.com> wrote:

> Got it. But in that sense, given a `op1` satisfies the
> "is_gimple_addressable" predicate (e.g., the _17 in my sample code), how
> can I find its def statement? Thank you very much.
>
> Shuai
>
> On Tue, Jun 16, 2020 at 3:19 AM Richard Biener <richard.guent...@gmail.com>
> wrote:
>
>> On June 15, 2020 6:58:27 PM GMT+02:00, Shuai Wang <wangshuai...@gmail.com>
>> wrote:
>> >Thank you very much for your prompt response, Rchard. Sorry I was kinda
>> >"learning by doing". I am familiar with LLVM stuff but newbie to GCC
>> >specifications.
>> >
>> >Just want to make sure I got it right; _17 and _16 in the IR code are
>> >SSA
>> >variables. They are initialized for once and used once. Could you
>> >please
>> >shed some light on where "non-ssa name" comes in this scenario, and how
>> >exactly can I get  _17 = (signed char *) _16 printed out? Thank you
>> >very
>> >much.
>> >
>> >Best,
>> >Shuai
>> >
>> >On Tue, Jun 16, 2020 at 12:52 AM Richard Biener
>> ><richard.guent...@gmail.com>
>> >wrote:
>> >
>> >> On June 15, 2020 6:31:38 PM GMT+02:00, Shuai Wang via Gcc
>> ><gcc@gcc.gnu.org>
>> >> wrote:
>> >> >Hello,
>> >> >
>> >> >Suppose given the following SSA statement generated by the `sanopt`
>> >> >pass:
>> >> >
>> >> >   _17 = (signed char *) _16;
>> >> >   _18 = *_17;
>> >> >
>> >> >I am using the following code to identify that _17 depends on _16:
>> >> >
>> >> >// def_stmt refers to _18 = &_17;
>> >> >for (unsigned i = 1; i < gimple_num_ops(def_stmt); i++) {
>> >> >         op1 = gimple_assign_rhs1(def_stmt);
>>
>> op1 is not an SSA name here.
>>
>> >> >         if (is_gimple_addressable(op1))
>>
>> That predicate does not make sense on SSA names
>>
>>  {
>> >> >              gimple* def_stmt = SSA_NAME_DEF_STMT(op1);
>> >> >          print_gimple_stmt(stderr, def_stmt, 0, TDF_SLIM); // crash
>> >at
>> >> >this point
>> >> >         }
>> >> >
>> >> >It crashes with the following call stack:
>> >> >
>> >> >0xb5cd5f crash_signal
>> >> >        ../../gcc-10.1.0/gcc/toplev.c:328
>> >> >0x1452134 pp_format(pretty_printer*, text_info*)
>> >> >        ../../gcc-10.1.0/gcc/pretty-print.c:1828
>> >> >0x14533e4 pp_printf(pretty_printer*, char const*, ...)
>> >> >        ../../gcc-10.1.0/gcc/pretty-print.c:1773
>> >> >0x8dcc81 print_gimple_stmt(_IO_FILE*, gimple*, int, dump_flag)
>> >> >        ../../gcc-10.1.0/gcc/gimple-pretty-print.c:157
>> >> >
>> >> >I tried hard but just cannot understand why this would crash.
>> >Indeed,
>> >> >this
>> >> >code works pretty well when printing out other dependency
>> >statements,
>> >> >but
>> >> >just gets stuck in front of pointer dereference like _18 = *_17.
>> >> >
>> >> >Any suggestion would be appreciated. Thank you!
>> >>
>> >> Build your compiler with - - enable-checking and you'll figure you
>> >> reference SSA_NAME_DEF_STMT of a NON-SSA_NAME. I suggest you learn to
>> >use a
>> >> debugger.
>> >>
>> >> Richard.
>> >>
>> >> >Best,
>> >> >Shuai
>> >>
>> >>
>>
>>

Reply via email to