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