Recent

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

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • 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: 5446
  • 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: 1186
    • 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: 5446
  • 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: 1186
    • 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: 1186
    • 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

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Note: Call to subroutine "function any;" marked as inline is not inlined
« Reply #21 on: November 08, 2020, 12:12:21 pm »
Still fighting the inline thing.

I've found a bug report that says the compiler throws a false positive (or negative?) as it inlined the subroutine but said it wasn't.

Also I've found the wiki says that inline is buggy without more information.  There are a few open bugs in the bug tracker, a bunch from several years ago.

Just informing.
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: 1186
    • Burdjia
Re: Note: Call to subroutine "function any;" marked as inline is not inlined
« Reply #22 on: November 08, 2020, 01:35:29 pm »
Ok, this is nuts. It says it can't inline this:

Code: Pascal  [Select][+][-]
  1. PROCEDURE SetLotagHi (VAR aLoTag: INTEGER; CONST aValue: INTEGER);
  2. BEGIN
  3.   aLoTag := (aLoTag AND $00FFFFFF) OR (aValue SHL 24)
  4. END;

Or this other one:
Code: Pascal  [Select][+][-]
  1. FUNCTION GetLotagHi (CONST aLoTag, aValue: INTEGER): INTEGER;
  2. BEGIN
  3.   RESULT := (aLoTag AND $00FFFFFF) OR (aValue SHL 24)
  4. END;

I didn't get the assembler output (yet) to confirm if it is another false positive, but something is wrong with the INLINE generation for sure.

I'm about to get mad.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Note: Call to subroutine "function any;" marked as inline is not inlined
« Reply #23 on: November 08, 2020, 03:15:13 pm »
Ok, this is nuts. It says it can't inline this:

Please provide a full example. Both functions correctly inline both with 3.2.0 and trunk.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Note: Call to subroutine "function any;" marked as inline is not inlined
« Reply #24 on: November 10, 2020, 06:42:21 pm »
I can't.  I don't know why it works now. %)

I was trying to write a code snippet to show but it didn't show the hint in any way.  So I recompiled the project where I had the problem and that procedures didn't show any hint.  Just vanished. Disappeared.  And I didn't changed anything (except remove the temporary files, but I swear I did it before and the hints appeared).

I feel like somebody were pranking me.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

 

TinyPortal © 2005-2018