This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Gimplifying Java


On 11 Jun 2003, Andrew MacLeod wrote:
> Yes, a testcase would be most excellent.

You'll need a patched gcj, I don't have a C/C++ example.

public class NameFinder {
  private String createStackTraceElement(String file) {
    String fileName = file;
    int colon = file.lastIndexOf(':');
    if (colon > 0) {
            fileName = file.substring(0, colon);
            try {
                Integer.parseInt(file.substring(colon+1));
            } catch (NumberFormatException nfe) { }
    }
    return fileName;
  }
}

The GIMPLE tree looks OK to me, fileName is initialized before the
COND_EXPR and later from an initialized temporary:

  struct java.lang.String * fileName;

  fileName = file;
  {
    if (colon > 0)
      {
        ...
        {
          ...
          T.7 = substring.6 (file.4, 0, colon.5);
          fileName = T.7;
          ...
        }
      };
    return fileName;
  }

The -fdump-tree-optimized output then goes awry.  The initial assignment
moves to the else block.  But if "else" is taken, T.7 is unitialized, and
the replacement of phi nodes assigns fileName from T.7 after the
COND_EXPR:

  struct java.lang.String * T.7;
  struct java.lang.String * fileName;

    ...
    if (T.3 > 0)
      {
        ...
        T.7 = substring.6 (file, 0, T.3);
        try
          {
            ...
          }
        catch
          {
            catch (struct java.lang.NumberFormatException)
              {
                  ...
                  fileName = T.7
              }
          }
      }
    else
      {
        fileName = file
      };
    fileName = T.7;
    fileName = T.7;
    fileName = T.7;
    return fileName;

If you want the entire dumps I'll send them off-list.

Thanks,

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]