[fpc-devel] Does FPC optimize unused parameters ?

Martin lazarus at mfriebe.de
Fri Aug 24 13:07:48 CEST 2012


On 24/08/2012 12:04, Jonas Maebe wrote:
>
> Martin wrote on Fri, 24 Aug 2012:
>
>> On 08/08/2012 15:37, Jonas Maebe wrote:
>>>
>>> Martin wrote on Wed, 08 Aug 2012:
>>>
>>>> Out of curiosity. Is there an optimization like this
>>> [removing calculation/load of unused parameters]
>>>
>>> No.
>>
>>  Are you sure? It seems the compiler disagrees with you.
>>
>> I  tested with 2.7.1 (updated yesterday):
>>
>> function Foo(s:string): string;
>> begin
>>   Result := s;
>>   Form1.Caption := s;
>> end;
>>
>> procedure TForm1.FormCreate(Sender: TObject);
>> begin
>>   //DebugLn(['abc']);
>>   //DebugLn('abc');
>>   DebugLn(foo('abc'));
>> end;
>>
>> The assembler for FormCreate (no optimization used). It even omits 
>> the call to "Foo"...
>
> How is debugln defined?

The above takes the first of the overloaded.
All bodies are empty.


procedure DebugLn(const s: string = ''); inline; overload;
procedure DebugLn(Args: array of const); {inline;} overload;
procedure DebugLn(const S: String; Args: array of const); {inline;} 
overload;// similar to Format(s,Args)
procedure DebugLn(const s1, s2: string; const s3: string = '';
                   const s4: string = ''; const s5: string = ''; const 
s6: string = '';
                   const s7: string = ''; const s8: string = ''; const 
s9: string = '';
                   const s10: string = ''; const s11: string = ''; const 
s12: string = '';
                   const s13: string = ''; const s14: string = ''; const 
s15: string = '';
                   const s16: string = ''; const s17: string = ''; const 
s18: string = ''); inline; overload;




More information about the fpc-devel mailing list