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, i8* }
8 @0 = private unnamed_addr constant [1 x i8] c"\00", align 1
9 @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @0, i32 0, i32 0) }, align 8
12 ; CHECK-NOT: [openmp-opt] Basic block @kernel entry is executed by a single thread.
13 ; CHECK: [openmp-opt] Basic block @kernel if.then is executed by a single thread.
14 ; CHECK-NOT: [openmp-opt] Basic block @kernel if.else is executed by a single thread.
15 ; CHECK-NOT: [openmp-opt] Basic block @kernel if.end is executed by a single thread.
16 define void @kernel() {
17 %call = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @1, i8 1, i1 false, i1 false)
18 %cmp = icmp eq i32 %call, -1
19 br i1 %cmp, label %if.then, label %if.else
25 call void @__kmpc_target_deinit(%struct.ident_t* null, i8 1, i1 true)
29 ; REMARKS: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible.
30 ; REMARKS-NOT: remark: single_threaded_execution.c:1:0: Could not internalize function. Some optimizations may not be possible.
32 ; CHECK-NOT: [openmp-opt] Basic block @nvptx entry is executed by a single thread.
33 ; CHECK-DAG: [openmp-opt] Basic block @nvptx if.then is executed by a single thread.
34 ; CHECK-NOT: [openmp-opt] Basic block @nvptx if.end is executed by a single thread.
35 ; Function Attrs: noinline
36 define void @nvptx() {
38 %call = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
39 %cmp = icmp eq i32 %call, 0
40 br i1 %cmp, label %if.then, label %if.end
53 ; CHECK-NOT: [openmp-opt] Basic block @amdgcn entry is executed by a single thread.
54 ; CHECK-DAG: [openmp-opt] Basic block @amdgcn if.then is executed by a single thread.
55 ; CHECK-NOT: [openmp-opt] Basic block @amdgcn if.end is executed by a single thread.
56 ; Function Attrs: noinline
57 define void @amdgcn() {
59 %call = call i32 @llvm.amdgcn.workitem.id.x()
60 %cmp = icmp eq i32 %call, 0
61 br i1 %cmp, label %if.then, label %if.end
74 ; CHECK: [openmp-opt] Basic block @foo entry is executed by a single thread.
75 ; Function Attrs: noinline
76 define internal void @foo() {
81 ; CHECK: [openmp-opt] Basic block @bar.internalized entry is executed by a single thread.
82 ; Function Attrs: noinline
88 ; CHECK-NOT: [openmp-opt] Basic block @baz entry is executed by a single thread.
89 ; Function Attrs: noinline
90 define weak void @baz() !dbg !8 {
95 ; CHECK-NOT: [openmp-opt] Basic block @cold entry is executed by a single thread.
96 ; Function Attrs: cold convergent noinline nounwind optnone mustprogress
97 define weak void @cold() #0 !dbg !9 {
102 declare i32 @llvm.nvvm.read.ptx.sreg.tid.x()
104 declare i32 @llvm.amdgcn.workitem.id.x()
106 declare void @__kmpc_kernel_prepare_parallel(i8*)
108 declare i32 @__kmpc_target_init(%struct.ident_t*, i8, i1, i1)
110 declare void @__kmpc_target_deinit(%struct.ident_t*, i8, i1)
112 attributes #0 = { cold noinline }
115 !llvm.module.flags = !{!3, !4, !5, !6}
116 !nvvm.annotations = !{!7}
118 !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)
119 !1 = !DIFile(filename: "single_threaded_execution.c", directory: "/tmp/single_threaded_execution.c")
121 !3 = !{i32 2, !"Debug Info Version", i32 3}
122 !4 = !{i32 1, !"wchar_size", i32 4}
123 !5 = !{i32 7, !"openmp", i32 50}
124 !6 = !{i32 7, !"openmp-device", i32 50}
125 !7 = !{void ()* @kernel, !"kernel", i32 1}
126 !8 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
127 !9 = distinct !DISubprogram(name: "cold", scope: !1, file: !1, line: 8, type: !10, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
128 !10 = !DISubroutineType(types: !2)