Traversing gimple?

Georg-Johann Lay avr@gjlay.de
Mon Feb 20 14:44:00 GMT 2017


Hi, I'd like to traverse gimple statements and all operands therein
like VAR_DECLs.

For each basic_block, I am calling

walk_gimple_seq (bb_seq (bb), NULL, func_op, &wi);

but some part of the code is not traversed.  It's in a pass that
runs after all tree optimizations where -fdump-tree-optimized
reads:


;; Function foo2 (foo2)

foo2 (int x)
{
   static struct ptrs p = {.p1=&a, .p2=&b, .p3=&c};
   struct ptrs * iftmp.0;

<bb 2>:
   if (x_2(D) != 0)
     goto <bb 3>;
   else
     goto <bb 4>;

<bb 3>:

<bb 4>:
   # iftmp.0_1 = PHI <&p(3), 0B(2)>
   bar (iftmp.0_1); [tail call]
   return;

}


The callback is called for:

* gimple_cond in BB2 (operands x and 0).
* gimple_call (operands iftmp)
* gimple_return (no operands)

What I am after is p and its constructor, but the
setting of iftmp is skipped and hence p is never
traversed.

What does the trick so that I get all operands?

Is this only die to PHI nodes? Or are there other
nodes that might hide the operands when traversing?

Thanks,

Johann



More information about the Gcc-help mailing list