-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AVX-512f intrinsics fail to compile with MemorySanitizer #957
Comments
Looks like a bug in MemorySanitizer instrumentation pass, I would recommend reporting upstream. #include <immintrin.h>
unsigned test_mm_cvt_roundss_u32(__m128 __A) {
return _mm_cvt_roundss_u32(__A, _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC);
} # Note clang has assertions disabled.
$ clang -march=skylake-avx512 a.c -emit-llvm -S -fsanitize=memory
$ opt a.ll
opt: a.ll:36:9: error: stored value and pointer type do not match
store <4 x i32> %11, i32* bitcast ([100 x i64]* @__msan_retval_tls to i32*), align 8 # Note opt has assertions enabled.
$ clang -march=skylake-avx512 a.c -emit-llvm -S
$ opt a.ll -msan
opt: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2684: void {anonymous}::MemorySanitizerVisitor::handleVectorConvertIntrinsic(llvm::IntrinsicInst&, int): Assertion `CopyOp->getType() == I.getType()' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. |
I can try to forward your reproducer, but for now I'm still waiting for Bugzilla account approval. |
Oh, I forgot about those small roadblocks when reporting bugs to LLVM. I opened https://bugs.llvm.org/show_bug.cgi?id=48298. |
Thanks, glad it got fixed already!
I however get
|
Which clang version did you build? The one in https://github.com/rust-lang/llvm-project?
That command builds the standard library with the bootstrap compiler, which I think currently uses an older version than master. |
First I cherry-picked the fix for the cvt functions from upstream llvm (and committed the llvm submodule in the rust repo), ran my "build core with instrumentation" test, which proved that For more in-depth tests, and hopefully a reduction, I tried to get clang built from a rust checkout using
but |
#include <immintrin.h>
__m512 test_mm512_shuffle_ps(__m512 __M, __m512 __V) {
return _mm512_shuffle_ps(__M, __V, 78);
} $ clang -cc1 -target-feature +avx512f -ffreestanding -triple x86_64-unknown-linux-gnu -x c a.c -internal-isystem /usr/lib64/clang/11.0.0/include -S -emit-obj -fsanitize=memory
clang: llvm/lib/Target/X86/X86ISelLowering.cpp:12493: llvm::SDValue lowerShuffleAsByteRotate(const llvm::SDLoc&, llvm::MVT, llvm::SDValue, llvm::SDValue, llvm::ArrayRef<int>, const llvm::X86Subtarget&, llvm::SelectionDAG&): Assertion `(!VT.is512BitVector() || Subtarget.hasBWI()) && "512-bit PALIGNR requires BWI instructions"' failed. Reduced: ; ModuleID = 'a.c'
source_filename = "a.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: norecurse nounwind readnone
define <16 x i32> @shuffle(<16 x i32> %a, <16 x i32> %b) local_unnamed_addr #0 {
entry:
%c = shufflevector <16 x i32> %a, <16 x i32> %b, <16 x i32> <i32 2, i32 3, i32 16, i32 17, i32 6, i32 7, i32 20, i32 21, i32 10, i32 11, i32 24, i32 25, i32 14, i32 15, i32 28, i32 29>
ret <16 x i32> %c
}
attributes #0 = { norecurse nounwind readnone "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="512" "no-builtins" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+avx,+avx2,+avx512f,+cx8,+f16c,+fma,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 12.0.0 (https://github.com/llvm/llvm-project 530c69e90964444bc916d38b337105ab44f0961b)"} $ llc a.ll
llc: llvm/lib/Target/X86/X86ISelLowering.cpp:12493: llvm::SDValue lowerShuffleAsByteRotate(const llvm::SDLoc&, llvm::MVT, llvm::SDValue, llvm::SDValue, llvm::ArrayRef<int>, const llvm::X86Subtarget&, llvm::SelectionDAG&): Assertion `(!VT.is512BitVector() || Subtarget.hasBWI()) && "512-bit PALIGNR requires BWI instructions"' failed. |
Thanks! Forwarded: https://bugs.llvm.org/show_bug.cgi?id=48322 |
I found an issue when using the memory sanitizer (which requires rebuilding the standard library with extra flags). The compiler has problems generating code for _mm_cvt_roundss_u32 or _mm512_shuffle_ps.
I don't have a CPU supporting these, but enabling sanitizers does require linking everything due to warts in linkers and LLVM's coverage measurement runtime.
Here is a PR showing how to test this from the rust repository: rust-lang/rust#79382
Alternatively, it may be slightly faster to test it like this (also from a rust checkout):
The errors look like this:
And
The text was updated successfully, but these errors were encountered: