For example, this code has a variable length array (VLA) declaration that uses a variable, W, defined inside the region:
#pragma clava begin_outline imsmooth_out1
int W;
W = (int) ceil(4 * s);
float temp[2 * W + 1];
F2D *buffer;
float acc;
acc = 0.0;
#pragma clava end_outline imsmooth_out1
This leads to :
float acc;
F2D *buffer;
float temp[2 * W + 1];
int W;
imsmooth_out1(&W, &s, &acc);
Which is incorrect, because it declares W and defines it on the outlined function, both after W is used for defining the array. In this case, we could fix this by moving temp below the outlined function, that would only work for this case; it wouldn't fix the more generic case where temp can be used inside the region itself. Fixing this isn't trivial, and I see no way of doing it without turning the array dynamic. Converting all VLAs to malloc/calloc might make further sense considering that VLAs are banned in C++ and discouraged in modern C:
float acc;
F2D *buffer;
float *temp;
int W;
imsmooth_out1(&W, &s, &acc);
temp = (float*)malloc((2 * W + 1) * sizeof(float));
For example, this code has a variable length array (VLA) declaration that uses a variable,
W, defined inside the region:This leads to :
Which is incorrect, because it declares
Wand defines it on the outlined function, both afterWis used for defining the array. In this case, we could fix this by movingtempbelow the outlined function, that would only work for this case; it wouldn't fix the more generic case wheretempcan be used inside the region itself. Fixing this isn't trivial, and I see no way of doing it without turning the array dynamic. Converting all VLAs to malloc/calloc might make further sense considering that VLAs are banned in C++ and discouraged in modern C: