1; RUN: opt -passes='default<O2>' -pass-remarks-missed=openmp-opt < %s 2>&1 | FileCheck %s --check-prefix=MODULE
2target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
3
4%struct.ident_t = type { i32, i32, i32, i32, i8* }
5
6@.str = private unnamed_addr constant [13 x i8] c"Alloc Shared\00", align 1
7
8@S = external local_unnamed_addr global i8*
9
10; MODULE: remark: openmp_opt_module.c:5:7: Found thread data sharing on the GPU. Expect degraded performance due to data globalization.
11
12define void @foo() {
13entry:
14  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 true, i1 true)
15  %x = call i8* @__kmpc_alloc_shared(i64 4), !dbg !10
16  %x_on_stack = bitcast i8* %x to i32*
17  %0 = bitcast i32* %x_on_stack to i8*
18  call void @use(i8* %0)
19  call void @__kmpc_free_shared(i8* %x)
20  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 true)
21  ret void
22}
23
24declare void @use(i8* %0)
25
26define weak i8* @__kmpc_alloc_shared(i64 %DataSize) {
27entry:
28  %call = call i8* @_Z10SafeMallocmPKc(i64 %DataSize, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0)) #11
29  ret i8* %call
30}
31
32; Function Attrs: convergent nounwind mustprogress
33declare i8* @_Z10SafeMallocmPKc(i64 %size, i8* nocapture readnone %msg)
34
35declare void @__kmpc_free_shared(i8*)
36declare i32 @__kmpc_target_init(%struct.ident_t*, i1, i1 %use_generic_state_machine, i1)
37declare void @__kmpc_target_deinit(%struct.ident_t*, i1, i1)
38
39!llvm.dbg.cu = !{!0}
40!llvm.module.flags = !{!3, !4, !5, !6}
41!nvvm.annotations = !{!7}
42
43!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)
44!1 = !DIFile(filename: "openmp_opt_module.c", directory: "/tmp/openmp_opt_module.c")
45!2 = !{}
46!3 = !{i32 2, !"Debug Info Version", i32 3}
47!4 = !{i32 1, !"wchar_size", i32 4}
48!5 = !{i32 7, !"openmp", i32 50}
49!6 = !{i32 7, !"openmp-device", i32 50}
50!7 = !{void ()* @foo, !"kernel", i32 1}
51!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
52!9 = !DISubroutineType(types: !2)
53!10 = !DILocation(line: 5, column: 7, scope: !8)
54