Browse Source

* support forcing to write the parameter alignment for parameters for LLVM,
even when it's the same as the stack alignment (it can also refer to the
alignment of the data pointed to by pointer parameters)

git-svn-id: branches/debug_eh@41729 -

Jonas Maebe 6 years ago
parent
commit
fcde89cb26
4 changed files with 9 additions and 6 deletions
  1. 1 1
      compiler/llvm/aasmllvm.pas
  2. 5 2
      compiler/llvm/agllvm.pas
  3. 2 2
      compiler/llvm/hlcgllvm.pas
  4. 1 1
      compiler/parabase.pas

+ 1 - 1
compiler/llvm/aasmllvm.pas

@@ -204,7 +204,7 @@ interface
     pllvmcallpara = ^tllvmcallpara;
     pllvmcallpara = ^tllvmcallpara;
     tllvmcallpara = record
     tllvmcallpara = record
       def: tdef;
       def: tdef;
-      alignment: byte;
+      alignment: shortint;
       valueext: tllvmvalueextension;
       valueext: tllvmvalueextension;
       byval,
       byval,
       sret: boolean;
       sret: boolean;

+ 5 - 2
compiler/llvm/agllvm.pas

@@ -339,10 +339,13 @@ implementation
              owner.writer.AsmWrite(' byval');
              owner.writer.AsmWrite(' byval');
            if para^.sret then
            if para^.sret then
              owner.writer.AsmWrite(' sret');
              owner.writer.AsmWrite(' sret');
-           if para^.alignment<>std_param_align then
+           { For byval, this means "alignment on the stack" and of the passed source data.
+             For other pointer parameters, this means "alignment of the passed source data" }
+           if (para^.alignment<>std_param_align) or
+              (para^.alignment<0) then
              begin
              begin
                owner.writer.AsmWrite(' align ');
                owner.writer.AsmWrite(' align ');
-               owner.writer.AsmWrite(tostr(para^.alignment));
+               owner.writer.AsmWrite(tostr(abs(para^.alignment)));
              end;
              end;
            case para^.typ of
            case para^.typ of
              top_reg:
              top_reg:

+ 2 - 2
compiler/llvm/hlcgllvm.pas

@@ -1197,8 +1197,8 @@ implementation
       if indivalign then
       if indivalign then
         begin
         begin
           paramanager.getintparaloc(list,pd,4,volatilepara);
           paramanager.getintparaloc(list,pd,4,volatilepara);
-          destpara.Alignment:=dest.alignment;
-          sourcepara.Alignment:=source.alignment;
+          destpara.Alignment:=-dest.alignment;
+          sourcepara.Alignment:=-source.alignment;
         end
         end
       else
       else
         begin
         begin

+ 1 - 1
compiler/parabase.pas

@@ -106,7 +106,7 @@ unit parabase;
           Location  : PCGParalocation;
           Location  : PCGParalocation;
           IntSize   : tcgint; { size of the total location in bytes }
           IntSize   : tcgint; { size of the total location in bytes }
           DefDeref  : tderef;
           DefDeref  : tderef;
-          Alignment : ShortInt;
+          Alignment : ShortInt; { in case of LLVM, a negative alignment mean: force write the alignment }
           Size      : TCGSize;  { Size of the parameter included in all locations }
           Size      : TCGSize;  { Size of the parameter included in all locations }
           Temporary : boolean;  { created on the fly, no permanent references exist to this somewhere that will cause it to be disposed }
           Temporary : boolean;  { created on the fly, no permanent references exist to this somewhere that will cause it to be disposed }
           constructor init;
           constructor init;