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!

Reply via email to