Bugfixes for smallvector when the element size is small and N is small.
[oota-llvm.git] / utils / NightlyTest.pl
index 0c99c6248f3056077f3c6faf7e370a1dc7cc97e4..270753c21fc66dc2239caf7607d10eb77bb0fc5c 100755 (executable)
 #                   -norunningtests.
 #  -norunningtests  Do not run the Olden benchmark suite with
 #                   LARGE_PROBLEM_SIZE enabled.
-#  -noexternals     Do not run the external tests (for cases where povray
-#                   or SPEC are not installed)
 #  -nodejagnu       Do not run feature or regression tests
 #  -parallel        Run two parallel jobs with GNU Make.
 #  -release         Build an LLVM Release version
-#  -pedantic        Enable additional GCC warnings to detect possible errors.
-#  -enable-linscan  Enable linearscan tests
+#  -enable-llcbeta  Enable testing of beta features in llc.
 #  -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.
 #  -verbose         Turn on some debug output
 #  -debug           Print information useful only to maintainers of this script.
 #  -nice            Checkout/Configure/Build with "nice" to reduce impact 
 #  -gnuplotscript   Next argument specifies gnuplot script to use
 #  -templatefile    Next argument specifies template file to use
 #  -gccpath         Path to gcc/g++ used to build LLVM
+#  -cvstag          Check out a specific CVS tag to build LLVM (useful for
+#                   testing release branches)
+#  -target          Specify the target triplet
+#  -cflags          Next argument specifies that C compilation options that
+#                   override the default.
+#  -cxxflags        Next argument specifies that C++ compilation options that
+#                   override the default.
+#  -ldflags         Next argument specifies that linker options that override
+#                   the default.
+#  -compileflags    Next argument specifies extra options passed to make when
+#                   building LLVM.
+#
+#  ---------------- Options to configure llvm-test ----------------------------
+#  -extraflags      Next argument specifies extra options that are passed to
+#                   compile the tests.
+#  -noexternals     Do not run the external tests (for cases where povray
+#                   or SPEC are not installed)
+#  -with-externals  Specify a directory where the external tests are located.
 #
 # CVSROOT is the CVS repository from which the tree will be checked out,
 #  specified either in the full :method:user@host:/dir syntax, or
@@ -66,7 +82,7 @@ my $WebDir     = $ENV{'WEBDIR'};
 @TIME = localtime;
 my $DATE = sprintf "%4d-%02d-%02d", $TIME[5]+1900, $TIME[4]+1, $TIME[3];
 my $DateString = strftime "%B %d, %Y", localtime;
-my $TestStartTime = gmtime;
+my $TestStartTime = gmtime() . "GMT<br>" . localtime() . " (local)";
 
 # Command line argument settings...
 my $NOCHECKOUT = 0;
@@ -79,6 +95,7 @@ my $PROGTESTOPTS = "";
 my $VERBOSE = 0;
 my $DEBUG = 0;
 my $CONFIGUREARGS = "";
+my $CVSCOOPT = "-APR";
 my $NICE = "";
 my $NODEJAGNU = 0;
 
