diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2019-01-16 09:15:02 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-16 09:15:02 -0800 |
| commit | c260e6aa3a7dc3e6794442daacde3ae23f029e0b (patch) | |
| tree | 2985f616ac8085168b1c5dce13f566f217559fc9 /tests | |
| parent | f0633a7d0b1615f6b115d53763bedeeb857b7f3c (diff) | |
Fix a bug in IR linking (#777)
The IR linking logic was recently rewritten to use the (optional) `IRLinkageDecoration`s instead of assuming `IRGlobalVals` always have a mangled name field, and in that process a bug seems to have crept in where in the case that an instruction that would usually quality as a "global value" does *not* have linkage, we were failing to register the instruction we create in the output module as a replacement for the original instruction.
This problem affects `static` variables inside of functions, leading to them potentially getting emitted multiple times.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/static-var.slang | 22 | ||||
| -rw-r--r-- | tests/bugs/static-var.slang.expected.txt | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/bugs/static-var.slang b/tests/bugs/static-var.slang new file mode 100644 index 000000000..f060586ad --- /dev/null +++ b/tests/bugs/static-var.slang @@ -0,0 +1,22 @@ +// gh-775-ext.slang +//TEST(compute):COMPARE_COMPUTE: + +int test(int inVal) +{ + static int kVal = 16; + return inVal + kVal; +} + +//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):dxbinding(0),glbinding(0),out +RWStructuredBuffer<int> outputBuffer : register(u0); + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int inVal = int(tid); + int outVal = test(inVal); + + outputBuffer[tid] = outVal; +}
\ No newline at end of file diff --git a/tests/bugs/static-var.slang.expected.txt b/tests/bugs/static-var.slang.expected.txt new file mode 100644 index 000000000..a0d427709 --- /dev/null +++ b/tests/bugs/static-var.slang.expected.txt @@ -0,0 +1,4 @@ +10 +11 +12 +13 |
