public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* ASSERT_EXPR during SIMPLE_IPA_PASS and LTO
@ 2022-03-01 14:36 Erick Ochoa
  2022-03-02  7:25 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Erick Ochoa @ 2022-03-01 14:36 UTC (permalink / raw)
  To: gcc

Hi,

I am working on an analysis that is able to determine some static
information about a specific variable. At the moment, I would like to avoid
much of the transformation by taking advantage of other GCC's passes. So, I
can imagine something like, create an ASSERT_EXPR and let other passes
change the CFG, and remove dead code, fold constants, etc.

At the moment I am only prototyping it, and so I have created a
SIMPLE_IPA_PASS during LTO that finds the variables of interest and then
creates an ASSERT_EXPR which contains the static information of interest.

This looks to be working somewhat correctly. When I print the functions'
gimple everything looks ok. The pass doesn't fail even if I use the
TODO_verify_all flag at the end of the SIMPLE_IPA_PASS. However, the
transformation triggers a segfault during fixup_cfg and I am unsure what
can be the case.

My questions are:
1. Is it possible to insert new ASSERT_EXPR during LTO and have other tree
passes transform the function based on this?
2. How complex can the ASSERT_EXPR be? I can see that it must be a COND
expr, by which it can be EQ_EXPR, NE_EXPR, LT_EXPR... and others. But what
if I need to express something like a bitmask to guarantee that certain
bits are zero? Could I have a complicated ASSERT_EXPR where COND is
ASSERT_EXPR (a & 0xff == 0)?
Or should I break it down?
temp = a & 0xff;
ASSERT_EXPR (temp == 0);
3. Any other advice?

Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ASSERT_EXPR during SIMPLE_IPA_PASS and LTO
  2022-03-01 14:36 ASSERT_EXPR during SIMPLE_IPA_PASS and LTO Erick Ochoa
@ 2022-03-02  7:25 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-03-02  7:25 UTC (permalink / raw)
  To: Erick Ochoa; +Cc: GCC Development

On Tue, Mar 1, 2022 at 3:37 PM Erick Ochoa via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi,
>
> I am working on an analysis that is able to determine some static
> information about a specific variable. At the moment, I would like to avoid
> much of the transformation by taking advantage of other GCC's passes. So, I
> can imagine something like, create an ASSERT_EXPR and let other passes
> change the CFG, and remove dead code, fold constants, etc.
>
> At the moment I am only prototyping it, and so I have created a
> SIMPLE_IPA_PASS during LTO that finds the variables of interest and then
> creates an ASSERT_EXPR which contains the static information of interest.
>
> This looks to be working somewhat correctly. When I print the functions'
> gimple everything looks ok. The pass doesn't fail even if I use the
> TODO_verify_all flag at the end of the SIMPLE_IPA_PASS. However, the
> transformation triggers a segfault during fixup_cfg and I am unsure what
> can be the case.
>
> My questions are:
> 1. Is it possible to insert new ASSERT_EXPR during LTO and have other tree
> passes transform the function based on this?

ASSERT_EXPR is something only used internally by the VRP pass, it cannot
be used elsewhere and is not expected by most of the compiler.

> 2. How complex can the ASSERT_EXPR be? I can see that it must be a COND
> expr, by which it can be EQ_EXPR, NE_EXPR, LT_EXPR... and others. But what
> if I need to express something like a bitmask to guarantee that certain
> bits are zero? Could I have a complicated ASSERT_EXPR where COND is
> ASSERT_EXPR (a & 0xff == 0)?
> Or should I break it down?
> temp = a & 0xff;
> ASSERT_EXPR (temp == 0);
> 3. Any other advice?
>
> Thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-02  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 14:36 ASSERT_EXPR during SIMPLE_IPA_PASS and LTO Erick Ochoa
2022-03-02  7:25 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).