Skip to content

AVX-512f intrinsics fail to compile with MemorySanitizer #957

Open
@g2p

Description

@g2p

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):

time RUSTFLAGS_NOT_BOOTSTRAP="-Cpasses=sancov -Clink-dead-code -Zsanitizer=memory -C codegen-units=1" ./x.py build -i library/core 

The errors look like this:

LLVM ERROR: Cannot select: 0x7f96e9336bf0: v64i8 = X86ISD::PALIGNR 0x7f96e93296b0, 0x7f96e9381fe8, TargetConstant:i8<8>
  0x7f96e93296b0: v64i8,ch = load<(load 64 from %ir.2245)> 0x7f96f547cba8, 0x7f96e9337270, undef:i64
    0x7f96e9337270: i64 = xor 0x7f96e93298b8, 0x7f96e9279c58
      0x7f96e93298b8: i64,ch = CopyFromReg 0x7f96f547cba8, Register:i64 %1119
        0x7f96e93424a0: i64 = Register %1119
      0x7f96e9279c58: i64 = AssertZext 0x7f96e9272c00, ValueType:ch:i47
        0x7f96e9272c00: i64,ch = CopyFromReg 0x7f96f547cba8, Register:i64 %6
          0x7f96e927fad0: i64 = Register %6
    0x7f96e931fb58: i64 = undef
  0x7f96e9381fe8: v64i8 = bitcast 0x7f96e9344420
    0x7f96e9344420: v16i32,ch = CopyFromReg 0x7f96f547cba8, Register:v16i32 %782
   Compiling rustc-std-workspace-core v1.99.0 (/home/g2p/src/github.com/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/library/rustc-std-workspace-core)
      0x7f96e927a410: v16i32 = Register %782
  0x7f96e93820b8: i8 = TargetConstant<8>
In function: _ZN4core9core_arch3x867avx512f17_mm512_shuffle_ps17h2adad9c5dc64a280E

And

PHI node operands are not the same type as the result!
  %_msphi_s = phi i32 [ %42, %38 ], [ %35, %31 ], [ %28, %24 ], [ %21, %17 ], [ %14, %10 ]
in function _ZN4core9core_arch3x867avx512f19_mm_cvt_roundss_u3217h42028e7a281c0c10E
LLVM ERROR: Broken function found, compilation aborted!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions