summaryrefslogtreecommitdiffstats
path: root/tests/bugs
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-10-30 14:21:34 -0700
committerGitHub <noreply@github.com>2018-10-30 14:21:34 -0700
commit098dd5d87ef73528a14b5478616967f16f73a9ad (patch)
treececb84ae7d3b9c09c3eb239f7f7bdebb2215cc1a /tests/bugs
parentbaf06088dff0b961843ad03efd75ff009befec5c (diff)
Fix a crash on function-static variables with initializers (#703)
This code path hadn't been used, and it had a crash due to not inserting the basic blocks it created (for initializing the variable) into the parent function. The fix adds a bit more smarts to the `IRBuilder` to help with inserting basic blocks into the flow of a function. The actual user issue was around `static const` declarations, and it is clear that the code is incorrectly treating a function local `static const` as if it were just `static`. That will need to be fixed in another change.
Diffstat (limited to 'tests/bugs')
-rw-r--r--tests/bugs/ir-null-parent-crash.slang25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/bugs/ir-null-parent-crash.slang b/tests/bugs/ir-null-parent-crash.slang
new file mode 100644
index 000000000..ca4d0877d
--- /dev/null
+++ b/tests/bugs/ir-null-parent-crash.slang
@@ -0,0 +1,25 @@
+// ir-null-parent-crash.slang
+
+// Test an issue where Slang was crashing on functions that
+// have `static` variables with initializers.
+
+//TEST:SIMPLE:-target hlsl
+
+struct RNG
+{
+ uint state[2];
+}
+
+void jump(inout RNG rng)
+{
+ static uint32_t a[] = { 0x4, 0x2, 0x1, 0x3 };
+
+ uint32_t s0 = 0;
+
+ for (int i = 0; i < 4; i++)
+ {
+ s0 ^= rng.state[0];
+ }
+
+ rng.state[0] = s0;
+}