1; RUN: opt -passes=openmp-opt -debug-only=openmp-opt -disable-output < %s 2>&1 | FileCheck %s 2; RUN: opt -passes=openmp-opt -pass-remarks-analysis=openmp-opt -disable-output < %s 2>&1 | FileCheck %s --check-prefix=REMARKS 3; REQUIRES: asserts 4; ModuleID = 'single_threaded_exeuction.c' 5 6define weak void @kernel() { 7 call void @__kmpc_kernel_init(i32 512, i16 1) 8 call void @nvptx() 9 call void @amdgcn() 10 ret void 11} 12 13; REMARKS: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible. 14; REMARKS-NOT: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible. 15 16; CHECK-NOT: [openmp-opt] Basic block @nvptx entry is executed by a single thread. 17; CHECK: [openmp-opt] Basic block @nvptx if.then is executed by a single thread. 18; CHECK-NOT: [openmp-opt] Basic block @nvptx if.end is executed by a single thread. 19; Function Attrs: noinline 20define internal void @nvptx() { 21entry: 22 %call = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() 23 %cmp = icmp eq i32 %call, 0 24 br i1 %cmp, label %if.then, label %if.end 25 26if.then: 27 call void @foo() 28 call void @bar() 29 call void @baz() 30 call void @cold() 31 br label %if.end 32 33if.end: 34 ret void 35} 36 37; CHECK-NOT: [openmp-opt] Basic block @amdgcn entry is executed by a single thread. 38; CHECK: [openmp-opt] Basic block @amdgcn if.then is executed by a single thread. 39; CHECK-NOT: [openmp-opt] Basic block @amdgcn if.end is executed by a single thread. 40; Function Attrs: noinline 41define internal void @amdgcn() { 42entry: 43 %call = call i32 @llvm.amdgcn.workitem.id.x() 44 %cmp = icmp eq i32 %call, 0 45 br i1 %cmp, label %if.then, label %if.end 46 47if.then: 48 call void @foo() 49 call void @bar() 50 call void @baz() 51 call void @cold() 52 br label %if.end 53 54if.end: 55 ret void 56} 57 58; CHECK: [openmp-opt] Basic block @foo entry is executed by a single thread. 59; Function Attrs: noinline 60define internal void @foo() { 61entry: 62 ret void 63} 64 65; CHECK: [openmp-opt] Basic block @bar.internalized entry is executed by a single thread. 66; Function Attrs: noinline 67define void @bar() { 68entry: 69 ret void 70} 71 72; CHECK-NOT: [openmp-opt] Basic block @baz entry is executed by a single thread. 73; Function Attrs: noinline 74define weak void @baz() !dbg !8 { 75entry: 76 ret void 77} 78 79; CHECK-NOT: [openmp-opt] Basic block @cold entry is executed by a single thread. 80; Function Attrs: cold convergent noinline nounwind optnone mustprogress 81define weak void @cold() #0 !dbg !9 { 82entry: 83 ret void 84} 85 86declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() 87 88declare i32 @llvm.amdgcn.workitem.id.x() 89 90declare void @__kmpc_kernel_init(i32, i16) 91 92attributes #0 = { cold noinline } 93 94!llvm.dbg.cu = !{!0} 95!llvm.module.flags = !{!3, !4, !5, !6} 96!nvvm.annotations = !{!7} 97 98!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 99!1 = !DIFile(filename: "single_threaded_execution.c", directory: "/tmp/single_threaded_execution.c") 100!2 = !{} 101!3 = !{i32 2, !"Debug Info Version", i32 3} 102!4 = !{i32 1, !"wchar_size", i32 4} 103!5 = !{i32 7, !"openmp", i32 50} 104!6 = !{i32 7, !"openmp-device", i32 50} 105!7 = !{void ()* @kernel, !"kernel", i32 1} 106!8 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 107!9 = distinct !DISubprogram(name: "cold", scope: !1, file: !1, line: 8, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 108!10 = !DISubroutineType(types: !2) 109