This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Crash in remove_stmt_from_en_lp_fn() due to remving of gimple statement using gsi_remove
- From: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- To: Shubham Narlawar <gsocshubham at gmail dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Sat, 16 Nov 2019 13:49:53 +0530
- Subject: Re: Crash in remove_stmt_from_en_lp_fn() due to remving of gimple statement using gsi_remove
- References: <CAN=hqDB7H2RiD3OmTWJORENT_=Hmw-z3Ge+4orKPKCUSHiS1NA@mail.gmail.com>
On Sat, 16 Nov 2019 at 11:28, Shubham Narlawar <gsocshubham@gmail.com> wrote:
>
> Hello,
>
> I'm writing a Simple LTO pass. I have placed my optimization routine under
> execute() hook. In my optimization routine, I want to delete an
> instruction for which I have the gimple_stmt_iterator. If I call
> gsi_remove(gsi, true), it causes a crash in remove_stmt_from_en_lp_fn()
> where it is expecting cfun and cfun is NULL.
I assume you mean simple_ipa_opt_pass ?
Maybe try calling push_cfun with appropriate function, to provide cfun
context before calling gsi_remove
(and pop_cfun after you're done).
Thanks,
Prathamesh
>
> If I call gsi_remove(gsi, false), it goes through fine but at final link
> stage it shows undefined reference to a certain function. It looks like
> the entire function vanished. And the instruction I tried to delete was
> not even a part of that function.
>
> Do I need to call update_ssa() after I delete the instruction using
> gsi_remove(gsi, false)?
>
> Is there a simple manner in which I can delete the instruction without
> having to go through writing the full blown LTO pass with
> serializers/deserializers and the like?
>
> Thanks
>
> Shubham