llvm-project/llvm/test/CodeGen/SPIRV/user-function-with-builtin-name.ll
Dmitry Sidorov 3d52f0c539
[SPIR-V] Don't consider a function be a builtin just by checking name (#182776)
If a function has the same name as a (n OpenCL) builtin, but not
matching number of arguments to the builtin - consider it to be a user
function.

Fixes: https://github.com/llvm/llvm-project/issues/165237
2026-03-04 10:41:14 +01:00

23 lines
813 B
LLVM

; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
; Verify that calling a function, that looks like a builtin, but has no matching
; number of arguments is treated as user function.
; "Barrier" with zero args - consider as user function.
; CHECK: OpFunctionCall %[[#]] %[[#]]
define spir_func void @test_too_few() {
call spir_func void @barrier()
ret void
}
; Too many args - consider as user function.
; CHECK: OpFunctionCall %[[#]] %[[#]] %[[#]] %[[#]] %[[#]] %[[#]]
define spir_func void @test_too_many() {
call spir_func void @_Z7barrieriiii(i32 1, i32 2, i32 3, i32 4)
ret void
}
declare spir_func void @barrier()
declare spir_func void @_Z7barrieriiii(i32, i32, i32, i32)