1; RUN: opt -S -dxil-finalize-linkage -mtriple=dxil-unknown-shadermodel6.5-compute %s | FileCheck %s 2; RUN: llc %s --filetype=asm -o - | FileCheck %s 3 4target triple = "dxilv1.5-pc-shadermodel6.5-compute" 5 6; Confirm that DXILFinalizeLinkage will remove functions that have compatible 7; linkage and are not called from anywhere. This should be any function that 8; is not an entry point. 9 10; Has no specified inlining/linking behavior and is uncalled, this should be removed. 11; CHECK-NOT: define {{.*}}doNothingUncalled 12define void @"?doNothingUncalled@@YAXXZ"() #1 { 13entry: 14 ret void 15} 16 17; Alwaysinline and uncalled, this should be removed. 18; CHECK-NOT: define {{.*}}doAlwaysInlineUncalled 19define void @"?doAlwaysInlineUncalled@@YAXXZ"() #0 { 20entry: 21 ret void 22} 23 24; Noinline and uncalled, this should be removed. 25; CHECK-NOT: define {{.*}}doNoinlineUncalled 26define void @"?doNoinlineUncalled@@YAXXZ"() #3 { 27entry: 28 ret void 29} 30 31; No inlining attribute, internal, and uncalled; this should be removed. 32; CHECK-NOT: define {{.*}}doInternalUncalled 33define internal void @"?doInternalUncalled@@YAXXZ"() #1 { 34entry: 35 ret void 36} 37 38; Alwaysinline, internal, and uncalled; this should be removed. 39; CHECK-NOT: define {{.*}}doAlwaysInlineInternalUncalled 40define internal void @"?doAlwaysInlineInternalUncalled@@YAXXZ"() #0 { 41entry: 42 ret void 43} 44 45; Noinline, internal, and uncalled; this should be removed. 46; CHECK-NOT: define {{.*}}doNoinlineInternalUncalled 47define internal void @"?doNoinlineInternalUncalled@@YAXXZ"() #3 { 48entry: 49 ret void 50} 51 52; Marked external and uncalled, this should become internal and be removed. 53; CHECK-NOT: define {{.*}}doExternalUncalled 54define external void @"?doExternalUncalled@@YAXXZ"() #1 { 55entry: 56 ret void 57} 58 59; Alwaysinline, external and uncalled, this should become internal and be removed. 60; CHECK-NOT: define {{.*}}doAlwaysInlineExternalUncalled 61define external void @"?doAlwaysInlineExternalUncalled@@YAXXZ"() #0 { 62entry: 63 ret void 64} 65 66; Noinline, external and uncalled, this should become internal and be removed. 67; CHECK-NOT: define {{.*}}doNoinlineExternalUncalled 68define external void @"?doNoinlineExternalUncalled@@YAXXZ"() #3 { 69entry: 70 ret void 71} 72 73; No inlining attribute and called, this should stay. 74; CHECK: define {{.*}}doNothingCalled 75define void @"?doNothingCalled@@YAXXZ"() #1 { 76entry: 77 ret void 78} 79 80; Alwaysinline and called, this should stay. 81; CHECK: define {{.*}}doAlwaysInlineCalled 82define void @"?doAlwaysInlineCalled@@YAXXZ"() #0 { 83entry: 84 ret void 85} 86 87; Noinline and called, this should stay. 88; CHECK: define {{.*}}doNoinlineCalled 89define void @"?doNoinlineCalled@@YAXXZ"() #3 { 90entry: 91 ret void 92} 93 94; No inlining attribute, internal, and called; this should stay. 95; CHECK: define {{.*}}doInternalCalled 96define internal void @"?doInternalCalled@@YAXXZ"() #1 { 97entry: 98 ret void 99} 100 101; Alwaysinline, internal, and called; this should stay. 102; CHECK: define {{.*}}doAlwaysInlineInternalCalled 103define internal void @"?doAlwaysInlineInternalCalled@@YAXXZ"() #0 { 104entry: 105 ret void 106} 107 108; Noinline, internal, and called; this should stay. 109; CHECK: define {{.*}}doNoinlineInternalCalled 110define internal void @"?doNoinlineInternalCalled@@YAXXZ"() #3 { 111entry: 112 ret void 113} 114 115; Marked external and called, this should become internal and stay. 116; CHECK: define {{.*}}doExternalCalled 117define external void @"?doExternalCalled@@YAXXZ"() #1 { 118entry: 119 ret void 120} 121 122; Always inlined, external and called, this should become internal and stay. 123; CHECK: define {{.*}}doAlwaysInlineExternalCalled 124define external void @"?doAlwaysInlineExternalCalled@@YAXXZ"() #0 { 125entry: 126 ret void 127} 128 129; Noinline, external and called, this should become internal and stay. 130; CHECK: define {{.*}}doNoinlineExternalCalled 131define external void @"?doNoinlineExternalCalled@@YAXXZ"() #3 { 132entry: 133 ret void 134} 135 136; Entry point function, this should stay. 137; CHECK: define void @main() 138define void @main() #4 { 139entry: 140 call void @"?doNothingCalled@@YAXXZ"() #5 141 call void @"?doAlwaysInlineCalled@@YAXXZ"() #5 142 call void @"?doNoinlineCalled@@YAXXZ"() #5 143 call void @"?doInternalCalled@@YAXXZ"() #5 144 call void @"?doAlwaysInlineInternalCalled@@YAXXZ"() #5 145 call void @"?doNoinlineInternalCalled@@YAXXZ"() #5 146 call void @"?doExternalCalled@@YAXXZ"() #5 147 call void @"?doAlwaysInlineExternalCalled@@YAXXZ"() #5 148 call void @"?doNoinlineExternalCalled@@YAXXZ"() #5 149 ret void 150} 151 152attributes #0 = { alwaysinline convergent norecurse nounwind } 153attributes #1 = { convergent norecurse nounwind } 154attributes #3 = { convergent noinline norecurse nounwind } 155attributes #4 = { convergent noinline norecurse "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" } 156attributes #5 = { convergent } 157