1- // RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.3-library -finclude-default-header %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
2- // RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.0-compute -finclude-default-header %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
1+ // RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.3-library -finclude-default-header %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,LIB
2+ // RUN: %clang_cc1 -x hlsl -triple dxil-pc-shadermodel6.0-compute -finclude-default-header %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s --check-prefixes=CHECK,COMPUTE
33
44// Verify that a few different function types all get the NoRecurse attribute
55
@@ -11,7 +11,8 @@ struct Node {
1111 uint left, right;
1212};
1313
14- // CHECK: Function Attrs:{{.*}}norecurse
14+ // LIB: Function Attrs:{{.*}}norecurse{{.*}}optnone
15+ // COMPUTE: Function Attrs: alwaysinline{{.*}}norecurse
1516// CHECK: define noundef i32 @_Z4FindA100_4Nodej(ptr noundef byval([100 x %struct.Node]) align 4 %SortedTree, i32 noundef %key) [[IntAttr:\#[0-9]+]]
1617// CHECK: ret i32
1718// Find and return value corresponding to key in the SortedTree
@@ -30,7 +31,8 @@ uint Find(Node SortedTree[MAX], uint key) {
3031 }
3132}
3233
33- // CHECK: Function Attrs:{{.*}}norecurse
34+ // LIB: Function Attrs:{{.*}}norecurse{{.*}}optnone
35+ // COMPUTE: Function Attrs: alwaysinline{{.*}}norecurse
3436// CHECK: define noundef i1 @_Z8InitTreeA100_4NodeN4hlsl8RWBufferIDv4_jEEj(ptr noundef byval([100 x %struct.Node]) align 4 %tree, ptr noundef byval(%"class.hlsl::RWBuffer") align 4 %encodedTree, i32 noundef %maxDepth) [[ExtAttr:\#[0-9]+]]
3537// CHECK: ret i1
3638// Initialize tree with given buffer
@@ -51,12 +53,13 @@ bool InitTree(/*inout*/ Node tree[MAX], RWBuffer<uint4> encodedTree, uint maxDep
5153RWBuffer <uint4 > gTree;
5254
5355// Mangled entry points are internal
54- // CHECK: Function Attrs:{{.*}}norecurse
55- // CHECK: define internal void @_Z4mainj(i32 noundef %GI) [[IntAttr]]
56+ // CHECK: Function Attrs:{{.*}}norecurse{{.*}}optnone
57+ // LIB: define internal void @_Z4mainj(i32 noundef %GI) [[IntAttr]]
58+ // COMPUTE: define internal void @_Z4mainj(i32 noundef %GI) [[IntComputeAttr:\#[0-9]]]
5659// CHECK: ret void
5760
5861// Canonical entry points are external and shader attributed
59- // CHECK: Function Attrs:{{.*}} norecurse
62+ // CHECK: Function Attrs: convergent noinline norecurse
6063// CHECK: define void @main() [[EntryAttr:\#[0-9]+]]
6164// CHECK: ret void
6265
@@ -70,12 +73,13 @@ void main(uint GI : SV_GroupIndex) {
7073}
7174
7275// Mangled entry points are internal
73- // CHECK: Function Attrs:{{.*}}norecurse
74- // CHECK: define internal void @_Z11defaultMainv() [[IntAttr]]
76+ // CHECK: Function Attrs:{{.*}}norecurse{{.*}}optnone
77+ // LIB: define internal void @_Z11defaultMainv() [[IntAttr]]
78+ // COMPUTE: define internal void @_Z11defaultMainv() [[IntComputeAttr]]
7579// CHECK: ret void
7680
7781// Canonical entry points are external and shader attributed
78- // CHECK: Function Attrs:{{.*}} norecurse
82+ // CHECK: Function Attrs: convergent noinline norecurse
7983// CHECK: define void @defaultMain() [[EntryAttr]]
8084// CHECK: ret void
8185
@@ -88,6 +92,7 @@ void defaultMain() {
8892 needle = Find (haystack, needle);
8993}
9094
91- // CHECK: attributes [[IntAttr]] = {{.*}} norecurse
92- // CHECK: attributes [[ExtAttr]] = {{.*}} norecurse
93- // CHECK: attributes [[EntryAttr]] = {{.*}} norecurse
95+ // CHECK: attributes [[IntAttr]] = {{.*}}norecurse
96+ // CHECK: attributes [[ExtAttr]] = {{.*}}norecurse
97+ // COMPUTE: attributes [[IntComputeAttr]] = {{.*}}norecurse
98+ // CHECK: attributes [[EntryAttr]] = {{.*}}norecurse
0 commit comments