Skip to content
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

Missing support for 'fneg' LLVM operation #359

Closed
AlexeySachkov opened this issue Oct 21, 2019 · 0 comments · Fixed by #360
Closed

Missing support for 'fneg' LLVM operation #359

AlexeySachkov opened this issue Oct 21, 2019 · 0 comments · Fixed by #360
Labels
bug Something isn't working

Comments

@AlexeySachkov
Copy link
Contributor

llvm-spirv crashes on the following input:

; ModuleID = 'neg.bc'
source_filename = "neg.cl"
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir64"

; Function Attrs: convergent noinline nounwind optnone
define spir_kernel void @foo(float %a, float addrspace(1)* %b) #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !5 !kernel_arg_type !6 !kernel_arg_base_type !6 !kernel_arg_type_qual !7 {
entry:
  %a.addr = alloca float, align 4
  %b.addr = alloca float addrspace(1)*, align 8
  store float %a, float* %a.addr, align 4
  store float addrspace(1)* %b, float addrspace(1)** %b.addr, align 8
  %0 = load float, float* %a.addr, align 4
  %neg = fneg float %0
  %1 = load float addrspace(1)*, float addrspace(1)** %b.addr, align 8
  store float %neg, float addrspace(1)* %1, align 4
  ret void
}

attributes #0 = { convergent noinline nounwind optnone "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0}
!opencl.ocl.version = !{!1}
!opencl.spir.version = !{!2}
!llvm.ident = !{!3}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, i32 0}
!2 = !{i32 1, i32 2}
!3 = !{!"clang version 10.0.0-svn369720-1~exp1+0~20190823011559.2434~1.gbpf9fff7 (trunk)"}
!4 = !{i32 0, i32 1}
!5 = !{!"none", !"none"}
!6 = !{!"float", !"float*"}
!7 = !{!"", !""}

Backtrace:

#0  0x00007ffff33fd428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff33ff02a in __GI_abort () at abort.c:89
#2  0x00007ffff33f5bd7 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0xab57bb "Found && \"Invalid key\"",
    file=file@entry=0xab2300 "SPIRV-LLVM-Translator/lib/SPIRV/libSPIRV/SPIRVUtil.h", line=line@entry=90,
    function=function@entry=0xabb4a0 <SPIRV::SPIRVMap<unsigned int, spv::Op, void>::map(unsigned int)::__PRETTY_FUNCTION__> "static Ty2SPIRV::SPIRVMap<Ty1, Ty2, Identifier>::map(Ty1) [with Ty1 = unsigned int; Ty2 = spv::Op; Identifier = void]") at assert.c:92
#3  0x00007ffff33f5c82 in __GI___assert_fail (assertion=0xab57bb "Found && \"Invalid key\"",
    file=0xab2300 "SPIRV-LLVM-Translator/lib/SPIRV/libSPIRV/SPIRVUtil.h", line=90,
    function=0xabb4a0 <SPIRV::SPIRVMap<unsigned int, spv::Op, void>::map(unsigned int)::__PRETTY_FUNCTION__> "static Ty2 SPIRV::SPIRVMap<Ty1, Ty2, Identifier>::map(Ty1) [with Ty1 = unsigned int; Ty2 = spv::Op; Identifier = void]") at assert.c:101
#4  0x0000000000967420 in SPIRV::SPIRVMap<unsigned int, spv::Op, void>::map (Key=12)
    at SPIRV-LLVM-Translator/lib/SPIRV/libSPIRV/SPIRVUtil.h:90
#5  0x0000000000951fcd in SPIRV::LLVMToSPIRV::transUnaryInst (this=0xda9180, U=0xda4d48, BB=0xdb2eb0)
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:680
#6  0x0000000000954129 in SPIRV::LLVMToSPIRV::transValueWithoutDecoration (this=0xda9180, V=0xda4d48, BB=0xdb2eb0, CreateForward=false)
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:971
#7  0x0000000000951b97 in SPIRV::LLVMToSPIRV::transValue (this=0xda9180, V=0xda4d48, BB=0xdb2eb0, CreateForward=false)
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:636
#8  0x0000000000958afa in SPIRV::LLVMToSPIRV::transFunction (this=0xda9180, I=0xd9c748)
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:1681
#9  0x000000000095920b in SPIRV::LLVMToSPIRV::translate (this=0xda9180)
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:1733
#10 0x000000000094d806 in SPIRV::LLVMToSPIRV::runOnModule (this=0xda9180, Mod=...)
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:115
#11 0x00007ffff491fefa in llvm::legacy::PassManagerImpl::run(llvm::Module&) () from /usr/lib/llvm-9/lib/libLLVM-9.so.1
#12 0x000000000095ba9b in llvm::writeSpirv (M=0xd9a010, Opts=..., OS=..., ErrMsg="")
    at SPIRV-LLVM-Translator/lib/SPIRV/SPIRVWriter.cpp:2087
#13 0x00000000008686a0 in convertLLVMToSPIRV (Opts=...) at SPIRV-LLVM-Translator/tools/llvm-spirv/llvm-spirv.cpp:168
#14 0x0000000000869bce in main (Ac=2, Av=0x7fffffffe8d8) at SPIRV-LLVM-Translator/tools/llvm-spirv/llvm-spirv.cpp:380
@AlexeySachkov AlexeySachkov added the bug Something isn't working label Oct 21, 2019
neildhickey pushed a commit that referenced this issue Oct 28, 2019
It adds support for the fneg operation (added in LLVM 8.0.0) when
translating from LLVM IR to SPIR-V, using the SPIR-V FNegate operation.

Signed-off-by: Ilya Mashkov ilya.mashkov@intel.com

Fix #359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant