Compiler bug found?

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
User avatar
dsteinwe
Experienced Member
Posts: 103
Joined: Wed Jun 29, 2016 8:59 am

Compiler bug found?

Post by dsteinwe »

Hi,

I have programmed following function:

Code: Select all

static bool powerdown_output(client i2c_master_if i2c, t_output output) {
   // some I2C communication ...

    if (output == 0 || output == 4) {
        for (uint8_t i = output + 1; i < output + 4; i++) {
            if (OUTPUT_CONFIG[i].source == OUTPUT_SOURCE_LINK) {
                powerdown_output(i2c, i); // problematic code line
            }
        }
    }

    return true;
}
It is no rocket science and works fine, as long as the calling code is the sole unit, that uses a core on a tile. If I use a further tile on the same tile, I get this compiler error:
Creating app_test3.xe
../src/app_test3.xc:(.dp.data.4+0x4): Error: Meta information ("_Spowerdown_output_0.nstackwords") for function "_Spowerdown_output_0" cannot be determined.
../src/app_test3.xc:(.dp.data.4+0x4): Error: lower bound could not be calculated (function is recursive?).
xmake[1]: *** [bin//app_test3.xe] Error 1
xmake: *** [bin//app_test3.xe] Error 2
If I have commented out the line:

Code: Select all

powerdown_output(i2c, i); // problematic code line
Now, I can compile it even with two core on the same tile. Yes, there is a recursion, but only with a depth of one.

This behaviour concerns the IDE version: Community_14.4.1 (build 235-acbb966, Dec-01-2019).

If you have more questions about it, feel free to ask.


User avatar
dsteinwe
Experienced Member
Posts: 103
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

Today, I got the same error again. In this case, I have a recursion. I have tried to reproduce the error with a test project with a trivial recursion, but the error didn't happen. It seems so, that the code/recursion needs higher complexity to raise this error. This error will happen, if you get following output on compiling (marked bold):

Constraint check for tile[0]:
Cores available: 8, used: 1+. MAYBE
Timers available: 10, used: 1+. MAYBE
Chanends available: 32, used: 1+. MAYBE
Memory available: 262144, used: 79628+. MAYBE
(Stack: 3612+, Code: 55368, Data: 20648)
Constraints checks PASSED WITH CAVEATS.
I have tried "#pragma stackfunction" and "#pragma stackcalls", but the message "PASSED WITH CAVEATS" is still output.

It seems so, you have to use a loop instead of a recursion to fix this errror.
User avatar
akp
XCore Expert
Posts: 566
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Working around the XC compiler's idiosyncrasies is how you level up
User avatar
dsteinwe
Experienced Member
Posts: 103
Joined: Wed Jun 29, 2016 8:59 am

Post by dsteinwe »

Ok, I think, I have now entered level 2 ;-).

I'm not sure, but possibly the following thread explains the cause of this idiosyncrasy:
https://www.xcore.com/viewtopic.php?f=2 ... =recursion