Bugfixes for smallvector when the element size is small and N is small.
[oota-llvm.git] / utils / NightlyTest.pl
index 3d9084755ad42591f2f203e82c84721535ea04b0..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-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
@@ -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
@@ -199,7 +230,7 @@ sub GetDejagnuTestResults { # (filename, log)
   my $firstline;
   $/ = "\n"; #Make sure we're going line at a time.
 
-  print "Dejagnu test results:\n";
+  print "DEJAGNU TEST RESULTS:\n";
 
   if (open SRCHFILE, $filename) {
     # Process test results
@@ -230,13 +261,13 @@ sub GetDejagnuTestResults { # (filename, log)
             push(@lines, "</li></ol>\n");
           }
           push(@lines, "<h3>STATISTICS</h3><pre>\n");
-          print "\nSTATISTICS:\n";
+          print "\nDEJAGNU STATISTICS:\n";
           $should_break = 0;
           $nocopy = 0;
           $readingsum = 1;
         } elsif ( $readingsum ) {
           push(@lines,"$_\n");
-          print "$_\n";
+          print "  $_\n";
         }
       }
     }
@@ -268,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-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";
 }
 
@@ -357,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") ;
 }
 
@@ -400,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
@@ -432,7 +484,7 @@ if (`grep '^gmake[^:]*: .*Error' $BuildLog | wc -l` + 0 ||
   $BuildStatus = "<h3><font color='red'>error: compilation " .
                 "<a href=\"$DATE-Build-Log.txt\">aborted</a></font></h3>";
   $BuildError = 1;
-  if ($VERBOSE) { print "BUILD ERROR\n"; }
+  print "\n***ERROR BUILDING TREE\n\n";
 }
 
 if ($BuildError) { $NODEJAGNU=1; }
@@ -488,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...
@@ -499,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...
@@ -546,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;
@@ -710,7 +764,6 @@ if (!$BuildError) {
     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);
@@ -718,7 +771,6 @@ if (!$BuildError) {
     $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
@@ -729,7 +781,6 @@ if (!$BuildError) {
   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";
 }
@@ -755,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');
@@ -779,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...
 #
@@ -790,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";
 }
 
@@ -814,7 +871,10 @@ 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...