crash in WLF, triggered by specialized+inline function that fails to inline
|
|
Bugzilla Link |
943 |
Created on |
Mar 30, 2012 16:51 |
Version |
svn |
OS |
Linux |
Architecture |
PC |
Attachments |
inline-wlf.tar.gz |
Extended Description
Created an attachment (id=873)
demo for the bug
Compiler crashes in WLF; disabling WLF (-nowlf) makes it run...
Possibly there is more than one problem here. The shape of x=iota(4) is not inferred to be int[4], it stays simply int[.] (why?). Therefore, cwc:dfc pass cannot inline function 'suma', because it cannot statically match int[.] (from iota) and int[4] (from suma() specialization). Afterwards it crashes in wlf. Interestingly, it works when 'inline' on suma is removed. Perhaps there is a confusion somewhere that a function marked 'inline' is not actually inlined?
Amusingly, when you modify the source code below in *any* *one* of the following ways it works!
* removing inline on function 'suma'
* removing the shape specialization on 'suma', i.e. replacing 'int[SZ]' by 'int[.]'. This enables cwc:dfc to inline the function completely.
* replacing the iota() call with (currently commented out) direct assignment x=[0,1,2,3]; This also enables to inline suma().
/**********************************************************************
*
* SAC bug report: spec-inlined.sacbugreport
*
**********************************************************************
*
* Automatically generated on Fri Mar 30 16:20:45 BST 2012
*
* using sac2c v1.00-beta (Haggis And Apple) rev 17776:MODIFIED for linux-gnu_i686
* built Fri Mar 30 16:09:20 BST 2012.
* by user js308 on host lxjs308 for linux-gnu.
*
* The compiler was called by
* sac2c -o spec-inlined spec-inlined.sac
*
* The compiler crashed in
* phase: opt (Running SAC optimizations)
* sub phase: cyc (Optimization cycle)
* cycle phase: wlf (Applying with-loop folding)
* cycle instance: 1
*
* What follows is the contents of spec-inlined.sac.
*
**********************************************************************/
use Array: all;
use StdIO: all;
#define SZ 4
inline
int suma(int[SZ] x)
{
y = with {
(0*shape(x) <= iv < shape(x)) : x[iv];
} : fold(+, 0);
return y;
}
int main()
{
x = iota(SZ);
// x = [0, 1, 2, 3];
// print(x);
y = suma(x);
print(y);
return 0;
}
/**********************************************************************
*
* End of bug report
*
**********************************************************************/