1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals 2; RUN: opt -S -passes=openmp-opt < %s | FileCheck %s 3; RUN: opt -passes=openmp-opt -pass-remarks=openmp-opt -pass-remarks-missed=openmp-opt -disable-output < %s 2>&1 | FileCheck %s -check-prefix=CHECK-REMARKS 4; RUN: opt -passes=openmp-opt -pass-remarks-missed=openmp-opt -openmp-opt-max-iterations=1 -disable-output < %s 2>&1 | FileCheck %s -check-prefix=CHECK-FIXPOINT 5; RUN: opt -openmp-opt-disable-deglobalization -S -passes=openmp-opt < %s | FileCheck %s --check-prefix=CHECK-DISABLED 6target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64" 7target triple = "nvptx64" 8 9; UTC_ARGS: --disable 10; CHECK-REMARKS: remark: remove_globalization.c:4:2: Could not move globalized variable to the stack. Variable is potentially captured in call. Mark parameter as `__attribute__((noescape))` to override. 11; CHECK-REMARKS: remark: remove_globalization.c:2:2: Moving globalized variable to the stack. 12; CHECK-REMARKS: remark: remove_globalization.c:6:2: Moving globalized variable to the stack. 13; CHECK-REMARKS: remark: remove_globalization.c:4:2: Found thread data sharing on the GPU. Expect degraded performance due to data globalization. 14; CHECK-FIXPOINT: Attributor did not reach a fixpoint after 1 iterations. 15; UTC_ARGS: --enable 16 17@S = external local_unnamed_addr global i8* 18 19%struct.ident_t = type { i32, i32, i32, i32, i8* } 20 21declare i32 @__kmpc_target_init(%struct.ident_t*, i8, i1, i1) 22declare void @__kmpc_target_deinit(%struct.ident_t*, i8, i1) 23 24;. 25; CHECK: @[[S:[a-zA-Z0-9_$"\\.-]+]] = external local_unnamed_addr global i8* 26;. 27; CHECK-DISABLED: @[[S:[a-zA-Z0-9_$"\\.-]+]] = external local_unnamed_addr global i8* 28;. 29define void @kernel() { 30; CHECK-LABEL: define {{[^@]+}}@kernel() { 31; CHECK-NEXT: entry: 32; CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* nonnull null, i8 1, i1 false, i1 true) 33; CHECK-NEXT: call void @foo() #[[ATTR0:[0-9]+]] 34; CHECK-NEXT: call void @bar() #[[ATTR0]] 35; CHECK-NEXT: call void @unknown_no_openmp() 36; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* nonnull null, i8 1, i1 true) 37; CHECK-NEXT: ret void 38; 39; CHECK-DISABLED-LABEL: define {{[^@]+}}@kernel() { 40; CHECK-DISABLED-NEXT: entry: 41; CHECK-DISABLED-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* nonnull null, i8 1, i1 false, i1 true) 42; CHECK-DISABLED-NEXT: call void @foo() #[[ATTR0:[0-9]+]] 43; CHECK-DISABLED-NEXT: call void @bar() #[[ATTR0]] 44; CHECK-DISABLED-NEXT: call void @unknown_no_openmp() 45; CHECK-DISABLED-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* nonnull null, i8 1, i1 true) 46; CHECK-DISABLED-NEXT: ret void 47; 48entry: 49 %0 = call i32 @__kmpc_target_init(%struct.ident_t* nonnull null, i8 1, i1 true, i1 true) 50 call void @foo() 51 call void @bar() 52 call void @unknown_no_openmp() 53 call void @__kmpc_target_deinit(%struct.ident_t* nonnull null, i8 1, i1 true) 54 ret void 55} 56 57define internal void @foo() { 58; CHECK-LABEL: define {{[^@]+}}@foo 59; CHECK-SAME: () #[[ATTR0]] { 60; CHECK-NEXT: entry: 61; CHECK-NEXT: [[TMP0:%.*]] = alloca i8, i64 4, align 1 62; CHECK-NEXT: ret void 63; 64; CHECK-DISABLED-LABEL: define {{[^@]+}}@foo 65; CHECK-DISABLED-SAME: () #[[ATTR0]] { 66; CHECK-DISABLED-NEXT: entry: 67; CHECK-DISABLED-NEXT: [[TMP0:%.*]] = alloca i8, i64 4, align 1 68; CHECK-DISABLED-NEXT: ret void 69; 70entry: 71 %0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !12 72 call void @use(i8* %0) 73 call void @__kmpc_free_shared(i8* %0, i64 4) 74 ret void 75} 76 77define internal void @bar() { 78; CHECK-LABEL: define {{[^@]+}}@bar 79; CHECK-SAME: () #[[ATTR1:[0-9]+]] { 80; CHECK-NEXT: entry: 81; CHECK-NEXT: [[TMP0:%.*]] = call i8* @__kmpc_alloc_shared(i64 4) #[[ATTR0]], !dbg [[DBG8:![0-9]+]] 82; CHECK-NEXT: call void @share(i8* nofree [[TMP0]]) #[[ATTR6:[0-9]+]], !dbg [[DBG8]] 83; CHECK-NEXT: call void @__kmpc_free_shared(i8* [[TMP0]], i64 4) #[[ATTR0]] 84; CHECK-NEXT: ret void 85; 86; CHECK-DISABLED-LABEL: define {{[^@]+}}@bar 87; CHECK-DISABLED-SAME: () #[[ATTR1:[0-9]+]] { 88; CHECK-DISABLED-NEXT: entry: 89; CHECK-DISABLED-NEXT: [[TMP0:%.*]] = call i8* @__kmpc_alloc_shared(i64 4) #[[ATTR0]], !dbg [[DBG8:![0-9]+]] 90; CHECK-DISABLED-NEXT: call void @share(i8* nofree [[TMP0]]) #[[ATTR6:[0-9]+]], !dbg [[DBG8]] 91; CHECK-DISABLED-NEXT: call void @__kmpc_free_shared(i8* [[TMP0]], i64 4) #[[ATTR0]] 92; CHECK-DISABLED-NEXT: ret void 93; 94entry: 95 %0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !13 96 call void @share(i8* %0), !dbg !13 97 call void @__kmpc_free_shared(i8* %0, i64 4) 98 ret void 99} 100 101define internal void @use(i8* %x) { 102; CHECK-LABEL: define {{[^@]+}}@use 103; CHECK-SAME: (i8* [[X:%.*]]) #[[ATTR2:[0-9]+]] { 104; CHECK-NEXT: entry: 105; CHECK-NEXT: ret void 106; 107; CHECK-DISABLED-LABEL: define {{[^@]+}}@use 108; CHECK-DISABLED-SAME: (i8* [[X:%.*]]) #[[ATTR2:[0-9]+]] { 109; CHECK-DISABLED-NEXT: entry: 110; CHECK-DISABLED-NEXT: ret void 111; 112entry: 113 ret void 114} 115 116define internal void @share(i8* %x) { 117; CHECK-LABEL: define {{[^@]+}}@share 118; CHECK-SAME: (i8* nofree [[X:%.*]]) #[[ATTR3:[0-9]+]] { 119; CHECK-NEXT: entry: 120; CHECK-NEXT: store i8* [[X]], i8** @S, align 8 121; CHECK-NEXT: ret void 122; 123; CHECK-DISABLED-LABEL: define {{[^@]+}}@share 124; CHECK-DISABLED-SAME: (i8* nofree [[X:%.*]]) #[[ATTR3:[0-9]+]] { 125; CHECK-DISABLED-NEXT: entry: 126; CHECK-DISABLED-NEXT: store i8* [[X]], i8** @S, align 8 127; CHECK-DISABLED-NEXT: ret void 128; 129entry: 130 store i8* %x, i8** @S 131 ret void 132} 133 134define void @unused() { 135; CHECK-LABEL: define {{[^@]+}}@unused() { 136; CHECK-NEXT: entry: 137; CHECK-NEXT: [[TMP0:%.*]] = alloca i8, i64 4, align 1 138; CHECK-NEXT: call void @use(i8* undef) 139; CHECK-NEXT: ret void 140; 141; CHECK-DISABLED-LABEL: define {{[^@]+}}@unused() { 142; CHECK-DISABLED-NEXT: entry: 143; CHECK-DISABLED-NEXT: [[TMP0:%.*]] = call i8* @__kmpc_alloc_shared(i64 4), !dbg [[DBG11:![0-9]+]] 144; CHECK-DISABLED-NEXT: call void @use(i8* [[TMP0]]) 145; CHECK-DISABLED-NEXT: call void @__kmpc_free_shared(i8* [[TMP0]], i64 4) 146; CHECK-DISABLED-NEXT: ret void 147; 148entry: 149 %0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !14 150 call void @use(i8* %0) 151 call void @__kmpc_free_shared(i8* %0, i64 4) 152 ret void 153} 154 155; CHECK: declare i8* @__kmpc_alloc_shared(i64) 156declare i8* @__kmpc_alloc_shared(i64) 157 158; CHECK: declare void @__kmpc_free_shared(i8* nocapture, i64) 159declare void @__kmpc_free_shared(i8*, i64) 160 161declare void @unknown_no_openmp() "llvm.assume"="omp_no_openmp" 162 163!llvm.dbg.cu = !{!0} 164!llvm.module.flags = !{!3, !4, !6, !7} 165!nvvm.annotations = !{!5} 166 167!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 168!1 = !DIFile(filename: "remove_globalization.c", directory: "/tmp/remove_globalization.c") 169!2 = !{} 170!3 = !{i32 2, !"Debug Info Version", i32 3} 171!4 = !{i32 1, !"wchar_size", i32 4} 172!5 = !{void ()* @kernel, !"kernel", i32 1} 173!6 = !{i32 7, !"openmp", i32 50} 174!7 = !{i32 7, !"openmp-device", i32 50} 175!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 176!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 177!10 = distinct !DISubprogram(name: "unused", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 178!11 = !DISubroutineType(types: !2) 179!12 = !DILocation(line: 2, column: 2, scope: !8) 180!13 = !DILocation(line: 4, column: 2, scope: !9) 181!14 = !DILocation(line: 6, column: 2, scope: !9) 182;. 183; CHECK: attributes #[[ATTR0]] = { nounwind } 184; CHECK: attributes #[[ATTR1]] = { nosync nounwind } 185; CHECK: attributes #[[ATTR2]] = { nounwind readnone } 186; CHECK: attributes #[[ATTR3]] = { nofree norecurse nosync nounwind writeonly } 187; CHECK: attributes #[[ATTR4:[0-9]+]] = { nosync nounwind allocsize(0) } 188; CHECK: attributes #[[ATTR5:[0-9]+]] = { "llvm.assume"="omp_no_openmp" } 189; CHECK: attributes #[[ATTR6]] = { nosync nounwind writeonly } 190;. 191; CHECK-DISABLED: attributes #[[ATTR0]] = { nounwind } 192; CHECK-DISABLED: attributes #[[ATTR1]] = { nosync nounwind } 193; CHECK-DISABLED: attributes #[[ATTR2]] = { nounwind readnone } 194; CHECK-DISABLED: attributes #[[ATTR3]] = { nofree norecurse nosync nounwind writeonly } 195; CHECK-DISABLED: attributes #[[ATTR4:[0-9]+]] = { nosync nounwind allocsize(0) } 196; CHECK-DISABLED: attributes #[[ATTR5:[0-9]+]] = { "llvm.assume"="omp_no_openmp" } 197; CHECK-DISABLED: attributes #[[ATTR6]] = { nosync nounwind writeonly } 198;. 199; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 200; CHECK: [[META1:![0-9]+]] = !DIFile(filename: "remove_globalization.c", directory: "/tmp/remove_globalization.c") 201; CHECK: [[META2:![0-9]+]] = !{} 202; CHECK: [[META3:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3} 203; CHECK: [[META4:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} 204; CHECK: [[META5:![0-9]+]] = !{i32 7, !"openmp", i32 50} 205; CHECK: [[META6:![0-9]+]] = !{i32 7, !"openmp-device", i32 50} 206; CHECK: [[META7:![0-9]+]] = !{void ()* @kernel, !"kernel", i32 1} 207; CHECK: [[DBG8]] = !DILocation(line: 4, column: 2, scope: !9) 208; CHECK: [[META9:![0-9]+]] = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 209; CHECK: [[META10:![0-9]+]] = !DISubroutineType(types: !2) 210;. 211; CHECK-DISABLED: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) 212; CHECK-DISABLED: [[META1:![0-9]+]] = !DIFile(filename: "remove_globalization.c", directory: "/tmp/remove_globalization.c") 213; CHECK-DISABLED: [[META2:![0-9]+]] = !{} 214; CHECK-DISABLED: [[META3:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3} 215; CHECK-DISABLED: [[META4:![0-9]+]] = !{i32 1, !"wchar_size", i32 4} 216; CHECK-DISABLED: [[META5:![0-9]+]] = !{i32 7, !"openmp", i32 50} 217; CHECK-DISABLED: [[META6:![0-9]+]] = !{i32 7, !"openmp-device", i32 50} 218; CHECK-DISABLED: [[META7:![0-9]+]] = !{void ()* @kernel, !"kernel", i32 1} 219; CHECK-DISABLED: [[DBG8]] = !DILocation(line: 4, column: 2, scope: !9) 220; CHECK-DISABLED: [[META9:![0-9]+]] = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) 221; CHECK-DISABLED: [[META10:![0-9]+]] = !DISubroutineType(types: !2) 222; CHECK-DISABLED: [[DBG11]] = !DILocation(line: 6, column: 2, scope: !9) 223;. 224