Jelajahi Sumber

* loading a got depends only on the fact if a got is needed and not if pic shall be generated

git-svn-id: trunk@43075 -
florian 5 tahun lalu
induk
melakukan
11319353fd
3 mengubah file dengan 14 tambahan dan 18 penghapusan
  1. 9 12
      compiler/i386/cpupi.pas
  2. 1 1
      compiler/i8086/cgcpu.pas
  3. 4 5
      compiler/psub.pas

+ 9 - 12
compiler/i386/cpupi.pas

@@ -98,19 +98,16 @@ unit cpupi;
 
     procedure tcpuprocinfo.allocate_got_register(list: tasmlist);
       begin
-        if (cs_create_pic in current_settings.moduleswitches) then
+        if (pi_uses_threadvar in flags) and (tf_section_threadvars in target_info.flags) and (current_settings.tlsmodel in [tlsm_general]) then
           begin
-            if (pi_uses_threadvar in flags) and (tf_section_threadvars in target_info.flags) then
-              begin
-                { FIXME: It is better to use an imaginary register for GOT and
-                  if EBX is needed for some reason just allocate EBX and
-                  copy GOT into it before its usage. }
-                cg.getcpuregister(list,NR_EBX);
-                got := NR_EBX;
-              end
-            else
-              got := cg.getaddressregister(list);
-          end;
+            { FIXME: It is better to use an imaginary register for GOT and
+              if EBX is needed for some reason just allocate EBX and
+              copy GOT into it before its usage. }
+            cg.getcpuregister(list,NR_EBX);
+            got := NR_EBX;
+          end
+        else if cs_create_pic in current_settings.moduleswitches then
+          got := cg.getaddressregister(list);
       end;
 
 begin

+ 1 - 1
compiler/i8086/cgcpu.pas

@@ -151,7 +151,7 @@ unit cgcpu;
 
     procedure tcg8086.do_register_allocation(list:TAsmList;headertai:tai);
       begin
-        if (pi_needs_got in current_procinfo.flags) then
+        if (tf_pic_uses_got in target_info.flags) and (pi_needs_got in current_procinfo.flags) then
           begin
             if getsupreg(current_procinfo.got) < first_int_imreg then
               include(rg[R_INTREGISTER].used_in_proc,getsupreg(current_procinfo.got));

+ 4 - 5
compiler/psub.pas

@@ -1801,9 +1801,9 @@ implementation
 
             { make sure the got/pic register doesn't get freed in the }
             { middle of a loop                                        }
-            if (cs_create_pic in current_settings.moduleswitches) and
-               (pi_needs_got in flags) and
-               (got<>NR_NO) then
+            if (tf_pic_uses_got in target_info.flags) and
+              (pi_needs_got in flags) and
+              (got<>NR_NO) then
               cg.a_reg_sync(aktproccode,got);
 
             if (pi_uses_threadvar in flags) and
@@ -1879,8 +1879,7 @@ implementation
               maintain location lists }
             procdef.parast.SymList.ForEachCall(@translate_registers,templist);
             procdef.localst.SymList.ForEachCall(@translate_registers,templist);
-            if (cs_create_pic in current_settings.moduleswitches) and
-               (pi_needs_got in flags) and
+            if (tf_pic_uses_got in target_info.flags) and (pi_needs_got in flags) and
                not(cs_no_regalloc in current_settings.globalswitches) and
                (got<>NR_NO) then
               cg.translate_register(got);