Is it possible that the AVX support in the JIT engine or x86-64 backend
is not mature? I am getting segfaults when switching from a vector
length 4 to 8 in my application. I isolated the barfing function and it
still segfaults in the minimal setup:
The IR attached implements the following simple function:
void bar(int start, int end, int ignore , bool add , bool addme , float* out, float* in)
{
int loop_start = add ? start+add : start;
int loop_end = add ? end+add : end;
loop_start /= 8;
loop_end /= 8;
for ( int i = loop_start ; i < loop_end ; ++i )
for ( int q = 0 ; q < 8 ; ++q )
out[ i * 8 + q ] = in[ i * 8 + q ];
}
The main.cc program implements the following:
Set loop vectorizer min trip count to 4
Create Module from file (given as program argument)
Set loop vectorizer debug info output
Optimize including loop vectorization
Create payload
Call function
Check result
I tried this on various CPUs. On those which support SSE only this program
works fine (vectorized to length 4). Now, running it on a CPU with AVX
support, the loop vectorizer goes for vector length 8, JIT'ing the function
works still fine but then the call to the function suddenly segfaults.
The LLVM website says that the x86-64 backend includes support for ISA
extensions such as MMX and SSE but it doesn't say explicitly AVX. Is this
on purpose and there's no AVX support?
We have two different code emitters for X86 in LLVM. The one used by the normal compiler and MCJIT and the other used by the legacy JIT. All of the test cases for AVX support go through the first one so it gets the most attention. We try to keep the legacy JIT in sync with it, but have a history of failing at that. The stack trace of the segfault may point to what part is missing.
(gdb) bt #0 0x00007ffff7f6506b in ?? () #1 0x000000000045d01a in main () at main.cc:165
Line 165 is the call to the function that was compiled by the JIT'er. Meaning that JIT'ing the function went well, but the code or the pointer are somehow corrupt.
There is no particular reason why I am working with the legacy interface. Would you recommend to use the MCJIT interface in general?
Bugs found in MCJIT are far more likely to get fixed. The aim is to
deprecate the old JIT as soon as possible, so solving problems in it don't
get priority.
For what it's worth, I'm also experiencing this same issue. If there is
interest I can provide some very simple reproducible test cases, but I was
planning on moving to MCJIT this week anyway.
I changed the code to use the MCJIT engine. As Josh suspected
it's the same issue: The program runs fine on SSE based machines,
but SEGFAULTs on a CPU with AVX extensions.
I attach the repro case.
Should I file a bug report? P.S. On bugzilla there is the component
'new-bugs'. Should all new bugs be filed there?
I changed the code to use the MCJIT engine. As Josh suspected
it's the same issue: The program runs fine on SSE based machines,
but SEGFAULTs on a CPU with AVX extensions.
I attach the repro case.
Should I file a bug report? P.S. On bugzilla there is the component
'new-bugs'. Should all new bugs be filed there?
Did you file a PR on this? If not, please do. Use: product: libraries, component: backend: x86.