Browse Source

* cap the assumed alignment of pass-by-reference parameters to the minimum of
their default alignment, the alignment of locals, globals and constants
(so that we don't overestimate the alignment of global normal set
constants to 32 bytes, while the maximum const alignment is often only
8 bytes)

git-svn-id: trunk@40374 -

Jonas Maebe 6 years ago
parent
commit
f98a9bea3c
1 changed files with 5 additions and 1 deletions
  1. 5 1
      compiler/ncgld.pas

+ 5 - 1
compiler/ncgld.pas

@@ -420,6 +420,7 @@ implementation
         href : treference;
         href : treference;
         newsize : tcgsize;
         newsize : tcgsize;
         vd : tdef;
         vd : tdef;
+        alignment: longint;
         indirect : boolean;
         indirect : boolean;
         name : TSymStr;
         name : TSymStr;
       begin
       begin
@@ -529,7 +530,10 @@ implementation
                     { assume packed records may always be unaligned }
                     { assume packed records may always be unaligned }
                     if not(resultdef.typ in [recorddef,objectdef]) or
                     if not(resultdef.typ in [recorddef,objectdef]) or
                        (tabstractrecordsymtable(tabstractrecorddef(resultdef).symtable).usefieldalignment<>1) then
                        (tabstractrecordsymtable(tabstractrecorddef(resultdef).symtable).usefieldalignment<>1) then
-                      location_reset_ref(location,LOC_REFERENCE,newsize,resultdef.alignment,[])
+                      begin
+                        alignment:=min(min(min(resultdef.alignment,current_settings.alignment.localalignmax),current_settings.alignment.constalignmax),current_settings.alignment.varalignmax);
+                        location_reset_ref(location,LOC_REFERENCE,newsize,alignment,[]);
+                      end
                     else
                     else
                       location_reset_ref(location,LOC_REFERENCE,newsize,1,[]);
                       location_reset_ref(location,LOC_REFERENCE,newsize,1,[]);
                     hlcg.reference_reset_base(location.reference,voidpointertype,hregister,0,ctempposinvalid,location.reference.alignment,[]);
                     hlcg.reference_reset_base(location.reference,voidpointertype,hregister,0,ctempposinvalid,location.reference.alignment,[]);