Recent

Author Topic: Note: Call to subroutine "function any;" marked as inline is not inlined  (Read 1271 times)

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1052
    • Burdjia
I understand why the compiler isn't able in some cases, but anyway there should be a way to fix it;  maybe 2 pass compilation although I understand it isn't feasible without rewriting most of the compiler (IIRC current compilation is done in a single pass).  Anyway it is quite annoying.

Is the hint triggered when called in a different unit or the same unit? If the same unit, then see my example: if you want FindState to be inlined then any callsite inside the same unit needs to be after FindState.

Other possibility: is STATE_NOT_FOUND global or local to the unit?

Sometimes in the same unit, some times in other units.

Fixing the "same unit" the way you said is a mess, as I have the implementation in same order than the interface declarations, wich is helpful for maintenance.  So changing that...  Not sure but I think I have hundred methods in the engine and several docens in Allegro.pas.  :(

What about the other units?
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

PascalDragon

  • Hero Member
  • *****
  • Posts: 2138
  • Compiler Developer
I understand why the compiler isn't able in some cases, but anyway there should be a way to fix it;  maybe 2 pass compilation although I understand it isn't feasible without rewriting most of the compiler (IIRC current compilation is done in a single pass).  Anyway it is quite annoying.

No, that won't be changed. If it is inside a single unit it's up to the user that their code is ordered correctly to allow inlining (at least if nothing else blocks inlining, e.g. inherited or open array arguments). Cross-unit that part isn't important anyway.

Is the hint triggered when called in a different unit or the same unit? If the same unit, then see my example: if you want FindState to be inlined then any callsite inside the same unit needs to be after FindState.

Other possibility: is STATE_NOT_FOUND global or local to the unit?

Sometimes in the same unit, some times in other units.

Fixing the "same unit" the way you said is a mess, as I have the implementation in same order than the interface declarations, wich is helpful for maintenance.  So changing that...  Not sure but I think I have hundred methods in the engine and several docens in Allegro.pas.  :(

What about the other units?

As said above if it's about cross-unit inline then the order is not important, but other things might be. Thus I ask again: is STATE_NOT_FOUND declared globally or locally? And is it used in a function that is declared as inline and is available from the interface section of the unit?

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1052
    • Burdjia
As said above if it's about cross-unit inline then the order is not important, but other things might be. Thus I ask again: is STATE_NOT_FOUND declared globally or locally? And is it used in a function that is declared as inline and is available from the interface section of the unit?
STATE_NOT_FOUND is a RESOURCESTRING declared in the IMPLEMENTATION section.  It is used by two methods, one declared as INLINE, the other isn't.  The INLINE method is used by other units only (and never inlined).
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

PascalDragon

  • Hero Member
  • *****
  • Posts: 2138
  • Compiler Developer
Then there is the problem. FPC < 3.3.1 does not support inlining functions from another unit that use local symbols. That was only implemented at the beginning of the year by Jonas, but it's too invasive to merge back to 3.2. If you want inlining to work for such functions then all symbols need to be available in the interface section.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1052
    • Burdjia
Well, I planed to remove all RESOURCESTRINGS since I'll change the way it uses strings.  Anyway project is still in alpha status.  ::)

Thanks for the tips. :)
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1052
    • Burdjia
Re: Note: Call to subroutine "function any;" marked as inline is not inlined
« Reply #20 on: August 14, 2020, 12:26:34 pm »
Quite annoying, but I still don't understand.  Next method is marked as INLINE but it isn't:
Code: Pascal  [Select][+][-]
  1. (* Clears event queue. *)
  2.   PROCEDURE TmngEventManager.Clear;
  3.   BEGIN
  4.     IF NOT SELF.IsQueueEmpty THEN al_flush_event_queue (fEventQueue)
  5.   END;
fEventQueue is a field of TmngEventManager, while al_flush_event_queue is a procedure defined in a 3rd party unit that is included in the INTERFACE USES section.  As I understood it should be inlined, or didn't I understood the whole thing?

Can see the full unit code here.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

 

TinyPortal © 2005-2018