write the symbol table for function bodies
[oota-llvm.git] / utils / NewNightlyTest.pl
index 6101b0ab79e91519609afa9de540e66e0fbe9c09..1a3adbca663bf45e97d890139d80c87dab1aa79c 100755 (executable)
@@ -31,6 +31,7 @@ use Socket;
 #  -release         Build an LLVM Release version
 #  -release-asserts Build an LLVM ReleaseAsserts version
 #  -enable-llcbeta  Enable testing of beta features in llc.
+#  -enable-lli      Enable testing of lli (interpreter) features, default is off
 #  -disable-llc     Disable LLC tests in the nightly tester.
 #  -disable-jit     Disable JIT tests in the nightly tester.
 #  -disable-cbe     Disable C backend tests in the nightly tester.
@@ -44,6 +45,10 @@ use Socket;
 #  -gccpath         Path to gcc/g++ used to build LLVM
 #  -cvstag          Check out a specific CVS tag to build LLVM (useful for
 #                   testing release branches)
+#  -usesvn          Check code out from a subversion repository. With no
+#                   argument, use the standard repository. An argument specifies
+#                   the repository URL to use.
+#  -svnurl          Specify the SVN URL where LLVM can be found
 #  -target          Specify the target triplet
 #  -cflags          Next argument specifies that C compilation options that
 #                   override the default.
@@ -90,6 +95,8 @@ use Socket;
 #
 ##############################################################
 my $HOME       = $ENV{'HOME'};
+my $SVNURL     = $ENV{"SVNURL"};
+$SVNURL        = 'svn://anon@hlvm.org:3691/llvm.svn' unless $SVNURL;
 my $CVSRootDir = $ENV{'CVSROOT'};
 $CVSRootDir    = "/home/vadve/shared/PublicCVS" unless $CVSRootDir;
 my $BuildDir   = $ENV{'BUILDDIR'};
@@ -115,6 +122,7 @@ my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
 $CONFIGUREARGS="";
 $nickname="";
 $NOTEST=0;
+$USESVN=0;
 $NORUNNINGTESTS=0;
 $MAKECMD="make";
 $SUBMITSERVER = "llvm.org";
@@ -136,8 +144,11 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
                              "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release"; next;}
   if (/^-release-asserts$/){ $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1 ".
                              "DISABLE-ASSERTIONS=1 ".
-                             "OPTIMIZE_OPTION=-O2"; $BUILDTYPE="release-asserts"; next;}
+                             "OPTIMIZE_OPTION=-O2"; 
+                             $BUILDTYPE="release-asserts"; next;}
   if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
