Menu

#3286 [MCS-51] ICE with --stack-auto and 64-bit argument

open
nobody
None
MCS51
5
2023-11-15
2021-10-03
Oleg Endo
No

Compiling the example below with '--stack-auto' will fail in the function 'func_0_ng'.

error 9: FATAL Compiler Internal Error in file '../../../sdcc_svn/sdcc/src/mcs51/gen.c' line number '478' : getFreePtr should never reach here

'func'0_ok' is a workaround that I'm using for now.
My SDCC version is 4.1.6 #12575 (with some local seemingly unrelated modifications).

#include <stdint.h>

extern uint8_t func_2 (void);
extern void func_1 (void) __banked;

__xdata uint32_t g_x = 0;

#if 1
void func_0_ng (uint64_t x) __banked
{
  if (func_2 ())
  {
    if (g_x == 0)
      g_x = (uint32_t)x | 1;

    if ((uint32_t)x - g_x > 10)
      func_1 ();
  }
}
#endif


#if 1
void func_0_ok (uint64_t x_) __banked
{
  uint32_t x = x_;

  if (func_2 ())
  {
    if (g_x == 0)
      g_x = (uint32_t)x | 1;

    if ((uint32_t)x - g_x > 10)
      func_1 ();
  }
}
#endif

Discussion

  • Oleg Endo

    Oleg Endo - 2023-07-23

    A slightly reduced case:

    extern void func_1 (void) __banked;
    
    __xdata uint32_t g_x = 0;
    
    void func_0_ng (uint64_t x) __banked
    {
      if (g_x == 0)
        if ((uint32_t)x - g_x > 10)
          func_1 ();
    }
    
     
  • Oleg Endo

    Oleg Endo - 2023-11-15

    Issue still present as of SVN r14412.
    @spth I guess this will evaporate with the new register alloactor?

     

Log in to post a comment.