This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Merging BB and user labels (tree level)
- From: Jeffrey A Law <law at redhat dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 29 Dec 2004 13:59:38 -0700
- Subject: Re: [PATCH] Merging BB and user labels (tree level)
- Organization: Red Hat, Inc
- References: <90FAEF38-4FE6-11D9-A750-000A95D692F4@physics.uc.edu>
- Reply-to: law at redhat dot com
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