Help about plugins - GIMPLE_COND

Pierrick Philippe pierrick.philippe@irisa.fr
Mon Jan 30 13:42:04 GMT 2023


Hi everyone,

I'm playing around on GCC version 11.3 (build Ubuntu), with plugins and 
passes running on GCC IL, |GIMPLE| in its SSA form to be precise.
But I face an issue with |GIMPLE_COND| statement.

Here is my example statement (output from |debug_gimple_stmt()|):

|if (a_3 == x.0_1) |

Here is the basic bloc containing the statement (dump from 
|gimple_debug_bb()|):

|;; basic block 2, loop depth 0 ;; pred: ENTRY a_3 = 5; # VUSE 
<.MEM_4(D)> x.0_1 = x; if (a_3 == x.0_1) goto <bb 3>; [INV] else goto 
<bb 4>; [INV] ;; succ: 3 ;; 4 |

So, things I'm having trouble with is that when I'm calling 
|gimple_cond_{true,false}_label()| on the |GIMPLE_COND| statement 
(casted through |as_a<gcond*>()|), I get a null pointer for both of 
them, and I do not understand why.

My first intuition is that here |goto|s is not branching on any label 
but on basic bloc directly somehow explain it.
I have been told to use extract_true_false_edges_from_block(), and it do 
works.
Though this is not really what I was expecting as I get an edge and not 
a tree nor a gimple *.
By the way, extract_true_false_edges_from_block() is not mention inside 
the internal documentation, whereas gimple_cond_{true,false}_label() is.

Anyway, my question is regarding the gimple_cond_{true,false}_label() 
function.
I can't find any use case where this function is not returning nullptr, 
so what could be its typical use(s) case(s)?

Cheers,

Pierrick Philippe


More information about the Gcc-help mailing list