[tree-ssa] Gimplifying Java

Jeff Sturm jsturm@one-point.com
Thu Jun 12 19:25:00 GMT 2003


On 12 Jun 2003, Andrew MacLeod wrote:
> Give this a quick try first. I quickly cobbled it together, Im not sure
> if the diagnostic is in the right place for java or not, but I added
> support for SSAA_NAMe in debug output format %d, and now when there is a
> live on entry variable that also has a defintion, or a live-on-entry
> variable which is not a parameter, it spits out a warning telling you
> what the variable is.

Hmm... the warning didn't trigger for me.

> Try it and take a look at what, if anything, it says your variable is,
> and check the code coming out of the .dce pass to see what, if anything,
> appears to be wrong.

Looking at dce, for fileName, I have:

Marking useful stmt: return fileName_1;

Processing worklist:
processing: return fileName_1;
Marking useful stmt: fileName_1 = PHI <file_8(2), T.7_22(5), T.7_22(9),
T.7_22(10), T.7_22(11)>;
processing: fileName_1 = PHI <file_8(2), T.7_22(5), T.7_22(9), T.7_22(10),
T.7_22(11)>;
...
Eliminating unnecessary instructions:
Deleting : fileName_9 = file_8

So here's where the initial assignment is dropped.  Because it is
redundant with the PHI node, right?  (Or am I confused?)  How does the PHI
node then get expanded with:

Inserting a copy on edge BB11->BB12 :fileName = T.7
Inserting a copy on edge BB10->BB12 :fileName = T.7
Inserting a copy on edge BB9->BB12 :fileName = T.7
Inserting a copy on edge BB5->BB12 :fileName = T.7
Inserting a copy on edge BB2->BB12 :fileName = file

to:

                  fileName = T.7	// BB11->BB12
                }
              }
          }
      }
    else
      {
        fileName = file			// BB2->BB12
      };

    # BLOCK 12
    fileName = T.7;			// ???
    fileName = T.7;			// ???
    fileName = T.7;			// ???
    return fileName;

(Comments are mine.)  There are three copies clearly inserted into the
wrong place.  Oh wait... the CFG is wrong after all!  Block 5 has no edge
to 12, though it is marked as such:

          # BLOCK 5 (NameFinder.java:6).  PRED: 3.  SUCC: 12 6.
          colon.5 = colon;
          substring.6 = (java.lang.String:: *)substring;
          T.7 = substring.6 (file.4, 0, colon.5);
          fileName = T.7;
          try
            {

              # BLOCK 6 (NameFinder.java:18).  PRED: 5.  SUCC: 8 7.

Similar for BB10->BB12.  BB9->BB12 looks like a valid edge, but it is
also within the try/catch block.  So now I know where to look...

Can't say SSA is at fault here, except better diagnostics would sure be
nice. :)

Jeff



More information about the Gcc-patches mailing list