1; RUN: opt -passes=openmp-opt -pass-remarks-missed=openmp-opt -disable-output < %s 2>&1 | FileCheck %s
2; ModuleID = 'declare_target_codegen_globalization.cpp'
3source_filename = "declare_target_codegen_globalization.cpp"
4target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
5target triple = "nvptx64"
6
7; CHECK: remark: globalization_remarks.c:5:7: Could not move globalized variable to the stack. Variable is potentially captured in call. Mark parameter as `__attribute__((noescape))` to override.
8; CHECK: remark: globalization_remarks.c:5:7: Found thread data sharing on the GPU. Expect degraded performance due to data globalization.
9
10%struct.ident_t = type { i32, i32, i32, i32, i8* }
11
12@S = external local_unnamed_addr global i8*
13
14define void @foo() {
15entry:
16  %c = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 true, i1 true)
17  %0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !10
18  %x_on_stack = bitcast i8* %0 to i32*
19  %1 = bitcast i32* %x_on_stack to i8*
20  call void @share(i8* %1), !dbg !10
21  call void @__kmpc_free_shared(i8* %0)
22  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 true)
23  ret void
24}
25
26define internal void @share(i8* %x) {
27entry:
28  store i8* %x, i8** @S
29  ret void
30}
31
32declare i8* @__kmpc_alloc_shared(i64)
33
34declare void @__kmpc_free_shared(i8* nocapture)
35
36declare i32 @__kmpc_target_init(%struct.ident_t*, i1, i1, i1);
37
38declare void @__kmpc_target_deinit(%struct.ident_t*, i1, i1)
39
40!llvm.dbg.cu = !{!0}
41!llvm.module.flags = !{!3, !4, !5, !6}
42!nvvm.annotations = !{!7, !8}
43
44!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)
45!1 = !DIFile(filename: "globalization_remarks.c", directory: "/tmp/globalization_remarks.c")
46!2 = !{}
47!3 = !{i32 2, !"Debug Info Version", i32 3}
48!4 = !{i32 1, !"wchar_size", i32 4}
49!5 = !{i32 7, !"openmp", i32 50}
50!6 = !{i32 7, !"openmp-device", i32 50}
51!7 = !{void ()* @foo, !"kernel", i32 1}
52!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
53!9 = !DISubroutineType(types: !2)
54!10 = !DILocation(line: 5, column: 7, scope: !8)
55