When generating code for an SDFG with a single for loop containing a continue statement, codegen generates an infinite loop by inserting a wrongful goto in place of a continue statement.
The behavior occurs with Python 3.7, automatic simplification disabled, and control flow detection enabled (as is the default).
A minimal example SDFG that exposes the issue is shown here:
The following code is generated:
void __program_test_for_continue_internal(test_for_continue_state_t*__state, int * __restrict__ A)
{
long long i;
for (i = 0; (i < 10); i = i+1) {
if (((i % 2) == 0)) {
if (false) {
}
__state_0_s_6:;
}
{
{
int o1;
///////////////////
// Tasklet code (assign)
o1 = i;
///////////////////
A[i] = o1;
}
}
goto __state_0_s_6;
}
}
Evidently, the goto to label __state_0_s_6 causes an infinite loop. The expected behavior would be that:
Either a continue is generated in place of the label __state_0_s_6
or the position of the label and the goto statements is inverted.
When generating code for an SDFG with a single for loop containing a continue statement, codegen generates an infinite loop by inserting a wrongful goto in place of a continue statement. The behavior occurs with Python 3.7, automatic simplification disabled, and control flow detection enabled (as is the default).
A minimal example SDFG that exposes the issue is shown here:
The following code is generated:
Evidently, the goto to label
__state_0_s_6
causes an infinite loop. The expected behavior would be that:continue
is generated in place of the label__state_0_s_6
The issue can be reproduced by running the test found here: https://github.com/spcl/dace/blob/cfg_detection_infinite_loop_bug/tests/control_flow_test.py#L351
Note: This is a blocking issue for one of the final Loops PRs as it causes a single test to hang: https://github.com/spcl/dace/pull/1475