After adding this pragma to many routines I narrowed the problem to a file and peephole optimization:
#pragma optimization_level 0
Doing a binary search of that file using:
#pragma peephole off
...code...
#pragma peephole reset
I narrowed the problem to at leaset one function:
#define RADIO_FLAG_PACKET_ID (1<<1)
static uint8_t radio_last_packetID;
static void radioApi_TogglePacketID(uint8_t *packet_id)
{
radio_last_packetID = RADIO_FLAG_PACKET_ID & (~radio_last_packetID);
*packet_id &= ~RADIO_FLAG_PACKET_ID;
*packet_id |= radio_last_packetID;
}
disassembly of this code with and without peephole optimization comes down to this statement:
*packet_id &= ~RADIO_FLAG_PACKET_ID;
Here is the code disassembly differences:
; 106: static void radioApi_TogglePacketID(uint8_t *packet_id)
; 107: {
; 108: radio_last_packetID = RADIO_FLAG_PACKET_ID & (~radio_last_packetID);
;
0x00000000 _radioApi_TogglePacketID:
; radioApi_TogglePacketID:
0x00000000 0x73AD0000 mvz.b _radio_last_packetID(a5),d1
0x00000004 0x4681 not.l d1
0x00000006 0xA540 mov3q #2,d0
0x00000008 0xC280 and.l d0,d1
0x0000000A 0x1B410000 move.b d1,_radio_last_packetID(a5)
;
; 109: *packet_id &= ~RADIO_FLAG_PACKET_ID;
;
without peephole optimization gives this:
0x0000000E 0x70FD moveq #-3,d0
0x00000010 0x1210 move.b (a0),d1
0x00000012 0xC280 and.l d0,d1
0x00000014 0x1081 move.b d1,(a0)
with peephole optimization gives this:
0x0000000E 0xA341 mov3q #1,d1
0x00000010 0x0390 bclr d1,(a0)
Wayne