We have been struggling with a situation in which a large (75K) data structure is passed as an in out parameter to a procedure. We were surprised to discover that the compiler was copying the data that was passed at the start and end of the execution of the called procedure (which, in turn, had led to undesirable performance issues). Let the type of data being passed be L_Type. We also have a record type (call it R_Type) which has a component L, of type L_Type. Now let the called procedure be P, i.e.,
procedure P (L : in out L_Type);
Now if I declare:
L1 : L_Type;
and call P like this:
P(L => L1);
there is no copying of data. However, if I declare
R1 : R_Type
and then call P using R1:
P(L => R1.L);
then we see that R1.L is copied by the compiler.
Now we think we have uncovered the reason for all this, namely, there was a record representation clause for type R_Type. By removing this clause, the undesirable copying goes away. Also, we can manipulate the alignment of component L within R_Type and have seen that if it is placed at a multiple of 8 bytes from the beginning of R_Type, there is no copying. But if it is placed at a multiple of 4 bytes (and not a multiple of 8) then the copying occurs.
So... Can someone confirm that what is going on here is that the compiler needs to assure that the parameter of type L_Type is aligned on an 8-byte boundary during the execution of P and that is why it copies the data in the situation described?
Thanks in advance.