diff --git a/source/slang/slang-ir-use-uninitialized-values.cpp b/source/slang/slang-ir-use-uninitialized-values.cpp index e4374b1f1f..66e692bf95 100644 --- a/source/slang/slang-ir-use-uninitialized-values.cpp +++ b/source/slang/slang-ir-use-uninitialized-values.cpp @@ -70,7 +70,6 @@ namespace Slang case kIROp_FieldAddress: case kIROp_GetElement: case kIROp_GetElementPtr: - // TODO: array index return true; default: break; @@ -104,13 +103,14 @@ namespace Slang if (as(type)) return true; - if (as(type)) - return true; - // For structs, ignore if its empty if (as(type)) return (type->getFirstChild() == nullptr); + // Nothing to initialize for a pure interface + if (as(type)) + return true; + return false; } @@ -182,6 +182,12 @@ namespace Slang stores.add(user->getParent()); break; + case kIROp_MakeExistential: + case kIROp_MakeExistentialWithRTTI: + // For specializing generic structs + stores.add(user); + break; + // ... and the rest will load/use them default: loads.add(user); diff --git a/tests/bugs/gh-1990.slang b/tests/bugs/gh-1990.slang index 9c496b04ac..4baceee1fc 100644 --- a/tests/bugs/gh-1990.slang +++ b/tests/bugs/gh-1990.slang @@ -28,11 +28,7 @@ struct StandardBSDF : IBSDF struct StandardMaterial : IMaterial { typedef StandardBSDF BSDF; - StandardBSDF setupBSDF() - { - StandardBSDF g = StandardBSDF(); - return g; - } + StandardBSDF setupBSDF() { StandardBSDF g; return g; } }; //TEST_INPUT:ubuffer(data=[0], stride=4):out,name=gOutputBuffer diff --git a/tests/bugs/interface-type-self-ref.slang b/tests/bugs/interface-type-self-ref.slang index eef5fe0c11..e3b1fe7cca 100644 --- a/tests/bugs/interface-type-self-ref.slang +++ b/tests/bugs/interface-type-self-ref.slang @@ -27,6 +27,6 @@ int f(IFoo p) void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) { int index = dispatchThreadID.x; - Impl impl = Impl(); + Impl impl; outputBuffer[index] = f(impl); } diff --git a/tests/bugs/specialize-existential-in-generic.slang b/tests/bugs/specialize-existential-in-generic.slang index 85920185f7..695c7bc295 100644 --- a/tests/bugs/specialize-existential-in-generic.slang +++ b/tests/bugs/specialize-existential-in-generic.slang @@ -15,7 +15,7 @@ interface IFoo struct Impl : IFoo { struct Assoc : IAssoc { int getInner() { return 1; } } - Assoc getValue() { Assoc r = Assoc(); return r; } + Assoc getValue() { Assoc r; return r; } } struct GenType diff --git a/tests/diagnostics/no-type-conformance.slang b/tests/diagnostics/no-type-conformance.slang index f447f1047d..ada4f663a7 100644 --- a/tests/diagnostics/no-type-conformance.slang +++ b/tests/diagnostics/no-type-conformance.slang @@ -8,7 +8,7 @@ interface IFoo void foo() { - IFoo obj = IFoo(); + IFoo obj; obj.get(); } @@ -16,4 +16,4 @@ void foo() void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { foo(); -} +} \ No newline at end of file diff --git a/tests/experiments/generic/type-to-value-4.slang b/tests/experiments/generic/type-to-value-4.slang index 9213caf04a..8d768b54b2 100644 --- a/tests/experiments/generic/type-to-value-4.slang +++ b/tests/experiments/generic/type-to-value-4.slang @@ -67,7 +67,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { // Err.. even though IGetE doesn't require an instanciation, not clear how to set it. So lets try with instanciation - B b = B(); + B b; IGetE g = b; let e = g.getE(); diff --git a/tests/language-feature/generics/generic-interface-2.slang b/tests/language-feature/generics/generic-interface-2.slang index dd400397b4..9a44f679ca 100644 --- a/tests/language-feature/generics/generic-interface-2.slang +++ b/tests/language-feature/generics/generic-interface-2.slang @@ -31,7 +31,7 @@ RWStructuredBuffer outputBuffer; [numthreads(1, 1, 1)] void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) { - MyType<3> t = MyType<3>(); + MyType<3> t; test(t); // CHECK: 3 outputBuffer[0] = test(t); diff --git a/tests/language-feature/if-let/if-let-1.slang b/tests/language-feature/if-let/if-let-1.slang index e3b9538a46..c197f26eaf 100644 --- a/tests/language-feature/if-let/if-let-1.slang +++ b/tests/language-feature/if-let/if-let-1.slang @@ -67,8 +67,8 @@ int test1(T t) [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { - MyImpl1 impl1 = MyImpl1(); - MyImpl2 impl2 = MyImpl2(); + MyImpl1 impl1; + MyImpl2 impl2; // CHECK: 1 // CHECK: 7 outputBuffer[0] = test(impl1, 1); diff --git a/tests/language-feature/if-let/if-let.slang b/tests/language-feature/if-let/if-let.slang index 28fef4f66c..5bb31030fe 100644 --- a/tests/language-feature/if-let/if-let.slang +++ b/tests/language-feature/if-let/if-let.slang @@ -29,7 +29,7 @@ int test(IFoo foo, int idx) [numthreads(4, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) { - MyImpl impl = MyImpl(); + MyImpl impl; // CHECK: 0 // CHECK: 1 // CHECK: 2