Browse Source

* use typenames in more cases in the generated LLVM IR (results in smaller
IR in textual form)

git-svn-id: trunk@44518 -

Jonas Maebe 5 years ago
parent
commit
d5de84c6c5
2 changed files with 11 additions and 17 deletions
  1. 9 13
      compiler/llvm/llvmdef.pas
  2. 2 4
      compiler/llvm/llvmtype.pas

+ 9 - 13
compiler/llvm/llvmdef.pas

@@ -48,8 +48,8 @@ interface
      tllvmprocdefdecltype = (lpd_def,lpd_decl,lpd_alias,lpd_procvar);
      tllvmprocdefdecltype = (lpd_def,lpd_decl,lpd_alias,lpd_procvar);
 
 
     { returns the identifier to use as typename for a def in llvm (llvm only
     { returns the identifier to use as typename for a def in llvm (llvm only
-      allows naming struct types) -- only supported for defs with a typesym, and
-      only for tabstractrecorddef descendantds and complex procvars }
+      allows naming struct types) -- only supported for tabstractrecorddef
+      descendantds and complex procvars }
     function llvmtypeidentifier(def: tdef): TSymStr;
     function llvmtypeidentifier(def: tdef): TSymStr;
 
 
     { encode a type into the internal format used by LLVM (for a type
     { encode a type into the internal format used by LLVM (for a type
@@ -130,9 +130,10 @@ implementation
 
 
   function llvmtypeidentifier(def: tdef): TSymStr;
   function llvmtypeidentifier(def: tdef): TSymStr;
     begin
     begin
-      if not assigned(def.typesym) then
-        internalerror(2015041901);
-      result:='%"typ.'+def.fullownerhierarchyname(false)+def.typesym.realname+'"'
+      if assigned(def.typesym) then
+        result:='%"typ.'+def.fullownerhierarchyname(false)+def.typesym.realname+'"'
+      else
+        result:='%"typ.'+def.fullownerhierarchyname(false)+def.unique_id_str+'"';
     end;
     end;
 
 
 
 
@@ -444,9 +445,7 @@ implementation
           recorddef :
           recorddef :
             begin
             begin
               { avoid endlessly recursive definitions }
               { avoid endlessly recursive definitions }
-              if assigned(def.typesym) and
-                 ((lef_inaggregate in flags) or
-                  not(lef_typedecl in flags)) then
+              if not(lef_typedecl in flags) then
                 encodedstr:=encodedstr+llvmtypeidentifier(def)
                 encodedstr:=encodedstr+llvmtypeidentifier(def)
               else
               else
                 llvmaddencodedabstractrecordtype(trecorddef(def),encodedstr);
                 llvmaddencodedabstractrecordtype(trecorddef(def),encodedstr);
@@ -537,9 +536,7 @@ implementation
                   if def.typ=procvardef then
                   if def.typ=procvardef then
                     encodedstr:=encodedstr+'*';
                     encodedstr:=encodedstr+'*';
                 end
                 end
-              else if ((lef_inaggregate in flags) or
-                  not(lef_typedecl in flags)) and
-                 assigned(tprocvardef(def).typesym) then
+              else if not(lef_typedecl in flags) then
                 begin
                 begin
                   { in case the procvardef recursively references itself, e.g.
                   { in case the procvardef recursively references itself, e.g.
                     via a pointer }
                     via a pointer }
@@ -569,8 +566,7 @@ implementation
               odt_object,
               odt_object,
               odt_cppclass:
               odt_cppclass:
                 begin
                 begin
-                  if not(lef_typedecl in flags) and
-                     assigned(def.typesym) then
+                  if not(lef_typedecl in flags) then
                     encodedstr:=encodedstr+llvmtypeidentifier(def)
                     encodedstr:=encodedstr+llvmtypeidentifier(def)
                   else
                   else
                     llvmaddencodedabstractrecordtype(tabstractrecorddef(def),encodedstr);
                     llvmaddencodedabstractrecordtype(tabstractrecorddef(def),encodedstr);

+ 2 - 4
compiler/llvm/llvmtype.pas

@@ -574,8 +574,7 @@ implementation
         symdeflist:=tabstractrecordsymtable(def.symtable).llvmst.symdeflist;
         symdeflist:=tabstractrecordsymtable(def.symtable).llvmst.symdeflist;
         for i:=0 to symdeflist.Count-1 do
         for i:=0 to symdeflist.Count-1 do
           record_def(tllvmshadowsymtableentry(symdeflist[i]).def);
           record_def(tllvmshadowsymtableentry(symdeflist[i]).def);
-        if assigned(def.typesym) then
-          list.concat(taillvm.op_size(LA_TYPE,record_def(def)));
+        list.concat(taillvm.op_size(LA_TYPE,record_def(def)));
       end;
       end;
 
 
 
 
@@ -605,8 +604,7 @@ implementation
         for i:=0 to def.paras.count-1 do
         for i:=0 to def.paras.count-1 do
           appenddef(list,llvmgetcgparadef(tparavarsym(def.paras[i]).paraloc[callerside],true,calleeside));
           appenddef(list,llvmgetcgparadef(tparavarsym(def.paras[i]).paraloc[callerside],true,calleeside));
         appenddef(list,llvmgetcgparadef(def.funcretloc[callerside],true,calleeside));
         appenddef(list,llvmgetcgparadef(def.funcretloc[callerside],true,calleeside));
-        if assigned(def.typesym) and
-           not def.is_addressonly then
+        if not def.is_addressonly then
           list.concat(taillvm.op_size(LA_TYPE,record_def(def)));
           list.concat(taillvm.op_size(LA_TYPE,record_def(def)));
       end;
       end;