View Issue Details

IDProjectCategoryView StatusLast Update
0038638FPCCompilerpublic2021-03-27 01:04
ReporterDo-wan Kim Assigned ToFlorian  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0038638: LOOPUNROLL tryfinally node patch on i386-win32.
DescriptionTryfinally node with LOOPUNROLL optimization problem also happens i386-win32.

And I make copy and paste patch from x86-64-win64 code(r48972).

TagsNo tags attached.
Fixed in Revision49057
FPCOldBugId
FPCTarget-
Attached Files

Activities

Do-wan Kim

2021-03-19 06:18

reporter  

37305_for_tryfinally_i386.patch (2,279 bytes)   
Index: compiler/i386/n386flw.pas
===================================================================
--- compiler/i386/n386flw.pas	(revision 48948)
+++ compiler/i386/n386flw.pas	(working copy)
@@ -46,6 +46,7 @@
       constructor create(l,r:TNode);override;
       constructor create_implicit(l,r:TNode);override;
       function pass_1: tnode;override;
+	  function dogetcopy : tnode;override;
       function simplify(forinline: boolean): tnode;override;
       procedure pass_generate_code;override;
     end;
@@ -59,7 +60,7 @@
     cgbase,cgobj,cgcpu,cgutils,tgobj,
     cpubase,htypechk,
     parabase,paramgr,pass_1,pass_2,ncgutil,cga,
-    aasmbase,aasmtai,aasmdata,aasmcpu,procinfo,cpupi;
+    aasmbase,aasmtai,aasmdata,aasmcpu,procinfo,cpupi,procdefutil;
 
   var
     endexceptlabel: tasmlabel;
@@ -215,6 +216,30 @@
       end;
   end;
 
+function ti386tryfinallynode.dogetcopy: tnode;
+  var
+    n: ti386tryfinallynode;
+  begin
+	n:=ti386tryfinallynode(inherited dogetcopy);
+	if target_info.system=system_i386_win32 then
+	  begin
+	    n.finalizepi:=tcgprocinfo(cprocinfo.create(finalizepi.parent));
+		n.finalizepi.force_nested;
+		n.finalizepi.procdef:=create_outline_procdef('$fin$',current_procinfo.procdef.struct,potype_exceptfilter,voidtype);
+		n.finalizepi.entrypos:=finalizepi.entrypos;
+		n.finalizepi.entryswitches:=finalizepi.entryswitches;
+		n.finalizepi.exitpos:=finalizepi.exitpos;
+		n.finalizepi.exitswitches:=finalizepi.exitswitches;
+		n.finalizepi.flags:=finalizepi.flags;
+		{ node already transformed? }
+		if assigned(finalizepi.code) then
+		  begin
+			n.finalizepi.code:=finalizepi.code.getcopy;
+			n.right:=ccallnode.create(nil,tprocsym(n.finalizepi.procdef.procsym),nil,nil,[],nil);
+		  end;
+	  end;
+	result:=n;
+  end;
 
 function ti386tryfinallynode.simplify(forinline: boolean): tnode;
   begin
@@ -222,7 +247,8 @@
     if (target_info.system<>system_i386_win32) then
       exit;
 
-    if (result=nil) and assigned(finalizepi) then
+   { actually, this is not really the right place to do a node transformation like this }
+    if (result=nil) and assigned(finalizepi) and (not(assigned(finalizepi.code))) then
       begin
         finalizepi.code:=right;
         foreachnodestatic(right,@copy_parasize,finalizepi);

Florian

2021-03-26 23:22

administrator   ~0129914

Thanks, applied.

Do-wan Kim

2021-03-27 01:04

reporter   ~0129916

Thank you!

Issue History

Date Modified Username Field Change
2021-03-19 06:18 Do-wan Kim New Issue
2021-03-19 06:18 Do-wan Kim File Added: 37305_for_tryfinally_i386.patch
2021-03-26 23:22 Florian Assigned To => Florian
2021-03-26 23:22 Florian Status new => resolved
2021-03-26 23:22 Florian Resolution open => fixed
2021-03-26 23:22 Florian Fixed in Version => 3.3.1
2021-03-26 23:22 Florian Fixed in Revision => 49057
2021-03-26 23:22 Florian FPCTarget => -
2021-03-26 23:22 Florian Note Added: 0129914
2021-03-27 01:04 Do-wan Kim Status resolved => closed
2021-03-27 01:04 Do-wan Kim Note Added: 0129916