Browse Source

* Patch by J. Gareth "Kit" Moreton (issue #39343). Added missing allocation
of flags in tx86typeconvnode.second_int_to_bool and in generic
tcgtypeconvnode.second_int_to_bool. This fixes random failures of the
tcnvint1 test and some other tests when compiled with -O2.

(cherry picked from commit 940ac567a500e6e495379ec5609017a18aa55abc)

Yuriy Sydorov 3 years ago
parent
commit
0b5951cf22
2 changed files with 9 additions and 0 deletions
  1. 5 0
      compiler/ncgcnv.pas
  2. 4 0
      compiler/x86/nx86cnv.pas

+ 5 - 0
compiler/ncgcnv.pas

@@ -234,11 +234,13 @@ interface
                  cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hregister);
                  cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hregister);
                  href:=left.location.reference;
                  href:=left.location.reference;
                  inc(href.offset,4);
                  inc(href.offset,4);
+                 cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                  cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,href,hregister);
                  cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,href,hregister);
                end
                end
               else
               else
                begin
                begin
                  hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
                  hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
+                 cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,left.location.size,left.location.register,left.location.register);
                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,left.location.size,left.location.register,left.location.register);
                end;
                end;
             end;
             end;
@@ -253,11 +255,13 @@ interface
                begin
                begin
                  hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
                  hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
                  cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.register64.reglo,hregister);
                  cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.register64.reglo,hregister);
+                 cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reghi,hregister);
                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reghi,hregister);
                end
                end
               else
               else
 {$endif cpu64bitalu}
 {$endif cpu64bitalu}
                begin
                begin
+                 cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,left.location.size,left.location.register,left.location.register);
                  cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,left.location.size,left.location.register,left.location.register);
                end;
                end;
             end;
             end;
@@ -271,6 +275,7 @@ interface
               cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
               cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
               cg.a_label(current_asmdata.CurrAsmList,hlabel);
               cg.a_label(current_asmdata.CurrAsmList,hlabel);
+              cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
               cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_INT,hregister,hregister);
               cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_INT,hregister,hregister);
             end;
             end;
           else
           else

+ 4 - 0
compiler/x86/nx86cnv.pas

@@ -125,6 +125,7 @@ implementation
             LOC_CREFERENCE,
             LOC_CREFERENCE,
             LOC_REFERENCE :
             LOC_REFERENCE :
               begin
               begin
+                cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
 {$ifndef cpu64bitalu}
 {$ifndef cpu64bitalu}
                 if left.location.size in [OS_64,OS_S64{$ifdef cpu16bitalu},OS_32,OS_S32{$endif}] then
                 if left.location.size in [OS_64,OS_S64{$ifdef cpu16bitalu},OS_32,OS_S32{$endif}] then
                  begin
                  begin
@@ -150,6 +151,7 @@ implementation
               end;
               end;
             LOC_REGISTER,LOC_CREGISTER :
             LOC_REGISTER,LOC_CREGISTER :
               begin
               begin
+                cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
 {$if defined(cpu32bitalu)}
 {$if defined(cpu32bitalu)}
                 if left.location.size in [OS_64,OS_S64] then
                 if left.location.size in [OS_64,OS_S64] then
                  begin
                  begin
@@ -201,6 +203,7 @@ implementation
                 begin
                 begin
                   hreg2:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
                   hreg2:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
                   cg.g_flags2reg(current_asmdata.CurrAsmList,OS_32,resflags,hreg2);
                   cg.g_flags2reg(current_asmdata.CurrAsmList,OS_32,resflags,hreg2);
+                  cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                   if (is_cbool(resultdef)) then
                   if (is_cbool(resultdef)) then
                     cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,OS_32,hreg2,hreg2);
                     cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,OS_32,hreg2,hreg2);
                   location.register64.reglo:=hreg2;
                   location.register64.reglo:=hreg2;
@@ -217,6 +220,7 @@ implementation
                begin
                begin
                  location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
                  location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
                  cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,location.register);
                  cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,location.register);
+                 cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                  if (is_cbool(resultdef)) then
                  if (is_cbool(resultdef)) then
                    cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
                    cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
                end
                end