@@ -134,7 +151,21 @@ sub AddRecord {
 
 sub AddPreTag {  # Add pre tags around nonempty list, or convert to "none"
   $_ = shift;
-  if (length) { return "<ul><pre>$_</pre></ul>"; } else { "<b>none</b><br>"; }
+  if (length) { return "<pre>$_</pre>"; } else { "<b>none</b><br>"; }
+}
+
+sub ArrayToList { # Add <li> tags around nonempty list or convert to "none"
+  my $result = "";
+  if (scalar @_) {
+    $result = "<ul>";
+    foreach $item (@_) {
+      $result .= "<li><tt>$item</tt></li>";
+    }
+    $result .= "</ul>";
+  } else {
+    $result = "<p><b>none</b></p>";
+  }
+  return $result;
 }
 
 sub ChangeDir { # directory, logical name
@@ -198,9 +229,11 @@ sub GetDejagnuTestResults { # (filename, log)
   my @lines;
   my $firstline;
   $/ = "\n"; #Make sure we're going line at a time.
+
+  print "DEJAGNU TEST RESULTS:\n";
+
   if (open SRCHFILE, $filename) {
     # Process test results
-    push(@lines,"<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
     my $first_list = 1;
     my $should_break = 1;
     my $nocopy = 0;
@@ -211,20 +244,30 @@ sub GetDejagnuTestResults { # (filename, log)
         if ( m/^XPASS:/ || m/^FAIL:/ ) {
           $nocopy = 0;
           if ( $first_list ) {
+            push(@lines, "<h3>UNEXPECTED TEST RESULTS</h3><ol><li>\n");
             $first_list = 0;
             $should_break = 1;
-            push(@lines,"<b>$_</b><br/>\n");
+            push(@lines, "<b>$_</b><br/>\n");
+            print "  $_\n";
           } else {
-            push(@lines,"</li><li><b>$_</b><br/>\n");
+            push(@lines, "</li><li><b>$_</b><br/>\n");
+            print "  $_\n";
           }
         } elsif ( m/Summary/ ) {
-          if ( $first_list ) { push(@lines,"<b>PERFECT!</b>"); }
-          push(@lines,"</li></ol><h3>STATISTICS</h3><pre>\n");
+          if ( $first_list ) {
+            push(@lines, "<b>PERFECT!</b>"); 
+            print "  PERFECT!\n";
+          } else {
+            push(@lines, "</li></ol>\n");
+          }
+          push(@lines, "<h3>STATISTICS</h3><pre>\n");
+          print "\nDEJAGNU STATISTICS:\n";
           $should_break = 0;
           $nocopy = 0;
           $readingsum = 1;
         } elsif ( $readingsum ) {
           push(@lines,"$_\n");
+          print "  $_\n";
         }
       }
     }
@@ -232,7 +275,7 @@ sub GetDejagnuTestResults { # (filename, log)
   push(@lines, "</pre>\n");
   close SRCHFILE;
 
-  my $content = join("",@lines);
+  my $content = join("", @lines);
   return "$content</li></ol>\n";
 }
 
@@ -256,29 +299,47 @@ while (scalar(@ARGV) and ($_ = $ARGV[0], /^[-+]/)) {
   if (/^-norunningtests$/) { $NORUNNINGTESTS = 1; next; }
   if (/^-parallel$/)       { $MAKEOPTS = "$MAKEOPTS -j2 -l3.0"; next; }
   if (/^-release$/)        { $MAKEOPTS = "$MAKEOPTS ENABLE_OPTIMIZED=1"; next; }
-  if (/^-pedantic$/)       { 
-      $MAKEOPTS   = "$MAKEOPTS CompileOptimizeOpts='-O3 -DNDEBUG -finline-functions -Wpointer-arith -Wcast-align -Wno-deprecated -Wold-style-cast -Wabi -Woverloaded-virtual -ffor-scope'"; 
-      next; 
-  }
-  if (/^-enable-linscan$/) { $PROGTESTOPTS .= " ENABLE_LINEARSCAN=1"; next; }
+  if (/^-enable-llcbeta$/) { $PROGTESTOPTS .= " ENABLE_LLCBETA=1"; next; }
   if (/^-disable-llc$/)    { $PROGTESTOPTS .= " DISABLE_LLC=1";
                              $CONFIGUREARGS .= " --disable-llc_diffs"; next; }
   if (/^-disable-jit$/)    { $PROGTESTOPTS .= " DISABLE_JIT=1";
                              $CONFIGUREARGS .= " --disable-jit"; next; }
+  if (/^-disable-cbe$/)    { $PROGTESTOPTS .= " DISABLE_CBE=1"; next; }
   if (/^-verbose$/)        { $VERBOSE = 1; next; }
   if (/^-debug$/)          { $DEBUG = 1; next; }
   if (/^-nice$/)           { $NICE = "nice "; next; }
   if (/^-f2c$/)            {
     $CONFIGUREARGS .= " --with-f2c=$ARGV[0]"; shift; next;
   }
+  if (/^-with-externals/)  { 
+    $CONFIGUREARGS .= " --with-externals=$ARGV[0]"; shift; next 
+  }
   if (/^-gnuplotscript$/)  { $PlotScriptFilename = $ARGV[0]; shift; next; }
   if (/^-templatefile$/)   { $Template = $ARGV[0]; shift; next; }
   if (/^-gccpath/)         { 
     $CONFIGUREARGS .= " CC=$ARGV[0]/gcc CXX=$ARGV[0]/g++"; shift; next; 
   }
+  if (/^-cvstag/)          { $CVSCOOPT .= " -r $ARGV[0]"; shift; next; }
+  if (/^-target/)          {
+    $CONFIGUREARGS .= " --target=$ARGV[0]"; shift; next;
+  }
+  if (/^-cflags/)          {
+    $MAKEOPTS = "$MAKEOPTS C.Flags=\'$ARGV[0]\'"; shift; next;
+  }
+  if (/^-cxxflags/)        {
+    $MAKEOPTS = "$MAKEOPTS CXX.Flags=\'$ARGV[0]\'"; shift; next;
+  }
+  if (/^-ldflags/)         {
+    $MAKEOPTS = "$MAKEOPTS LD.Flags=\'$ARGV[0]\'"; shift; next;
+  }
+  if (/^-compileflags/)    {
+    $MAKEOPTS = "$MAKEOPTS $ARGV[0]"; shift; next;
+  }
+  if (/^-extraflags/)      {
+    $CONFIGUREARGS .= " --with-extra-options=\'$ARGV[0]\'"; shift; next;
+  }
   if (/^-noexternals$/)    { $NOEXTERNALS = 1; next; }
-  if(/^-nodejagnu$/) { $NODEJAGNU = 1; next; }
-
+  if (/^-nodejagnu$/)      { $NODEJAGNU = 1; next; }
   print "Unknown option: $_ : ignoring!\n";
 }
 
@@ -345,12 +406,14 @@ ChangeDir( $BuildDir, "CVS checkout directory" );
 #
 # Check out the llvm tree, saving CVS messages to the cvs log...
 #
-$CVSOPT = "";
-$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/; # Use compression if going over ssh.
+my $CVSOPT = "";
+# Use compression if going over ssh.
+$CVSOPT = "-z3" if $CVSRootDir =~ /^:ext:/;
+my $CVSCMD = "$NICE cvs $CVSOPT -d $CVSRootDir co $CVSCOOPT";
 if (!$NOCHECKOUT) {
   if ( $VERBOSE ) { print "CHECKOUT STAGE\n"; }
-  system "( time -p $NICE cvs $CVSOPT -d $CVSRootDir co -APR llvm; cd llvm/projects ; " .
-     "$NICE cvs $CVSOPT -d $CVSRootDir co -APR llvm-test ) > $CVSLog 2>&1";
+  system "( time -p $CVSCMD llvm; cd llvm/projects ; " .
+     "$CVSCMD llvm-test ) > $CVSLog 2>&1";
   ChangeDir( $BuildDir , "CVS Checkout directory") ;
 }
 
@@ -388,7 +451,8 @@ $LOC = `utils/countloc.sh`;
 #
 if (!$NOCHECKOUT) {
   if ( $VERBOSE ) { print "CONFIGURE STAGE\n"; }
-  system "(time -p $NICE ./configure $CONFIGUREARGS --enable-spec --with-objroot=.) > $BuildLog 2>&1";
+  my $EXTRAFLAGS = "--enable-spec --with-objroot=.";
+  system "(time -p $NICE ./configure $CONFIGUREARGS $EXTRAFLAGS) > $BuildLog 2>&1";
 
   if ( $VERBOSE ) { print "BUILD STAGE\n"; }
   # Build the entire tree, capturing the output into $BuildLog
@@ -402,7 +466,7 @@ if (!$NOCHECKOUT) {
 my @Linked = split '\n', `grep Linking $BuildLog`;
 my $NumExecutables = scalar(grep(/executable/, @Linked));
 my $NumLibraries   = scalar(grep(!/executable/, @Linked));
-my $NumObjects     = `grep '^Compiling' $BuildLog | wc -l` + 0;
+my $NumObjects     = `grep ']\: Compiling ' $BuildLog | wc -l` + 0;
 
 my $ConfigTimeU = GetRegexNum "^user", 0, "([0-9.]+)", "$BuildLog";
 my $ConfigTimeS = GetRegexNum "^sys", 0, "([0-9.]+)", "$BuildLog";
@@ -414,12 +478,13 @@ my $BuildTimeS = GetRegexNum "^sys", 1, "([0-9.]+)", "$BuildLog";
 my $BuildTime  = $BuildTimeU+$BuildTimeS;  # BuildTime = User+System
 my $BuildWallTime = GetRegexNum "^real", 1, "([0-9.]+)","$BuildLog";
 
-my $BuildError = "";
+my $BuildError = 0, $BuildStatus = "OK";
 if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
     `grep '^gmake: \*\*\*.*Stop.' $BuildLog | wc -l`+0) {
-  $BuildError = "<h3><font color='red'>Build error: compilation " .
+  $BuildStatus = "<h3><font color='red'>error: compilation " .
                 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
-  if ($VERBOSE) { print "BUILD ERROR\n"; }
+  $BuildError = 1;
+  print "\n***ERROR BUILDING TREE\n\n";
 }
 
 if ($BuildError) { $NODEJAGNU=1; }
@@ -445,7 +510,6 @@ if(!$NODEJAGNU) {
   CopyFile("test/testrun.sum", $DejagnuSum);
 
   $DejagnuTestResults = GetDejagnuTestResults($DejagnuSum, $DejagnuLog);
-  print $DejagnuTestResults;
 
 } else {
   $DejagnuTestResults = "Skipped by user choice.";
@@ -476,7 +540,7 @@ foreach $Warning (@Warn) {
   }
 }
 my $WarningsFile =  join "\n", @Warnings;
-my $WarningsList = AddPreTag $WarningsFile;
+my $WarningsList = ArrayToList @Warnings;
 $WarningsFile =~ s/:[0-9]+:/::/g;
 
 # Emit the warnings file, so we can diff...
@@ -487,8 +551,10 @@ my ($WarningsAdded, $WarningsRemoved) = DiffFiles "-Warnings.txt";
 print "ADDED   WARNINGS:\n$WarningsAdded\n\n" if (length $WarningsAdded);
 print "REMOVED WARNINGS:\n$WarningsRemoved\n\n" if (length $WarningsRemoved);
 
-$WarningsAdded = AddPreTag $WarningsAdded;
-$WarningsRemoved = AddPreTag $WarningsRemoved;
+my @TmpWarningsAdded = split "\n", $WarningsAdded;
+my @TmpWarningsRemoved = split "\n", $WarningsRemoved;
+$WarningsAdded = ArrayToList @TmpWarningsAdded;
+$WarningsRemoved = ArrayToList @TmpWarningsRemoved;
 
 #
 # Get some statistics about CVS commits over the current day...
@@ -534,8 +600,8 @@ foreach $File (@CVSHistory) {
   }
 }
 
-my $UserCommitList = join "\n", keys %UsersCommitted;
-my $UserUpdateList = join "\n", keys %UsersUpdated;
+my $UserCommitList = join "\n", sort keys %UsersCommitted;
+my $UserUpdateList = join "\n", sort keys %UsersUpdated;
 my $AddedFilesList = AddPreTag join "\n", sort keys %AddedFiles;
 my $ModifiedFilesList = AddPreTag join "\n", sort keys %ModifiedFiles;
 my $RemovedFilesList = AddPreTag join "\n", sort keys %RemovedFiles;
@@ -589,7 +655,7 @@ sub TestDirectory {
 }
 
 # If we built the tree successfully, run the nightly programs tests...
-if ($BuildError eq "") {
+if (!$BuildError) {
   if ( $VERBOSE ) {
     print "SingleSource TEST STAGE\n";
   }
@@ -663,7 +729,7 @@ if ($TestError) {
 
 # If we built the tree successfully, runs of the Olden suite with
 # LARGE_PROBLEM_SIZE on so that we can get some "running" statistics.
-if ($BuildError eq "") {
+if (!$BuildError) {
   if ( $VERBOSE ) { print "OLDEN TEST SUITE STAGE\n"; }
   my ($NATTime, $CBETime, $LLCTime, $JITTime, $OptTime, $BytecodeSize,
       $MachCodeSize) = ("","","","","","","");
@@ -698,7 +764,6 @@ if ($BuildError eq "") {
     my $rJITTime = GetRegex 'TEST-RESULT-jit-time: program\s*([.0-9m]+)', $Rec;
     my $rOptTime = GetRegex "TEST-RESULT-compile: .*$WallTimeRE", $Rec;
     my $rBytecodeSize = GetRegex 'TEST-RESULT-compile: *([0-9]+)', $Rec;
-    my $rMachCodeSize = GetRegex 'TEST-RESULT-jit-machcode: *([0-9]+).*bytes of machine code', $Rec;
 
     $NATTime .= " " . FormatTime($rNATTime);
     $CBETime .= " " . FormatTime($rCBETime);
@@ -706,7 +771,6 @@ if ($BuildError eq "") {
     $JITTime .= " " . FormatTime($rJITTime);
     $OptTime .= " $rOptTime";
     $BytecodeSize .= " $rBytecodeSize";
-    $MachCodeSize .= " $rMachCodeSize";
   }
 
   # Now that we have all of the numbers we want, add them to the running totals
@@ -717,7 +781,6 @@ if ($BuildError eq "") {
   AddRecord($JITTime, "running_Olden_jit_time.txt");
   AddRecord($OptTime, "running_Olden_opt_time.txt");
   AddRecord($BytecodeSize, "running_Olden_bytecode.txt");
-  AddRecord($MachCodeSize, "running_Olden_machcode.txt");
 
   system "gzip -f $OldenTestsLog";
 }
@@ -743,7 +806,7 @@ ChangeDir( $WebDir, "Web Directory" );
 # Make sure we don't get errors running the nightly tester the first time
 # because of files that don't exist.
 Touch ('running_build_time.txt', 'running_Olden_llc_time.txt',
-       'running_loc.txt', 'running_Olden_machcode.txt',
+       'running_loc.txt', 
        'running_Olden_bytecode.txt', 'running_Olden_nat_time.txt',
        'running_Olden_cbe_time.txt', 'running_Olden_opt_time.txt',
        'running_Olden_jit_time.txt');
@@ -767,6 +830,18 @@ system ("$GNUPLOT", $PlotScriptFilename);
 #
 system ( "$NICE rm -rf $BuildDir") if (!$NOCHECKOUT and !$NOREMOVE);
 
+print "\nUSERS WHO COMMITTED:\n  " . (join "\n  ", sort keys %UsersCommitted) . "\n"
+  if (scalar %UsersCommitted);
+
+print "\nADDED FILES:\n  " . (join "\n  ", sort keys %AddedFiles) . "\n"
+  if (scalar %AddedFiles);
+
+print "\nCHANGED FILES:\n  " . (join "\n  ", sort keys %ModifiedFiles) . "\n"
+  if (scalar %ModifiedFiles);
+
+print "\nREMOVED FILES:\n  " . (join "\n  ", sort keys %RemovedFiles) . "\n"
+  if (scalar %RemovedFiles);
+
 #
 # Print out information...
 #
@@ -778,12 +853,6 @@ if ($VERBOSE) {
   print "Libraries/Executables/Objects built: $NumLibraries/$NumExecutables/$NumObjects\n";
 
   print "WARNINGS:\n  $WarningsList\n";
-
-  print "Users committed: $UserCommitList\n";
-  print "Added Files: \n  $AddedFilesList\n";
-  print "Modified Files: \n  $ModifiedFilesList\n";
-  print "Removed Files: \n  $RemovedFilesList\n";
-
   print "Previous Days =\n  $PrevDaysList\n";
 }
 
@@ -797,11 +866,15 @@ if ( $VERBOSE ) {
 }
 # Main HTML file...
 my $Output;
-my $TestFinishTime = gmtime;
+my $TestFinishTime = gmtime() . " GMT<br>" . localtime() . " (local)";
+
 my $TestPlatform = `uname -a`;
 eval "\$Output = <<ENDOFFILE;$TemplateContents\nENDOFFILE\n";
 WriteFile "$DATE.html", $Output;
-system ( "ln -sf $DATE.html index.html" );
+
+# Remove the symlink before creating it for systems that don't have "ln -sf".
+system ("rm index.html");
+system ("ln -s $DATE.html index.html");
 
 # Change the index.html symlink...