Menu

#2752 inline and __reentrant causes bad code generation on MCS51

closed-fixed
None
other
7
2018-10-13
2018-05-24
No

Calling a function decorated with both inline and __reentrant causes bad code generation on MCS51. In the example below, SDCC inserts two rogue inc sp instructions. When I remove __reentrant, the code looks correct

Command to compile:
sdcc-sdcc -c x.c

$ sdcc-sdcc -v
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.6.0 #9615 (Linux)
published under GNU General Public License (GPL)

1 Attachments
x.c

Discussion

  • Philipp Klaus Krause

    • Priority: 5 --> 7
     
  • Philipp Klaus Krause

    This bug also affects ds390 (but not other backends, in particular it does not affect hc08 despite that one otherwise being similar inhandling of reentrancy).

    In [r10413], I added a test (currently disabled for mcs51 and ds390).

    Increasing priority, since bad code is generated silently.

    Philipp

     
  • Philipp Klaus Krause

    This bug also affects ds390 (but not other backends, in particular it does not affect hc08).

    In [r10413], I added a test (currently disabled for mcs51 and ds390).

    Increasing priority, since bad code is generated silently.

    Philipp

    P.S.: However, hc08 also does an apparently unnecessary stack adjustment by 2, it hust readjusts the stack accordingly at function exit, so it only wastes stack space, but does not jump into the void.

     
  • Erik Petrich

    Erik Petrich - 2018-06-04
    • status: open --> closed-fixed
    • assigned_to: Erik Petrich
     
  • Erik Petrich

    Erik Petrich - 2018-06-04

    Fixed in [r10420]

     
  • Maarten Brock

    Maarten Brock - 2018-10-13
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Calling a function decorated with both inline and __reentrant causes bad code generation on MCS51. In the example below, SDCC inserts two rogue inc sp instructions. When I remove __reentrant, the code looks correct
    +Calling a function decorated with both inline and \_\_reentrant causes bad code generation on MCS51. In the example below, SDCC inserts two rogue inc sp instructions. When I remove \_\_reentrant, the code looks correct
    
     Command to compile:
     sdcc-sdcc -c x.c
    
     

Log in to post a comment.