+  if (/^-enable-lli$/)     { $PROGTESTOPTS .= " ENABLE_LLI=1";
+                             $CONFIGUREARGS .= " --enable-lli"; next; } 
   if (/^-disable-llc$/)    { $PROGTESTOPTS .= " DISABLE_LLC=1";
                              $CONFIGUREARGS .= " --disable-llc_diffs"; next; } 
   if (/^-disable-jit$/)    { $PROGTESTOPTS .= " DISABLE_JIT=1";
@@ -159,6 +170,8 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   else                     { $GCCPATH=""; }
   if (/^-cvstag/)          { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; } 
   else                     { $CVSCOOPT="";}
+  if (/^-usesvn/)          { $USESVN = 1; }
+  if (/^-svnurl/)          { $SVNURL = $ARGV[0]; shift; next; }
   if (/^-target/)          { $CONFIGUREARGS .= " --target=$ARGV[0]"; 
                              shift; next; }
   if (/^-cflags/)          { $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; 
@@ -180,7 +193,12 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
 
 if ($ENV{'LLVMGCCDIR'}) {
   $CONFIGUREARGS .= " --with-llvmgccdir=" . $ENV{'LLVMGCCDIR'};
+  $LLVMGCCPATH = $ENV{'LLVMGCCDIR'};
 }
+else {
+  $LLVMGCCPATH = "";
+}
+
 if ($CONFIGUREARGS !~ /--disable-jit/) {
   $CONFIGUREARGS .= " --enable-jit";
 }
@@ -221,7 +239,7 @@ if ($BUILDTYPE ne "release" && $BUILDTYPE ne "release-asserts") {
 ##############################################################
 my $Prefix = "$WebDir/$DATE";
 my $BuildLog = "$Prefix-Build-Log.txt";
-my $CVSLog = "$Prefix-CVS-Log.txt";
+my $COLog = "$Prefix-CVS-Log.txt";
 my $OldenTestsLog = "$Prefix-Olden-tests.txt";
 my $SingleSourceLog = "$Prefix-SingleSource-ProgramTest.txt.gz";
 my $MultiSourceLog = "$Prefix-MultiSource-ProgramTest.txt.gz";
@@ -238,11 +256,15 @@ if (! -d $WebDir) {
 
 if ($VERBOSE) {
   print "INITIALIZED\n";
-  print "CVS Root = $CVSRootDir\n";
+  if ($USESVN) {
+    print "SVN URL  = $SVNURL\n";
+  } else {
+    print "CVS Root = $CVSRootDir\n";
+  }
+  print "COLog    = $COLog\n";
   print "BuildDir = $BuildDir\n";
   print "WebDir   = $WebDir\n";
   print "Prefix   = $Prefix\n";
-  print "CVSLog   = $CVSLog\n";
   print "BuildLog = $BuildLog\n";
 }
 
@@ -473,39 +495,48 @@ if (!$NOCHECKOUT) {
         print "Build directory exists! Removing it\n";
       }
       system "rm -rf $BuildDir";
-      mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
+      mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
     } else {
       if ( $VERBOSE ) {
         print "Build directory exists!\n";
       }
     }
   } else {
-    mkdir $BuildDir or die "Could not create CVS checkout directory $BuildDir!";
+    mkdir $BuildDir or die "Could not create checkout directory $BuildDir!";
   }
 }
-ChangeDir( $BuildDir, "CVS checkout directory" );
+ChangeDir( $BuildDir, "checkout directory" );
 
 
 ##############################################################
 #
-# Check out the llvm tree, saving CVS messages to the cvs log...
+# Check out the llvm tree, using either SVN or CVS 
 #
 ##############################################################
-my $CVSOPT = "";
-# Use compression if going over ssh.
-$CVSOPT = "-z3" 
-  if $CVSRootDir =~ /^:ext:/;
-my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
 if (!$NOCHECKOUT) {
   if ( $VERBOSE ) { 
     print "CHECKOUT STAGE:\n"; 
-    print "( time -p $CVSCMD llvm; cd llvm/projects ; $CVSCMD llvm-test ) " .
-          "> $CVSLog 2>&1\n";
   }
-  system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
-      "$CVSCMD llvm-test ) > $CVSLog 2>&1";
-  ChangeDir( $BuildDir , "CVS Checkout directory") ;
+  if ($USESVN) {
+    my $SVNCMD = "$NICE svn co $SVNURL";
+    if ($VERBOSE) {
+      print "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
+            "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
+      system "( time -p $SVNCMD/llvm/trunk llvm; cd llvm/projects ; " .
+            "$SVNCMD/llvm-test/trunk llvm-test ) > $COLog 2>&1\n";
+    }
+  } else {
+    my $CVSOPT = "";
+    $CVSOPT = "-z3" # Use compression if going over ssh.
+      if $CVSRootDir =~ /^:ext:/;
+    my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co -P $CVSCOOPT";
+    print "( time -p $CVSCMD llvm; cd llvm/projects ; " .
+          "$CVSCMD llvm-test ) > $COLog 2>&1\n";
+    system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
+          "$CVSCMD llvm-test ) > $COLog 2>&1\n";
+  }
 }
+ChangeDir( $BuildDir , "Checkout directory") ;
 ChangeDir( "llvm" , "llvm source directory") ;
 
 ##############################################################
@@ -515,14 +546,20 @@ ChangeDir( "llvm" , "llvm source directory") ;
 # This can probably be put on the server side
 #
 ##############################################################
-my $CVSCheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $CVSLog`;
-my $CVSCheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $CVSLog`;
-my $CVSCheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $CVSLog`;
-my $CVSCheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
-
-my $NumFilesInCVS = `egrep '^U' $CVSLog | wc -l` + 0;
-my $NumDirsInCVS  = 
-   `egrep '^cvs (checkout|server|update):' $CVSLog | wc -l` + 0;
+my $CheckoutTime_Wall = GetRegex "([0-9.]+)", `grep '^real' $COLog`;
+my $CheckoutTime_User = GetRegex "([0-9.]+)", `grep '^user' $COLog`;
+my $CheckoutTime_Sys = GetRegex "([0-9.]+)", `grep '^sys' $COLog`;
+my $CheckoutTime_CPU = $CVSCheckoutTime_User + $CVSCheckoutTime_Sys;
+
+my $NumFilesInCVS = 0;
+my $NumDirsInCVS  = 0;
+if ($USESVN) {
+  $NumFilesInCVS = `egrep '^A' $COLog | wc -l` + 0;
+  $NumDirsInCVS  = `sed -e 's#/[^/]*$##' $COLog | sort | uniq | wc -l` + 0;
+} else {
+  $NumFilesInCVS = `egrep '^U' $COLog | wc -l` + 0;
+  $NumDirsInCVS  = `egrep '^cvs (checkout|server|update):' $COLog | wc -l` + 0;
+}
 
 ##############################################################
 #
@@ -532,49 +569,112 @@ my $NumDirsInCVS  =
 #
 ##############################################################
 
-my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
-
-if(!$NOCVSSTATS){
-
-  if ($VERBOSE) { print "CVS HISTORY ANALYSIS STAGE\n"; }
-  @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
-#print join "\n", @CVSHistory; print "\n";
+# This just computes a reasonably accurate #of seconds since 2000. It doesn't
+# have to be perfect as its only used for comparing date ranges within a couple
+# of days.
+sub ConvertToSeconds {
+  my ($sec, $min, $hour, $day, $mon, $yr) = @_;
+  my $Result = ($yr - 2000) * 12;
+  $Result += $mon;
+  $Result *= 31;
+  $Result += $day;
+  $Result *= 24;
+  $Result += $hour;
+  $Result *= 60;
+  $Result += $min;
+  $Result *= 60;
+  $Result += $sec;
+  return $Result;
+}
 
-  my $DateRE = '[-/:0-9 ]+\+[0-9]+';
+my (%AddedFiles, %ModifiedFiles, %RemovedFiles, %UsersCommitted, %UsersUpdated);
 
-# Loop over every record from the CVS history, filling in the hashes.
-  foreach $File (@CVSHistory) {
-      my ($Type, $Date, $UID, $Rev, $Filename);
-      if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
-          ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
-      } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
-          ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
-      } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
-          ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
-      } else {
-          print "UNMATCHABLE: $File\n";
-          next;
+if (!$NOCVSSTATS) {
+  if ($VERBOSE) { print "CHANGE HISTORY ANALYSIS STAGE\n"; }
+
+  if ($USESVN) {
+    @SVNHistory = split /<logentry/, `svn log --xml --verbose -r{$DATE}:HEAD`;
+    # Skip very first entry because it is the XML header cruft
+    shift @SVNHistory;
+    my $Now = time();
+    foreach $Record (@SVNHistory) {
+      my @Lines = split "\n", $Record;
+      my ($Author, $Date, $Revision);
+      # Get the date and see if its one we want to process.
+      my ($Year, $Month, $Day, $Hour, $Min, $Sec);
+      if ($Lines[3] =~ /<date>(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/){
+        $Year = $1; $Month = $2; $Day = $3; $Hour = $4; $Min = $5; $Sec = $6;
       }
-      # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
-      
-      if ($Filename =~ /^llvm/) {
-          if ($Type eq 'M') {        # Modified
-              $ModifiedFiles{$Filename} = 1;
-              $UsersCommitted{$UID} = 1;
-          } elsif ($Type eq 'A') {   # Added
-              $AddedFiles{$Filename} = 1;
-              $UsersCommitted{$UID} = 1;
-          } elsif ($Type eq 'R') {   # Removed
-              $RemovedFiles{$Filename} = 1;
-              $UsersCommitted{$UID} = 1;
+      my $Then = ConvertToSeconds($Sec, $Min, $Hour, $Day, $Month, $Year);
+      # Get the current date and compute when "yesterday" is.
+      my ($NSec, $NMin, $NHour, $NDay, $NMon, $NYear) = gmtime();
+      my $Now = ConvertToSeconds( $NSec, $NMin, $NHour, $NDay, $NMon, $NYear);
+      if (($Now - 24*60*60) > $Then) {
+        next;
+      }
+      if ($Lines[1] =~ /   revision="([0-9]*)">/) {
+        $Revision = $1;
+      }
+      if ($Lines[2] =~ /<author>([^<]*)<\/author>/) {
+        $Author = $1;
+      }
+      $UsersCommitted{$Author} = 1;
+      $Date = $Year . "-" . $Month . "-" . $Day;
+      $Time = $Hour . ":" . $Min . ":" . $Sec;
+      print "Rev: $Revision, Author: $Author, Date: $Date, Time: $Time\n";
+      for ($i = 6; $i < $#Lines; $i += 2 ) {
+        if ($Lines[$i] =~ /^   action="(.)">([^<]*)</) {
+          if ($1 == "A") {
+            $AddedFiles{$2} = 1;
+          } elsif ($1 == 'D') {
+            $RemovedFiles{$2} = 1;
+          } elsif ($1 == 'M' || $1 == 'R' || $1 == 'C') {
+            $ModifiedFiles{$2} = 1;
           } else {
-              $UsersUpdated{$UID} = 1;
+            print "UNMATCHABLE: $Lines[$i]\n";
           }
+        }
       }
-  }
+    }
+  } else {
+    @CVSHistory = split "\n", `cvs history -D '1 day ago' -a -xAMROCGUW`;
+#print join "\n", @CVSHistory; print "\n";
 
-  my $TestError = 1;
+    my $DateRE = '[-/:0-9 ]+\+[0-9]+';
 
+# Loop over every record from the CVS history, filling in the hashes.
+    foreach $File (@CVSHistory) {
+        my ($Type, $Date, $UID, $Rev, $Filename);
+        if ($File =~ /([AMRUGC]) ($DateRE) ([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+)/) {
+            ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, $4, "$6/$5");
+        } elsif ($File =~ /([W]) ($DateRE) ([^ ]+)/) {
+            ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "");
+        } elsif ($File =~ /([O]) ($DateRE) ([^ ]+) +([^ ]+)/) {
+            ($Type, $Date, $UID, $Rev, $Filename) = ($1, $2, $3, "", "$4/");
+        } else {
+            print "UNMATCHABLE: $File\n";
+            next;
+        }
+        # print "$File\nTy = $Type Date = '$Date' UID=$UID Rev=$Rev File = '$Filename'\n";
+        
+        if ($Filename =~ /^llvm/) {
+            if ($Type eq 'M') {        # Modified
+                $ModifiedFiles{$Filename} = 1;
+                $UsersCommitted{$UID} = 1;
+            } elsif ($Type eq 'A') {   # Added
+                $AddedFiles{$Filename} = 1;
+                $UsersCommitted{$UID} = 1;
+            } elsif ($Type eq 'R') {   # Removed
+                $RemovedFiles{$Filename} = 1;
+                $UsersCommitted{$UID} = 1;
+            } else {
+                $UsersUpdated{$UID} = 1;
+            }
+        }
+    }
+
+    my $TestError = 1;
+  } #$USESVN
 }#!NOCVSSTATS
 
 my $CVSAddedFiles = join "\n", sort keys %AddedFiles;
@@ -940,7 +1040,7 @@ $machine_data = "uname: ".`uname -a`.
 
 my @CVS_DATA;
 my $cvs_data;
-@CVS_DATA = ReadFile "$CVSLog";
+@CVS_DATA = ReadFile "$COLog";
 $cvs_data = join("\n", @CVS_DATA);
 
 my @BUILD_DATA;
@@ -955,12 +1055,25 @@ my ($gcc_version, $gcc_version_long) = "";
 $gcc_version_long="";
 if ($GCCPATH ne "") {
        $gcc_version_long = `$GCCPATH/gcc --version`;
+} elsif ($ENV{"CC"}) {
+       $gcc_version_long = `$ENV{"CC"} --version`;
 } else {
        $gcc_version_long = `gcc --version`;
 }
 @GCC_VERSION = split '\n', $gcc_version_long;
 $gcc_version = $GCC_VERSION[0];
 
+$llvmgcc_version_long="";
+if ($LLVMGCCPATH ne "") {
+  $llvmgcc_version_long = `$LLVMGCCPATH/llvm-gcc -v 2>&1`;
+} else {
+  $llvmgcc_version_long = `llvm-gcc -v 2>&1`;
+}
+@LLVMGCC_VERSION = split '\n', $llvmgcc_version_long;
+$llvmgcc_versionTarget = $LLVMGCC_VERSION[1];
+$llvmgcc_versionTarget =~ /Target: (.+)/;
+$targetTriple = $1;
+
 if(!$BuildError){
   @DEJAGNU_LOG = ReadFile "$DejagnuLog";
   @DEJAGNU_SUM = ReadFile "$DejagnuSum";
@@ -986,8 +1099,8 @@ my %hash_of_data = (
   'nickname' => $nickname,
   'dejagnutime_wall' => $DejagnuWallTime,
   'dejagnutime_cpu' => $DejagnuTime,
-  'cvscheckouttime_wall' => $CVSCheckoutTime_Wall,
-  'cvscheckouttime_cpu' => $CVSCheckoutTime_CPU,
+  'cvscheckouttime_wall' => $CheckoutTime_Wall,
+  'cvscheckouttime_cpu' => $CheckoutTime_CPU,
   'configtime_wall' => $ConfigWallTime,
   'configtime_cpu'=> $ConfigTime,
   'buildtime_wall' => $BuildWallTime,
@@ -1019,7 +1132,8 @@ my %hash_of_data = (
   'starttime' => $starttime,
   'endtime' => $endtime,
   'o_file_sizes' => $o_file_sizes,
-  'a_file_sizes' => $a_file_sizes
+  'a_file_sizes' => $a_file_sizes,
+  'target_triple' => $targetTriple
 );
 
 $TESTING = 0;