summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/function-calls/forceinline-basic-block-inline-order.slang
diff options
context:
space:
mode:
Diffstat (limited to 'tests/language-feature/function-calls/forceinline-basic-block-inline-order.slang')
-rw-r--r--tests/language-feature/function-calls/forceinline-basic-block-inline-order.slang39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/language-feature/function-calls/forceinline-basic-block-inline-order.slang b/tests/language-feature/function-calls/forceinline-basic-block-inline-order.slang
new file mode 100644
index 000000000..24bfd5dff
--- /dev/null
+++ b/tests/language-feature/function-calls/forceinline-basic-block-inline-order.slang
@@ -0,0 +1,39 @@
+//TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target spirv -O0 -g3
+RWStructuredBuffer<int> outputBuffer;
+
+// Test where outer function is inlined before the inner function.
+
+[ForceInline]
+int inlineSingleBasicBlock1(int value1, int value2)
+{
+ // Simple operation that should be inlined
+ return value1 * 2 + value2;
+}
+
+[__unsafeForceInlineEarly]
+int inlineSingleBasicBlock2(int value1, int value2)
+{
+ int result1 = inlineSingleBasicBlock1(10, 20);
+ // Simple operation that should be inlined
+ return value1 * 2 + value2 + result1;
+}
+
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int i = dispatchThreadID.x;
+
+ // Call the forceinline function
+ int result = inlineSingleBasicBlock2(16, 10);
+
+ outputBuffer[i] = result;
+}
+
+
+// CHECK-COUNT-2: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugInlinedAt %uint_{{[0-9]+}} %{{[0-9]+}}
+// CHECK-NOT: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugInlinedAt %uint_{{[0-9]+}} %{{[0-9]+}}
+// CHECK-COUNT-3: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugScope %{{[0-9]+}} %{{[0-9]+}}
+// CHECK-NOT: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugScope %{{[0-9]+}} %{{[0-9]+}}
+// CHECK-COUNT-1: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugNoScope
+// CHECK-NOT: %{{[0-9]+}} = OpExtInst %void %{{[0-9]+}} DebugNoScope \ No newline at end of file