Yeah, I agree with you that it makes the pass looks confusing that if we are
mixing FOR_EACH_BB and for (const bb_info *bb...
But Jeff feels happy if I use FOR_EACH_BB so I send a patch to change the
iterator form if it doesn't care about the order.
In this patch, it's ok for both FOR_EACH_BB and for (const bb_info *bb... So I
change it as Jeff suggested.
However, in other places of this pass, for example
compute_global_backward_infos function, I want to iterate blocks in reverse
order and I must use
"for (const bb_info *bb : crtl->ssa->reverse_bbs ())" which can allow me to do
the information backward propagation throughly
so that I can do the aggressive and fancy optimization.
Base on these situations, it will be mixing FOR_EACH_BB and for (const bb_info
*bb... in this pass which may make the pass
a little bit confusing.
juzhe.zh...@rivai.ai
From: Richard Sandiford
Date: 2022-12-28 19:47
To: Jeff Law via Gcc-patches
CC: juzhe.zhong; Jeff Law; kito.cheng\@gmail.com; palmer\@dabbelt.com
Subject: Re: [PATCH] RISC-V: Fix ICE of visiting non-existing block in CFG.
Jeff Law via Gcc-patches writes:
> On 12/27/22 16:11, juzhe.zhong wrote:
>> You mean only change to this form you suggested in this patch? Since in
>> all other places of this PASS,I use RTL_SSA framework to iterate
>> instructions and blocks. I use RTL_SSA framework to iterate blocks here
>> to make codes look more consistent even though they are same here.
> The FOR_EACH_BB is used far more widely than the C++ style found in
> RTL-SSA so I'd slightly prefer that style.
I can see where you're coming from, but what the patch does is preferred
for RTL-SSA passes. There is some additional information in
rtl_ssa::bb_info compared to the underlying basic_block, and even if
this particular loop doesn't use that information, IMO it would be
better to avoid mixing styles within a pass.
Also, the list that the patch iterates over is in reverse postorder,
whereas FOR_EACH_BB doesn't guarantee a particular order. Again,
that might not be important here, but it seems better to stick to the
“native” RTL-SSA approach.
Thanks,
Richard