diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-09 01:23:56 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-08 10:23:56 -0700 |
| commit | 50f44c178de4c614dc45fc48938e6881c0373f6a (patch) | |
| tree | 6e4c33fb14e3955a496dd65faf36041e83fddc49 | |
| parent | 842dee3b6b62c7eb37134e3e27b2ebebdde99b42 (diff) | |
Look through attributes and rates when determining by reference initialization (#5023)
* Look through attributes and rates when determining by reference initialization
Closes #5022
* Make type of unwrapAttributedType more specific
* loosen type of unwrapAttributedType
* Discard changes to source/slang/slang-emit-spirv.cpp
* Discard changes to source/slang/slang-ir-check-differentiability.cpp
* Discard changes to source/slang/slang-ir.cpp
* Discard changes to source/slang/slang-ir.h
* Update slang-ir-use-uninitialized-values.cpp
* Remove redundant cast
---------
Co-authored-by: Yong He <yonghe@outlook.com>
| -rw-r--r-- | source/slang/slang-ir-use-uninitialized-values.cpp | 2 | ||||
| -rw-r--r-- | tests/bugs/gh-5022.slang | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/source/slang/slang-ir-use-uninitialized-values.cpp b/source/slang/slang-ir-use-uninitialized-values.cpp index c09077528..98fd9841a 100644 --- a/source/slang/slang-ir-use-uninitialized-values.cpp +++ b/source/slang/slang-ir-use-uninitialized-values.cpp @@ -265,7 +265,7 @@ namespace Slang // Consider it as a store if its passed // as an out/inout/ref parameter - IRType* type = ftype->getParamType(index); + auto type = unwrapAttributedType(ftype->getParamType(index)); return (as<IROutType>(type) || as<IRInOutType>(type) || as<IRRefType>(type)) ? Store : Load; } diff --git a/tests/bugs/gh-5022.slang b/tests/bugs/gh-5022.slang new file mode 100644 index 000000000..6d1b71991 --- /dev/null +++ b/tests/bugs/gh-5022.slang @@ -0,0 +1,22 @@ +//TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu + +// CHECK: 0 +// CHECK-NEXT: 1 +// CHECK-NEXT: 2 +// CHECK-NEXT: 3 + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +groupshared int myInt; + +void set(__ref groupshared int i){ i = 1; } +int use(__ref groupshared int i){ return i; } + +[numthreads(4, 1, 1)] +void computeMain(uint i : SV_GroupIndex) +{ + set(myInt); + use(myInt); + outputBuffer[i] = i; +} |
