Skip to content

Commit 1c89640

Browse files
maarquitos14vmaksimo
authored andcommitted
Ignore llvm.fake.use (#3264)
There's no SPIRV translation for `llvm.fake.use`, and currently it's causing the translator to crash, so just ignore it to prevent crashes. Original commit: KhronosGroup/SPIRV-LLVM-Translator@daada5684da36fd
1 parent 1e42a1b commit 1c89640

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3996,6 +3996,7 @@ bool LLVMToSPIRVBase::isKnownIntrinsic(Intrinsic::ID Id) {
39963996
case Intrinsic::masked_gather:
39973997
case Intrinsic::masked_scatter:
39983998
case Intrinsic::modf:
3999+
case Intrinsic::fake_use:
39994000
return true;
40004001
default:
40014002
// Unknown intrinsics' declarations should always be translated
@@ -4984,6 +4985,8 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
49844985
case Intrinsic::trap:
49854986
case Intrinsic::ubsantrap:
49864987
case Intrinsic::debugtrap:
4988+
// Just ignore llvm.fake.use intrinsic, as it has no translation in SPIRV.
4989+
case Intrinsic::fake_use:
49874990
// llvm.instrprof.* intrinsics are not supported
49884991
case Intrinsic::instrprof_increment:
49894992
case Intrinsic::instrprof_increment_step:
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -spirv-text -o %t
3+
; RUN: FileCheck < %t %s
4+
; RUN: llvm-spirv %t.bc -o %t.spv
5+
; RUN: spirv-val %t.spv
6+
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
7+
target triple = "spir-unknown-unknown"
8+
9+
; Function Attrs: nounwind
10+
; CHECK: Capability Addresses
11+
; CHECK: "foo"
12+
13+
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
14+
declare void @llvm.fake.use(...)
15+
16+
define spir_kernel void @foo(ptr addrspace(1) %a) {
17+
entry:
18+
call void (...) @llvm.fake.use(i8 undef)
19+
ret void
20+
}

0 commit comments

Comments
 (0)