Strange powerpc code generation bug
Original Reporter info from Mantis: Adriaan van Os
-
Reporter name: Adriaan van Os
Original Reporter info from Mantis: Adriaan van Os
- Reporter name: Adriaan van Os
Description:
I have a unit with a function MBMenuAddItemInternal (with macosx set to true)
function MBMenuAddItemInternal
( var theMenuRecord : MenuRecord;
theMenuOrSubMenuID : Int32;
theOptBeforeItemIndex : Int32;
var theItemsPtr : MenuItemsPtr;
const theItemStr : Str255;
theItemIconHandle : MenuIconHandle;
theEnableFlag : boolean;
theCheckFlag : boolean;
theCommandChar : char;
theCommandModifiers : Int16;
theItemCmdID : Int32;
const theItemAppStr : AnsiString;
var theNewItemIndex : Int32): MBError;
var
theErr : MBError;
{$ifc macosx}
theMacMenuRef : MenuRef;
{$endc}
begin
theItemsPtr := nil;
theNewItemIndex := 0;
{$ifc macosx}
theErr := MacMenuAddItemInternal
( theMenuRecord, theMenuOrSubMenuID, theOptBeforeItemIndex, theMacMenuRef, theItemsPtr,
theItemStr, theItemIconHandle, theEnableFlag, theCheckFlag, theCommandChar,
theCommandModifiers, theItemCmdID, theItemAppStr, theNewItemIndex);
{$endc}
MBMenuAddItemInternal := theErr
end;
that calls into another function
function MacMenuAddItemInternal
( var theMenuRecord : MenuRecord;
theMenuOrSubMenuID : Int32;
theOptBeforeItemIndex : Int32;
var theMenuRef : MenuRef;
var theItemsPtr : MenuItemsPtr;
const theItemStr : Str255;
theItemIconHandle : MenuIconHandle;
theEnableFlag : boolean;
theCheckFlag : boolean;
theCommandChar : char;
theCommandModifiers : Int16;
theItemCmdID : Int32;
const theItemAppStr : AnsiString;
var theNewItemIndex : Int32): MBError;
When compiling with -O3 or -O2 for powerpc the software hangs in MBMenuAddItemInternal and MacMenuAddItemInternal is never called. The code for i386 works fine. When I turn off optimizations locally, the software runs fine.
{$ifc powercpu}
{$optimization off}
function MBMenuAddItemInternal
( var theMenuRecord : MenuRecord;
theMenuOrSubMenuID : Int32;
theOptBeforeItemIndex : Int32;
var theItemsPtr : MenuItemsPtr;
const theItemStr : Str255;
theItemIconHandle : MenuIconHandle;
theEnableFlag : boolean;
theCheckFlag : boolean;
theCommandChar : char;
theCommandModifiers : Int16;
theItemCmdID : Int32;
const theItemAppStr : AnsiString;
var theNewItemIndex : Int32): MBError;
var
theErr : MBError;
{$ifc macosx}
theMacMenuRef : MenuRef;
{$endc}
begin
theItemsPtr := nil;
theNewItemIndex := 0;
{$ifc macosx}
theErr := MacMenuAddItemInternal
( theMenuRecord, theMenuOrSubMenuID, theOptBeforeItemIndex, theMacMenuRef, theItemsPtr,
theItemStr, theItemIconHandle, theEnableFlag, theCheckFlag, theCommandChar,
theCommandModifiers, theItemCmdID, theItemAppStr, theNewItemIndex);
{$endc}
MBMenuAddItemInternal := theErr
end;
{$endc}
Sorry for not providing yet a full reproducable case (which would take time putting everything together, you may still want to have a look first). I suspect that something goes wrong in the register allocator. Note that MacMenuAddItemInternal has one extra parameter "theMenuRef" inserted as compared to its caller. For the rest, nothing spectacular happens in MBMenuAddItemInternal.
Mantis conversion info:
- Mantis ID: 27634
- OS: OS X
- OS Build: 10.6
- Platform: Darwin
- Version: 2.6.4
- Fixed in version: 3.0.0
- Fixed in revision: 30164 (#fc218456)