瀏覽代碼

+ support for testing whole program optimisation tests (multiple
compilations using successively generated feedback files)

git-svn-id: branches/wpo@12331 -

Jonas Maebe 17 年之前
父節點
當前提交
e32ba49bb6
共有 3 個文件被更改,包括 75 次插入41 次删除
  1. 7 0
      tests/readme.txt
  2. 60 41
      tests/utils/dotest.pp
  3. 8 0
      tests/utils/testu.pp

+ 7 - 0
tests/readme.txt

@@ -85,6 +85,13 @@ KNOWNCOMPILEERROR..Known bug, which manifest itself at compile time. To
                    from compiler, followed by an optional note. Will not
                    be logged as a bug.
 QUICKTEST..........If set, only tests without package dependencies are executed
+WPOPARAS...........Parameters to be added after -OW/-Ow to perform whole
+                   program optimization tests
+WPOPASSES..........Number of whole program optimization iterations to perform
+                   ("1" means compile once with "-FWsomefile -OW<wpoparas>"
+                    and then again with "-FWsomefile2 -OW<wpoparas>
+                    -Fwsomefile1 -Ow<wpoparas>", "2" means another pass but
+                   using somefile2 as input and somefile3 as output, etc.)
 
   NOTE: A list consists of comma separated items, e. g. CPU=i386,m68k,powerpc
         No space between the elements and the comma.

+ 60 - 41
tests/utils/dotest.pp

@@ -525,7 +525,10 @@ end;
 
 function RunCompiler:boolean;
 var
-  args    : string;
+  args,
+  wpoargs : string;
+  passnr,
+  passes  : longint;
   execres : boolean;
 begin
   RunCompiler:=false;
@@ -547,50 +550,66 @@ begin
 {$endif unix}
   if Config.NeedOptions<>'' then
    args:=args+' '+Config.NeedOptions;
+  wpoargs:='';
+  if (Config.WpoPasses=0) or
+     (Config.WpoParas='') then
+    passes:=1
+  else
+    passes:=config.wpopasses+1;
   args:=args+' '+ppfile;
-  Verbose(V_Debug,'Executing '+compilerbin+' '+args);
-  { also get the output from as and ld that writes to stderr sometimes }
-{$ifndef macos}
-  execres:=ExecuteRedir(CompilerBin,args,'',CompilerLogFile,'stdout');
-{$else macos}
-  {Due to that Toolserver is not reentrant, we have to asm and link via script.}
-  execres:=ExecuteRedir(CompilerBin,'-s '+args,'',CompilerLogFile,'stdout');
-  if execres then
-    execres:=ExecuteRedir(TestOutputDir + ':ppas','','',CompilerLogFile,'stdout');
-{$endif macos}
-  Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
 
-  { Error during execution? }
-  if (not execres) and (ExecuteResult=0) then
+  for passnr:=1 to passes do
     begin
-      AddLog(FailLogFile,TestName);
-      AddLog(ResLogFile,failed_to_compile+PPFileInfo);
-      AddLog(LongLogFile,line_separation);
-      AddLog(LongLogFile,failed_to_compile+PPFileInfo);
-      CopyFile(CompilerLogFile,LongLogFile,true);
-      { avoid to try again }
-      AddLog(ExeLogFile,failed_to_compile+PPFileInfo);
-      Verbose(V_Abort,'IOStatus: '+ToStr(IOStatus));
-      exit;
-    end;
+      if (passes>1) then
+        begin
+          wpoargs:=' -OW'+config.wpoparas+' -FW'+TestOutputFileName(ppfile,'wp'+tostr(passnr));
+          if (passnr>1) then
+            wpoargs:=wpoargs+' -Ow'+config.wpoparas+' -Fw'+TestOutputFileName(ppfile,'wp'+tostr(passnr-1));
+        end;
+      Verbose(V_Debug,'Executing '+compilerbin+' '+args+wpoargs);
+      { also get the output from as and ld that writes to stderr sometimes }
+    {$ifndef macos}
+      execres:=ExecuteRedir(CompilerBin,args+wpoargs,'',CompilerLogFile,'stdout');
+    {$else macos}
+      {Due to that Toolserver is not reentrant, we have to asm and link via script.}
+      execres:=ExecuteRedir(CompilerBin,'-s '+args+wpoargs,'',CompilerLogFile,'stdout');
+      if execres then
+        execres:=ExecuteRedir(TestOutputDir + ':ppas','','',CompilerLogFile,'stdout');
+    {$endif macos}
+      Verbose(V_Debug,'Exitcode '+ToStr(ExecuteResult));
+
+      { Error during execution? }
+      if (not execres) and (ExecuteResult=0) then
+        begin
+          AddLog(FailLogFile,TestName);
+          AddLog(ResLogFile,failed_to_compile+PPFileInfo);
+          AddLog(LongLogFile,line_separation);
+          AddLog(LongLogFile,failed_to_compile+PPFileInfo);
+          CopyFile(CompilerLogFile,LongLogFile,true);
+          { avoid to try again }
+          AddLog(ExeLogFile,failed_to_compile+PPFileInfo);
+          Verbose(V_Abort,'IOStatus: '+ToStr(IOStatus));
+          exit;
+        end;
 
-  { Check for internal error }
-  if ExitWithInternalError(CompilerLogFile) then
-   begin
-     AddLog(FailLogFile,TestName);
-     if Config.Note<>'' then
-      AddLog(FailLogFile,Config.Note);
-     AddLog(ResLogFile,failed_to_compile+PPFileInfo+' internalerror generated');
-     AddLog(LongLogFile,line_separation);
-     AddLog(LongLogFile,failed_to_compile+PPFileInfo);
-     if Config.Note<>'' then
-      AddLog(LongLogFile,Config.Note);
-     CopyFile(CompilerLogFile,LongLogFile,true);
-     { avoid to try again }
-     AddLog(ExeLogFile,'Failed to compile '+PPFileInfo);
-     Verbose(V_Abort,'Internal error in compiler');
-     exit;
-   end;
+      { Check for internal error }
+      if ExitWithInternalError(CompilerLogFile) then
+       begin
+         AddLog(FailLogFile,TestName);
+         if Config.Note<>'' then
+          AddLog(FailLogFile,Config.Note);
+         AddLog(ResLogFile,failed_to_compile+PPFileInfo+' internalerror generated');
+         AddLog(LongLogFile,line_separation);
+         AddLog(LongLogFile,failed_to_compile+PPFileInfo);
+         if Config.Note<>'' then
+          AddLog(LongLogFile,Config.Note);
+         CopyFile(CompilerLogFile,LongLogFile,true);
+         { avoid to try again }
+         AddLog(ExeLogFile,'Failed to compile '+PPFileInfo);
+         Verbose(V_Abort,'Internal error in compiler');
+         exit;
+       end;
+    end;
 
   { Should the compile fail ? }
   if Config.ShouldFail then

+ 8 - 0
tests/utils/testu.pp

@@ -38,6 +38,8 @@ type
     Category      : string;
     Note          : string;
     Files         : string;
+    WpoParas      : string;
+    WpoPasses     : longint;
   end;
 
 Const
@@ -263,6 +265,12 @@ begin
               else
                if GetEntry('FILES') then
                 r.Files:=res
+              else
+                if GetEntry('WPOPARAS') then
+                 r.wpoparas:=res
+              else
+                if GetEntry('WPOPASSES') then
+                 val(res,r.wpopasses,code)
               else
                Verbose(V_Error,'Unknown entry: '+s);
             end;