Explorar el Código

* synchronised with trunk till r40724

git-svn-id: branches/debug_eh@40737 -
Jonas Maebe hace 6 años
padre
commit
14cc517f40
Se han modificado 3 ficheros con 36 adiciones y 3 borrados
  1. 3 0
      compiler/llvm/hlcgllvm.pas
  2. 12 2
      compiler/llvm/llvmdef.pas
  3. 21 1
      compiler/parabase.pas

+ 3 - 0
compiler/llvm/hlcgllvm.pas

@@ -441,6 +441,9 @@ implementation
     callparas:=tfplist.Create;
     for i:=0 to high(paras) do
       begin
+        { skip parameters without data }
+        if paras[i]^.isempty then
+          continue;
         paraloc:=paras[i]^.location;
         while assigned(paraloc) do
           begin

+ 12 - 2
compiler/llvm/llvmdef.pas

@@ -682,9 +682,19 @@ implementation
             exit
           end;
         if withparaname then
-          paraloc:=hp.paraloc[calleeside].location
+          begin
+            { don't add parameters that don't take up registers or stack space;
+              clang doesn't either and some LLVM backends don't support them }
+            if hp.paraloc[calleeside].isempty then
+              exit;
+            paraloc:=hp.paraloc[calleeside].location
+          end
         else
-          paraloc:=hp.paraloc[callerside].location;
+          begin
+            if hp.paraloc[callerside].isempty then
+              exit;
+            paraloc:=hp.paraloc[callerside].location;
+          end;
         repeat
           usedef:=paraloc^.def;
           llvmextractvalueextinfo(hp.vardef,usedef,signext);

+ 21 - 1
compiler/parabase.pas

@@ -118,6 +118,7 @@ unit parabase;
           function    add_location:pcgparalocation;
           procedure   get_location(var newloc:tlocation);
           function    locations_count:integer;
+          function    isempty: boolean; { no data, and not varargs para }
 
           procedure   buildderef;
           procedure   deref;
@@ -161,7 +162,7 @@ implementation
 
     uses
       systems,verbose,
-      symsym;
+      symsym,defutil;
 
 
 {****************************************************************************
@@ -317,6 +318,25 @@ implementation
       end;
 
 
+    function TCGPara.isempty: boolean;
+      var
+        hlocation: pcgparalocation;
+      begin
+        { can happen if e.g. [] is passed to a cdecl varargs para }
+        if not assigned(def) then
+          exit(true);
+        if is_array_of_const(def) then
+          exit(false);
+        hlocation:=location;
+        while assigned(hlocation) do
+          begin
+            if hlocation^.Loc<>LOC_VOID then
+              exit(false);
+            hlocation:=hlocation^.next;
+          end;
+        result:=true;
+      end;
+
     procedure TCGPara.buildderef;
       begin
         defderef.build(def);