[clang] [DXIL] Don't generate per-variable guards for DirectX (PR #106096)

Damyan Pepper via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 26 09:13:38 PDT 2024


================
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o - -disable-llvm-passes %s | FileCheck %s
+
+// Verify that no per variable _Init_thread instructions are emitted for non-trivial static locals
+// These would normally be emitted by the MicrosoftCXXABI, but the DirectX backend should exlude them
+// Instead, check for the guardvar oparations that should protect the constructor initialization should
+// only take place once.
+
+RWBuffer<int> buf[10];
+
+void InitBuf(RWBuffer<int> buf) {
+  for (unsigned i; i < 100; i++)
----------------
damyanp wrote:

FWIW, DXC emits an error for this line: https://godbolt.org/z/5dT7o8fsh

Changing it to `unsigned int` makes it happy, but it seems neither compiler minds that `i` is uninitialized, which is interesting!

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


More information about the cfe-commits mailing list