Menu

#2555 SDCC uses far too much memory

open
nobody
None
other
6
2020-08-06
2016-10-23
No

When compiling the attached file using current sdcc 3.6.3 #9787, on my Debian GNU/Linux system, SDCC uses too much memory. I tried compiling for mcs51 and stm8; for both targets, SDCC uses more than 16 GB of RAM (at which point I killed SDCC) during compilation.

The file has about 2000 lines and contains a function of about 1200 lines with 200 local variables. Big, but not unreasonable. It was obtained by using the LLVM+SDCC toolchain on the longlong regression test.

Philipp

P.S.: I've seen high memory use on few other files, too. But this seems to be the worst among files obtained from our regression tests.

1 Attachments

Related

Bugs: #2686
Bugs: #2759

Discussion

  • Philipp Klaus Krause

    The problem seems tobe in CSE. I started sdcc five times under gdb, then stopped it after a while when it had started eating up my memory, and looked at the backtraces. Here is the common part among them:

    #8  0x00005555555cc370 in applyToSet (list=<optimized out>, somefunc=somefunc@entry=0x5555555d9fe0 <mergeInExprs>) at SDCCset.c:549
    #9  0x00005555555da483 in computeDataFlow (ebbi=ebbi@entry=0x555556b831e0) at SDCCdflow.c:238
    #10 0x00005555555d6e9a in cseBBlock (ebb=0x555556b8d000, computeOnly=computeOnly@entry=0, ebbi=ebbi@entry=0x555556b831e0) at SDCCcse.c:2624
    #11 0x00005555555d920a in cseAllBlocks (ebbi=ebbi@entry=0x555556b831e0, computeOnly=computeOnly@entry=0) at SDCCcse.c:2643
    #12 0x0000555555593707 in eBBlockFromiCode (ic=<optimized out>) at SDCCopt.c:2497
    #13 0x00005555555ab718 in createFunction (name=0x555555dfe0a0, body=0x55555625d9f0) at SDCCast.c:7277
    #14 0x0000555555579ba2 in yyparse () at SDCC.y:199
    #15 0x0000555555576604 in main (argc=3, argv=<optimized out>, envp=<optimized out>) at SDCCmain.c:2546
    

    Philipp

     
  • Juan Castillo

    Juan Castillo - 2016-11-25

    Same problem here. I try to compile a file with a reasonably large function for 8051 and SDCC eats all the computer memory until I have to kill the process. I have reproduced the issue on two environments:

    SDCC 3.6 --> 3.6.0 #9615 (MINGW64) <-- Downloaded from SF
    SDCC 3.3 --> 3.3.0 #8604 (Dec 30 2013) (Linux) <-- Included in Ubuntu 14.04 LTS

    Build command line:
    sdcc --noinduction --nooverlay --no-peep --model-large --std-c99 --debug -I ./include -c -o build/main.rel src/main.c

    Same file builds successfully with SDCC 2.6.3 #4543 (Dec 31 2006) (MINGW32). This (very old) version of SDCC is provided with SoftConsole v3.4, so it might have been patched by Microsemi (refer to SoftConsole Release Notes).

    I do not have much experience with SDCC, so I cannot provide much more info about the issue.

    Thanks,
    Juan

     
    • Philipp Klaus Krause

      Could you create a minimal code example from your code to reproduce this bug? Your code seems to be the first real-world hand-written code to trigger this bug. Before we only had code genrated by the LLVM C backend (which as you can see from the file.cbe.c attachment is not very human-readable).

      Philipp

       
  • Philipp Klaus Krause

    • Priority: 5 --> 6
     
  • Juan Castillo

    Juan Castillo - 2016-11-26

    Sadly, I can't share the file because it's propietary code from the company I work for. I can tell you that the function is over 1000 lines and it has around 40 local variables (I will know the exact numbers when I get back to work on Monday). Nesting level is reasonably high (around 7 levels). Other than that, it is quite a simple function.

    We should have split the code in smaller functions instead of copy-paste everything in the same one, but we were in a hurry and we didn't do much software engineering (I am starting to regret it, though). That's probably the reason no one hit this bug before.

     
  • Erik Petrich

    Erik Petrich - 2018-06-12

    When compiling this for stm8, the current [r10436] revision is down to about 855 MB.

     
  • Sergey Belyashov

    When compiling this for z80, the current [r11800] revision eats about 509 MB.
    I think Bug [#2009] is related.

     

    Related

    Bugs: #2009


Log in to post a comment.

Auth0 Logo