[llvm] [SPIR-V] Emit builtin variable OpVariable into entry block (PR #189958)

Viktoria Maximova via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 10:46:33 PDT 2026


================
@@ -0,0 +1,33 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+;; Verify that builtin variable OpVariable is emitted in the entry block
+;; so its def dominates all uses, even when the same builtin is called
+;; in multiple non-entry blocks.
----------------
vmaksimo wrote:

The "entry block" wording is a bit confusing - it could be read as the SPIR-V function entry block. Clarify a bit:
```suggestion
;; Verify correct translation when the same builtin is called from multiple
;; non-entry blocks. The fix is validated by -verify-machineinstrs that fails
;; if the OpVariable's VReg definition does not dominate all its uses in MIR.
```

https://github.com/llvm/llvm-project/pull/189958


More information about the llvm-commits mailing list