[PATCH] Merging BB and user labels (tree level)

Jeffrey A Law law@redhat.com
Wed Dec 29 20:59:00 GMT 2004


On Thu, 2004-12-16 at 23:46 -0500, Andrew Pinski wrote:
> I was looking at some fortran code and I noticed that we were merging
> some Basic Blocks because it included an user label.  I noted that on 
> the
> rtl level we merge the BBs and just move the user label to the beginning
> of the BB we are merging into.
> 
> To get the "correct" output at -O0, I just enabled this when optimizing.
> 
> OK? Bootstrapped and tested on powerpc-darwin with no regressions.
> 
> Also checked to make sure at -O0, we don't merge basic blocks with user
> labels.
> 
> I don't know if this is unsuitable for 4.0, but it should help compile
> time and also code generation but I have not tested it on SPEC because
> I don't have access to it.
> 
> Thanks,
> Andrew Pinski
> 
> ChangeLog:
> 	* tree-cfg.c (tree_can_merge_blocks_p): Before checking if we have
> 	an user label in the second basic block, return true if we are
> 	optimizing.
> 	(tree_merge_blocks): Move user labels from the second basic block
> 	to the first basic block.
As much as I'd like to move forward with this patch, I think it is
broken.

Consider an unreferenced user label.

Your code will move that unreferenced user label to the start of 
some earlier block.

The RTL code does not move the label.  The RTL code "merely" ignores the
label by turning it into a NOTE_INSN_DELETED_LABEL and leaving the note
in its original location.

The net result is a breakpoint on the user label will work as expected
before your patch and it will fail miserably after your patch.

You can see this effect with the following testcase:

#define XX0(a) lab##a: z++; blah (z);
#define XX1(a) XX0(a##0) XX0(a##1) XX0(a##2) XX0(a##3) XX0(a##4) XX0
(a##5) XX0(a##6) XX0(a##7) XX0(a##8) XX0(a##9)
#define XX2(a) XX1(a##0) XX1(a##1) XX1(a##2) XX1(a##3) XX1(a##4) XX1
(a##5) XX1(a##6) XX1(a##7) XX1(a##8) XX1(a##9)
#define XX3(a) XX2(a##0) XX2(a##1) XX2(a##2) XX2(a##3) XX2(a##4) XX2
(a##5) XX2(a##6) XX2(a##7) XX2(a##8) XX2(a##9)
int foo()
{
 int z = 0;
XX3(1)
c:
return z;
}

I don't know if GDB's testsuite has a testcase for this kind of thing,
but it probably should...

Jeff




More information about the Gcc-patches mailing list