Skip to content

Conversation

aadeshps-mcw
Copy link
Contributor

@aadeshps-mcw aadeshps-mcw commented Aug 6, 2025

--Test for signed arithmetic overflow intrinsics, which is for now expectedly failing
--Test checking that no duplicate image types are emitted.

@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-backend-spir-v

Author: Aadesh Premkumar (aadeshps-mcw)

Changes

--Test for verifying that decorations are correctly applied to global variables
--Test for signed arithmetic overflow intrinsics, which is for now expectedly failing
--Test for verifying emission of correct image type


Full diff: https://github.com/llvm/llvm-project/pull/152289.diff

3 Files Affected:

  • (added) llvm/test/CodeGen/SPIRV/image_store.ll (+22)
  • (added) llvm/test/CodeGen/SPIRV/llvm-intrinsics/signed_arithmetic_overflow.ll (+30)
  • (added) llvm/test/CodeGen/SPIRV/spirv_global_variable_decoration.ll (+29)
diff --git a/llvm/test/CodeGen/SPIRV/image_store.ll b/llvm/test/CodeGen/SPIRV/image_store.ll
new file mode 100644
index 0000000000000..73ea6ad038de7
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/image_store.ll
@@ -0,0 +1,22 @@
+; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; Image types may be represented in two ways while translating to SPIR-V:
+; - OpenCL form, for example, '%opencl.image2d_ro_t',
+; - SPIR-V form, for example, '%spirv.Image._void_1_0_0_0_0_0_0',
+; but it is still one type which should be translated to one SPIR-V type.
+;
+; The test checks that the code below is successfully translated and only one
+; SPIR-V type for images is generated.
+
+; CHECK:     %[[#]] = OpTypeImage %[[#]] 2D
+; CHECK-NOT: %[[#]] = OpTypeImage %[[#]] 2D
+
+declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(ptr addrspace(1), ptr addrspace(2), <2 x float>, float)
+
+define spir_kernel void @read_image(ptr addrspace(1) %srcimg, ptr addrspace(2) %sampler){
+entry:
+  %spirvimg.addr = alloca target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), align 8
+  %val = call <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_ff(ptr addrspace(1) %srcimg, ptr addrspace(2) %sampler, <2 x float> zeroinitializer, float 0.0)
+  ret void
+}
diff --git a/llvm/test/CodeGen/SPIRV/llvm-intrinsics/signed_arithmetic_overflow.ll b/llvm/test/CodeGen/SPIRV/llvm-intrinsics/signed_arithmetic_overflow.ll
new file mode 100644
index 0000000000000..52f939faf0a9f
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/llvm-intrinsics/signed_arithmetic_overflow.ll
@@ -0,0 +1,30 @@
+; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -filetype=obj -o - | spirv-val %}
+; XFAIL: *
+;@llvm.sadd.with.overflow and @llvm.ssub.with.overflow has not been implemented.
+
+define spir_func void @test_sadd_overflow(ptr %out_result, ptr %out_overflow, i32 %a, i32 %b) {
+entry:
+  %res = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
+  %val = extractvalue { i32, i1 } %res, 0
+  %ofl = extractvalue { i32, i1 } %res, 1
+  store i32 %val, ptr %out_result
+  %zext_ofl = zext i1 %ofl to i8
+  store i8 %zext_ofl, ptr %out_overflow
+  ret void
+}
+
+declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32)
+
+define spir_func void @test_ssub_overflow(ptr %out_result, ptr %out_overflow, i32 %a, i32 %b) {
+entry:
+  %res = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
+  %val = extractvalue { i32, i1 } %res, 0
+  %ofl = extractvalue { i32, i1 } %res, 1
+  store i32 %val, ptr %out_result
+  %zext_ofl = zext i1 %ofl to i8
+  store i8 %zext_ofl, ptr %out_overflow
+  ret void
+}
+
+declare { i32, i1 } @llvm.ssub.with.overflow.i32(i32, i32)
diff --git a/llvm/test/CodeGen/SPIRV/spirv_global_variable_decoration.ll b/llvm/test/CodeGen/SPIRV/spirv_global_variable_decoration.ll
new file mode 100644
index 0000000000000..ce5ed087650cd
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/spirv_global_variable_decoration.ll
@@ -0,0 +1,29 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+@v1 = addrspace(1) global i32 42, !spirv.Decorations !2
+@v2 = addrspace(1) global float 1.0, !spirv.Decorations !4
+
+define i32 @use_globals() {
+entry:
+  %v1_ptr = addrspacecast i32 addrspace(1)* @v1 to i32*
+  %v1_val = load i32, i32* %v1_ptr
+
+  %v2_ptr = addrspacecast float addrspace(1)* @v2 to float*
+  %v2_val = load float, float* %v2_ptr
+  %v2_int = fptosi float %v2_val to i32
+
+  %sum = add i32 %v1_val, %v2_int
+  ret i32 %sum
+}
+
+; CHECK: OpDecorate %[[#PId1:]] Constant
+; CHECK: OpDecorate %[[#PId2:]] Constant
+; CHECK: OpDecorate %[[#PId2]] Binding 1
+; CHECK: %[[#PId1]] = OpVariable %[[#]] CrossWorkgroup %[[#]]
+; CHECK: %[[#PId2]] = OpVariable %[[#]] CrossWorkgroup %[[#]]
+
+!1 = !{i32 22}                          ; Constant
+!2 = !{!1}                             ; @v1
+!3 = !{i32 33, i32 1}                  ; Binding 1
+!4 = !{!1, !3}                         ; @v2

@aadeshps-mcw aadeshps-mcw marked this pull request as draft August 6, 2025 11:30
@aadeshps-mcw aadeshps-mcw changed the title [SPIRV] Addition of image_store.ll, signed_arithmetic_overflow.ll, spirv_global_varibale_declaration.ll [SPIRV] Addition of image_store.ll, signed_arithmetic_overflow.ll, spirv_global_variable_declaration.ll Aug 28, 2025
--Test for signed arithmetic overflow intrinsics, which is for now expectedly failing
@aadeshps-mcw aadeshps-mcw changed the title [SPIRV] Addition of image_store.ll, signed_arithmetic_overflow.ll, spirv_global_variable_declaration.ll [SPIRV] Addition of image_store.ll and signed_arithmetic_overflow.ll Aug 28, 2025
@aadeshps-mcw aadeshps-mcw marked this pull request as ready for review August 28, 2025 11:53
@michalpaszkowski michalpaszkowski merged commit 2b67f5e into llvm:main Sep 28, 2025
9 of 10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 29, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-ubuntu running on as-builder-9 while building llvm at step 16 "test-check-lldb-api".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/195/builds/15242

Here is the relevant piece of the build log for the reference
Step 16 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
...
PASS: lldb-api :: types/TestCharTypeExpr.py (1296 of 1305)
UNSUPPORTED: lldb-api :: windows/launch/missing-dll/TestMissingDll.py (1297 of 1305)
UNSUPPORTED: lldb-api :: windows/launch/replace-dll/TestReplaceDLL.py (1298 of 1305)
PASS: lldb-api :: types/TestRecursiveTypes.py (1299 of 1305)
PASS: lldb-api :: types/TestIntegerTypeExpr.py (1300 of 1305)
PASS: lldb-api :: types/TestShortType.py (1301 of 1305)
PASS: lldb-api :: types/TestShortTypeExpr.py (1302 of 1305)
PASS: lldb-api :: types/TestLongTypes.py (1303 of 1305)
PASS: lldb-api :: types/TestLongTypesExpr.py (1304 of 1305)
TIMEOUT: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py (1305 of 1305)
******************** TEST 'lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py' FAILED ********************
Script:
--
/usr/bin/python3.12 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --libcxx-include-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1 --libcxx-include-target-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu --arch aarch64 --build-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb --compiler /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang --dsymutil /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --lldb-obj-root /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb --lldb-libs-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --cmake-build-type Release --platform-url connect://jetson-agx-2198.lab.llvm.org:1234 --platform-working-dir /home/ubuntu/lldb-tests --sysroot /mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux --skip-category=lldb-server /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/python_api/process/cancel_attach -p TestCancelAttach.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 2b67f5e0b444976057f097a6e4872177d2a1cc8b)
  clang revision 2b67f5e0b444976057f097a6e4872177d2a1cc8b
  llvm revision 2b67f5e0b444976057f097a6e4872177d2a1cc8b

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx arguments
FAIL: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_scripted_implementation (TestCancelAttach.AttachCancelTestCase.test_scripted_implementation)

--

********************
Slowest Tests:
--------------------------------------------------------------------------
600.04s: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py
123.44s: lldb-api :: functionalities/progress_reporting/TestProgressReporting.py
70.54s: lldb-api :: commands/process/attach/TestProcessAttach.py
64.70s: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
60.87s: lldb-api :: commands/command/script_alias/TestCommandScriptAlias.py
35.02s: lldb-api :: functionalities/single-thread-step/TestSingleThreadStepTimeout.py
34.31s: lldb-api :: functionalities/completion/TestCompletion.py
31.36s: lldb-api :: functionalities/gdb_remote_client/TestGDBRemoteClient.py
31.17s: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
24.80s: lldb-api :: commands/statistics/basic/TestStats.py
20.67s: lldb-api :: functionalities/gdb_remote_client/TestPlatformClient.py
18.94s: lldb-api :: commands/dwim-print/TestDWIMPrint.py
18.77s: lldb-api :: python_api/find_in_memory/TestFindRangesInMemory.py
18.66s: lldb-api :: functionalities/thread/state/TestThreadStates.py

@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 29, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building llvm at step 12 "build-stage2-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/16392

Here is the relevant piece of the build log for the reference
Step 12 (build-stage2-unified-tree) failure: build (failure) (timed out)
...
616.556 [56/10/6648] Linking CXX executable bin/llvm-c-test
616.595 [56/9/6649] Linking CXX executable bin/llvm-opt-fuzzer
616.670 [56/8/6650] Linking CXX executable unittests/DebugInfo/DWARF/DebugInfoDWARFTests
616.681 [56/7/6651] Linking CXX executable bin/llvm-split
616.734 [56/6/6652] Linking CXX executable unittests/CodeGen/CGPluginTest/CGPluginTest
616.737 [56/5/6653] Linking CXX executable unittests/MI/MITests
616.782 [56/4/6654] Linking CXX executable bin/llvm-lto
616.803 [56/3/6655] Linking CXX executable bin/lld
642.901 [56/2/6656] Building CXX object tools/bugpoint-passes/CMakeFiles/BugpointPasses.dir/TestPasses.cpp.o
643.153 [55/2/6657] Linking CXX shared module lib/BugpointPasses.so
command timed out: 1200 seconds without output running [b'ninja'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1844.084990

mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
…lvm#152289)

--Test for signed arithmetic overflow intrinsics, which is for now
expectedly failing
--Test checking that no duplicate image types are emitted.

---------

Co-authored-by: Michal Paszkowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants