Skip to content

Commit 15aa73e

Browse files
svenvhAlexeySotkin
authored andcommitted
Correctly report unsupported intrinsic
The translator would report the name of the destination variable of an intrinsic call, which is not very helpful to a user. Report the offending intrinsic name, and update and unXFAIL a test to check the error message. For the test, we need to run `not` with `--crash`, as the translator currently asserts on errors and we need to ignore crashes to be able to FileCheck the stderr output.
1 parent d5d981a commit 15aa73e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,8 @@ SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
11971197
// LLVM intrinsic functions shouldn't get to SPIRV, because they
11981198
// would have no definition there.
11991199
BM->getErrorLog().checkError(false, SPIRVEC_InvalidFunctionCall,
1200-
II->getName().str(), "", __FILE__, __LINE__);
1200+
II->getCalledValue()->getName().str(), "",
1201+
__FILE__, __LINE__);
12011202
}
12021203
return nullptr;
12031204
}

test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
tool_dirs = [config.llvm_tools_dir, config.llvm_spirv_dir]
4949

50-
tools = ['llc', 'llvm-as', 'llvm-dis', 'llvm-dwarfdump', 'llvm-objdump', 'llvm-readelf', 'llvm-readobj', 'llvm-spirv']
50+
tools = ['llc', 'llvm-as', 'llvm-dis', 'llvm-dwarfdump', 'llvm-objdump', 'llvm-readelf', 'llvm-readobj', 'llvm-spirv', 'not']
5151

5252
llvm_config.add_tool_substitutions(tools, tool_dirs)
5353

test/llvm.fma.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
; Translator should not translate llvm intrinsic calls straight forward.
2-
; It either represnts intrinsic's semantics with SPIRV instruction(s), or
2+
; It either represents intrinsic's semantics with SPIRV instruction(s), or
33
; reports an error.
4-
; XFAIL: *
54
; RUN: llvm-as %s -o %t.bc
6-
; RUN: llvm-spirv %t.bc
5+
; RUN: not --crash llvm-spirv %t.bc 2>&1 | FileCheck %s
6+
7+
; CHECK: InvalidFunctionCall: Unexpected llvm intrinsic: llvm.fma.f32
78

89
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
910
target triple = "spir64"

0 commit comments

Comments
 (0)