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
4 ; ModuleID = 'single_threaded_exeuction.c'
6 %struct.ident_t = type { i32, i32, i32, i32, ptr }
7 %struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr }
8 %struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32, i32, i32 }
10 @0 = private unnamed_addr constant [1 x i8] c"\00", align 1
11 @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @0 }, align 8
12 @kernel_kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr @1, ptr null }
15 ; CHECK-NOT: [openmp-opt] Basic block @kernel entry is executed by a single thread.
16 ; CHECK: [openmp-opt] Basic block @kernel if.then is executed by a single thread.
17 ; CHECK-NOT: [openmp-opt] Basic block @kernel if.else is executed by a single thread.
18 ; CHECK-NOT: [openmp-opt] Basic block @kernel if.end is executed by a single thread.
19 define void @kernel(ptr %dyn) "kernel" {
20 %call = call i32 @__kmpc_target_init(ptr @kernel_kernel_environment, ptr %dyn)
21 %cmp = icmp eq i32 %call, -1
22 br i1 %cmp, label %if.then, label %if.else
28 call void @__kmpc_target_deinit()
32 ; CHECK: [openmp-opt] Basic block @foo entry is executed by a single thread.
33 ; Function Attrs: noinline
34 define internal void @foo() {
39 ; CHECK: [openmp-opt] Basic block @bar.internalized entry is executed by a single thread.
40 ; Function Attrs: noinline
46 ; REMARKS: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible.
47 ; REMARKS-NOT: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible.
49 ; CHECK-NOT: [openmp-opt] Basic block @nvptx entry is executed by a single thread.
50 ; CHECK-DAG: [openmp-opt] Basic block @nvptx if.then is executed by a single thread.
51 ; CHECK-NOT: [openmp-opt] Basic block @nvptx if.end is executed by a single thread.
52 ; Function Attrs: noinline
53 define void @nvptx() {
55 %call = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
56 %cmp = icmp eq i32 %call, 0
57 br i1 %cmp, label %if.then, label %if.end
70 ; CHECK-NOT: [openmp-opt] Basic block @amdgcn entry is executed by a single thread.
71 ; CHECK-DAG: [openmp-opt] Basic block @amdgcn if.then is executed by a single thread.
72 ; CHECK-NOT: [openmp-opt] Basic block @amdgcn if.end is executed by a single thread.
73 ; Function Attrs: noinline
74 define void @amdgcn() {
76 %call = call i32 @llvm.amdgcn.workitem.id.x()
77 %cmp = icmp eq i32 %call, 0
78 br i1 %cmp, label %if.then, label %if.end
91 ; CHECK-NOT: [openmp-opt] Basic block @baz entry is executed by a single thread.
92 ; Function Attrs: noinline
93 define weak void @baz() !dbg !8 {
98 ; CHECK-NOT: [openmp-opt] Basic block @cold entry is executed by a single thread.
99 ; Function Attrs: cold convergent noinline nounwind optnone mustprogress
100 define weak void @cold() #0 !dbg !9 {
105 declare i32 @llvm.nvvm.read.ptx.sreg.tid.x()
107 declare i32 @llvm.amdgcn.workitem.id.x()
109 declare void @__kmpc_kernel_prepare_parallel(ptr)
111 declare i32 @__kmpc_target_init(ptr, ptr)
113 declare void @__kmpc_target_deinit()
115 attributes #0 = { cold noinline }
118 !llvm.module.flags = !{!3, !4, !5, !6}
119 !nvvm.annotations = !{!7}
121 !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)
122 !1 = !DIFile(filename: "single_threaded_execution.c", directory: "/tmp/single_threaded_execution.c")
124 !3 = !{i32 2, !"Debug Info Version", i32 3}
125 !4 = !{i32 1, !"wchar_size", i32 4}
126 !5 = !{i32 7, !"openmp", i32 50}
127 !6 = !{i32 7, !"openmp-device", i32 50}
128 !7 = !{ptr @kernel, !"kernel", i32 1}
129 !8 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
130 !9 = distinct !DISubprogram(name: "cold", scope: !1, file: !1, line: 8, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
131 !10 = !DISubroutineType(types: !2)