diff options
5 files changed, 54 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 74b11079d..16164b957 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -698,6 +698,15 @@ Result linkAndOptimizeIR( // bit_cast on basic types. lowerBitCast(targetRequest, irModule); eliminateDeadCode(irModule); + + + // We include one final step to (optionally) dump the IR and validate + // it after all of the optimization passes are complete. This should + // reflect the IR that code is generated from as closely as possible. + // +#if 0 + dumpIRIfEnabled(compileRequest, irModule, "OPTIMIZED"); +#endif validateIRModuleIfEnabled(compileRequest, irModule); return SLANG_OK; diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index de5a07c0d..ab488a41f 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -5475,6 +5475,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // a field that holds the base type... // auto irKey = getBuilder()->createStructKey(); + addLinkageDecoration(context, irKey, inheritanceDecl); auto keyVal = LoweredValInfo::simple(irKey); setGlobalValue(context, inheritanceDecl, keyVal); return keyVal; diff --git a/tests/language-feature/inheritance/struct-inheritance-import.slang b/tests/language-feature/inheritance/struct-inheritance-import.slang new file mode 100644 index 000000000..0ea49957e --- /dev/null +++ b/tests/language-feature/inheritance/struct-inheritance-import.slang @@ -0,0 +1,28 @@ +// struct-inheritance-import.slang + +//TEST(compute):COMPARE_COMPUTE: + +// This test confirms that the synthesized code for struct type inheritance +// includes proper linkage decorations so that it can work across modules. + +import struct_inheritance_imported; + +int test(int val) +{ + Derived d; + d.a = val; + + return 0x100 + d.a*0x10 + getA(d); +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +} diff --git a/tests/language-feature/inheritance/struct-inheritance-import.slang.expected.txt b/tests/language-feature/inheritance/struct-inheritance-import.slang.expected.txt new file mode 100644 index 000000000..60d3d339d --- /dev/null +++ b/tests/language-feature/inheritance/struct-inheritance-import.slang.expected.txt @@ -0,0 +1,4 @@ +100 +111 +122 +133 diff --git a/tests/language-feature/inheritance/struct-inheritance-imported.slang b/tests/language-feature/inheritance/struct-inheritance-imported.slang new file mode 100644 index 000000000..8786b851c --- /dev/null +++ b/tests/language-feature/inheritance/struct-inheritance-imported.slang @@ -0,0 +1,12 @@ +//TEST_IGNORE_FILE: +// struct-inheritance-imported.slang + +struct Base +{ + int a; +} + +struct Derived : Base +{} + +int getA(Derived d) { return d.a; } |
