KhronosGroup / SPIRV-LLVM

This project is no longer active. Please join us at
https://github.com/KhronosGroup/SPIRV-LLVM-Translator
Other
262 stars 60 forks source link

SPIRV Writer fails with "Can't translate llvm.memset with non-zero value argument" #203

Closed ex-rzr closed 7 years ago

ex-rzr commented 7 years ago

I see this assertion when I use -emit-spirv with these files: https://github.com/KhronosGroup/SPIR/blob/spirv-1.1/test/OpenCL/OpenCL22/attributes/TestBasicAttributes_kernel.cl https://github.com/KhronosGroup/libclcxx/blob/master/test/libclcxx/address_spaces/TestAddrSpaceTypeConstantPtr.cl https://github.com/KhronosGroup/libclcxx/blob/master/test/libclcxx/address_spaces/TestAddrSpaceTypeGlobalPtr.cl https://github.com/KhronosGroup/libclcxx/blob/master/test/libclcxx/address_spaces/TestAddrSpaceTypeLocalPtr.cl https://github.com/KhronosGroup/libclcxx/blob/master/test/libclcxx/address_spaces/TestAddrSpaceTypePrivatePtr.cl

clang -cc1 -emit-spirv -triple=spir-unknown-unknown -cl-std=c++ assert-memset.cl
clang: .../llvm/lib/SPIRV/SPIRVWriter.cpp:1296: SPIRV::SPIRVValue* SPIRV::LLVMToSPIRV::transIntrinsicInst(llvm::IntrinsicInst*, SPIRV::SPIRVBasicBlock*):
Assertion `!"Can't translate llvm.memset with non-zero value argument"' failed.

Here my test case:

struct S1
{
    int x;
    int y;
};

S1 foo11()
{
    return S1();
}

S1 foo12()
{
    return S1{};
}

S1 foo13()
{
    S1 s;
    return s;
}

class S2
{
    int x;
    int y;
};

S2 foo21()
{
    return S2();
}

S2 foo22()
{
    return S2{};
}

S2 foo23()
{
    S2 s;
    return s;
}

foo11 - fail foo12 - ok foo13 - ok

foo21 - fail foo22 - fail foo23 - ok

Full stack trace: assert-memset.txt LLVM: assert-memset.ll.txt

(GCC 6.3.1 on linux and VS2015 on windows in Debug)