225 lines · plain
1; See ./README.md for how to maintain the LLVM IR in this test.2 3; REQUIRES: amdgpu-registered-target4 5; RUN: opt -pass-remarks=kernel-info -passes=kernel-info \6; RUN: -disable-output %s 2>&1 | \7; RUN: FileCheck -match-full-lines %s8 9; CHECK-NOT: remark:10; CHECK: remark: test.c:0:0: in artificial function '[[OFF_FUNC:__omp_offloading_[a-f0-9_]*_h_l12]]_debug__', artificial alloca ('%[[#]]') for 'dyn_ptr' with static size of 8 bytes11; CHECK-NEXT: remark: test.c:14:9: in artificial function '[[OFF_FUNC]]_debug__', alloca ('%[[#]]') for 'i' with static size of 4 bytes12; CHECK-NEXT: remark: test.c:15:9: in artificial function '[[OFF_FUNC]]_debug__', alloca ('%[[#]]') for 'a' with static size of 8 bytes13; CHECK-NEXT: remark: <unknown>:0:0: in artificial function '[[OFF_FUNC]]_debug__', 'store' instruction accesses memory in flat address space14; CHECK-NEXT: remark: test.c:13:3: in artificial function '[[OFF_FUNC]]_debug__', direct call, callee is '@__kmpc_target_init'15; CHECK-NEXT: remark: test.c:16:5: in artificial function '[[OFF_FUNC]]_debug__', direct call, callee is '@f'16; CHECK-NEXT: remark: test.c:17:5: in artificial function '[[OFF_FUNC]]_debug__', direct call to defined function, callee is 'g'17; CHECK-NEXT: remark: test.c:18:3: in artificial function '[[OFF_FUNC]]_debug__', direct call, callee is '@__kmpc_target_deinit'18; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', ExternalNotKernel = 019; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-max-num-workgroups[0] = 429496729520; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-max-num-workgroups[1] = 429496729521; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-max-num-workgroups[2] = 429496729522; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-flat-work-group-size[0] = 123; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-flat-work-group-size[1] = 102424; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-waves-per-eu[0] = 425; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', amdgpu-waves-per-eu[1] = 1026; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', Allocas = 327; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', AllocasStaticSizeSum = 2028; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', AllocasDyn = 029; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', DirectCalls = 430; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', IndirectCalls = 031; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', DirectCallsToDefinedFunctions = 132; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', InlineAssemblyCalls = 033; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', Invokes = 034; CHECK-NEXT: remark: test.c:13:0: in artificial function '[[OFF_FUNC]]_debug__', FlatAddrspaceAccesses = 135 36; CHECK-NEXT: remark: test.c:0:0: in artificial function '[[OFF_FUNC]]', artificial alloca ('%[[#]]') for 'dyn_ptr' with static size of 8 bytes37; CHECK-NEXT: remark: <unknown>:0:0: in artificial function '[[OFF_FUNC]]', 'store' instruction accesses memory in flat address space38; CHECK-NEXT: remark: test.c:12:1: in artificial function '[[OFF_FUNC]]', 'load' instruction ('%[[#]]') accesses memory in flat address space39; CHECK-NEXT: remark: test.c:12:1: in artificial function '[[OFF_FUNC]]', direct call to defined function, callee is artificial '[[OFF_FUNC]]_debug__'40; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', ExternalNotKernel = 041; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', omp_target_thread_limit = 25642; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-max-num-workgroups[0] = 429496729543; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-max-num-workgroups[1] = 429496729544; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-max-num-workgroups[2] = 429496729545; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-flat-work-group-size[0] = 146; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-flat-work-group-size[1] = 25647; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-waves-per-eu[0] = 148; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', amdgpu-waves-per-eu[1] = 1049; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', Allocas = 150; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', AllocasStaticSizeSum = 851; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', AllocasDyn = 052; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', DirectCalls = 153; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', IndirectCalls = 054; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', DirectCallsToDefinedFunctions = 155; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', InlineAssemblyCalls = 056; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', Invokes = 057; CHECK-NEXT: remark: test.c:12:0: in artificial function '[[OFF_FUNC]]', FlatAddrspaceAccesses = 258 59; CHECK-NEXT: remark: test.c:4:7: in function 'g', alloca ('%[[#]]') for 'i' with static size of 4 bytes60; CHECK-NEXT: remark: test.c:5:7: in function 'g', alloca ('%[[#]]') for 'a' with static size of 8 bytes61; CHECK-NEXT: remark: test.c:6:3: in function 'g', direct call, callee is '@f'62; CHECK-NEXT: remark: test.c:7:3: in function 'g', direct call to defined function, callee is 'g'63; CHECK-NEXT: remark: test.c:3:0: in function 'g', ExternalNotKernel = 164; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-max-num-workgroups[0] = 429496729565; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-max-num-workgroups[1] = 429496729566; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-max-num-workgroups[2] = 429496729567; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-flat-work-group-size[0] = 168; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-flat-work-group-size[1] = 102469; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-waves-per-eu[0] = 470; CHECK-NEXT: remark: test.c:3:0: in function 'g', amdgpu-waves-per-eu[1] = 1071; CHECK-NEXT: remark: test.c:3:0: in function 'g', Allocas = 272; CHECK-NEXT: remark: test.c:3:0: in function 'g', AllocasStaticSizeSum = 1273; CHECK-NEXT: remark: test.c:3:0: in function 'g', AllocasDyn = 074; CHECK-NEXT: remark: test.c:3:0: in function 'g', DirectCalls = 275; CHECK-NEXT: remark: test.c:3:0: in function 'g', IndirectCalls = 076; CHECK-NEXT: remark: test.c:3:0: in function 'g', DirectCallsToDefinedFunctions = 177; CHECK-NEXT: remark: test.c:3:0: in function 'g', InlineAssemblyCalls = 078; CHECK-NEXT: remark: test.c:3:0: in function 'g', Invokes = 079; CHECK-NEXT: remark: test.c:3:0: in function 'g', FlatAddrspaceAccesses = 080; CHECK-NOT: {{.}}81 82; ModuleID = 'test-openmp-amdgcn-amd-amdhsa-gfx906.bc'83source_filename = "test.c"84target triple = "amdgcn-amd-amdhsa"85 86%struct.ident_t = type { i32, i32, i32, i32, ptr }87%struct.DynamicEnvironmentTy = type { i16 }88%struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr }89%struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32, i32, i32 }90 91@__omp_rtl_debug_kind = weak_odr hidden addrspace(1) constant i32 092@__omp_rtl_assume_teams_oversubscription = weak_odr hidden addrspace(1) constant i32 093@__omp_rtl_assume_threads_oversubscription = weak_odr hidden addrspace(1) constant i32 094@__omp_rtl_assume_no_thread_state = weak_odr hidden addrspace(1) constant i32 095@__omp_rtl_assume_no_nested_parallelism = weak_odr hidden addrspace(1) constant i32 096@0 = private unnamed_addr constant [57 x i8] c";test.c;__omp_offloading_fd02_727e9_h_l12_debug__;13;3;;\00", align 197@1 = private unnamed_addr addrspace(1) constant %struct.ident_t { i32 0, i32 2, i32 0, i32 56, ptr @0 }, align 898@__omp_offloading_fd02_727e9_h_l12_dynamic_environment = weak_odr protected addrspace(1) global %struct.DynamicEnvironmentTy zeroinitializer99@__omp_offloading_fd02_727e9_h_l12_kernel_environment = weak_odr protected addrspace(1) constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 1, i8 1, i8 1, i32 1, i32 256, i32 -1, i32 -1, i32 0, i32 0 }, ptr addrspacecast (ptr addrspace(1) @1 to ptr), ptr addrspacecast (ptr addrspace(1) @__omp_offloading_fd02_727e9_h_l12_dynamic_environment to ptr) }100@__oclc_ABI_version = weak_odr hidden local_unnamed_addr addrspace(4) constant i32 500101 102; Function Attrs: convergent noinline norecurse nounwind optnone103define internal void @__omp_offloading_fd02_727e9_h_l12_debug__(ptr noalias noundef %0) #0 !dbg !15 {104 %2 = alloca ptr, align 8, addrspace(5)105 %3 = alloca i32, align 4, addrspace(5)106 %4 = alloca [2 x i32], align 4, addrspace(5)107 %5 = addrspacecast ptr addrspace(5) %2 to ptr108 %6 = addrspacecast ptr addrspace(5) %3 to ptr109 %7 = addrspacecast ptr addrspace(5) %4 to ptr110 store ptr %0, ptr %5, align 8111 #dbg_declare(ptr addrspace(5) %2, !23, !DIExpression(), !24)112 %8 = call i32 @__kmpc_target_init(ptr addrspacecast (ptr addrspace(1) @__omp_offloading_fd02_727e9_h_l12_kernel_environment to ptr), ptr %0), !dbg !25113 %9 = icmp eq i32 %8, -1, !dbg !25114 br i1 %9, label %10, label %11, !dbg !25115 11610: ; preds = %1117 #dbg_declare(ptr addrspace(5) %3, !26, !DIExpression(), !29)118 #dbg_declare(ptr addrspace(5) %4, !30, !DIExpression(), !34)119 call void @f() #4, !dbg !35120 call void @g() #4, !dbg !36121 call void @__kmpc_target_deinit(), !dbg !37122 ret void, !dbg !38123 12411: ; preds = %1125 ret void, !dbg !25126}127 128; Function Attrs: convergent mustprogress noinline norecurse nounwind optnone129define weak_odr protected amdgpu_kernel void @__omp_offloading_fd02_727e9_h_l12(ptr noalias noundef %0) #1 !dbg !39 {130 %2 = alloca ptr, align 8, addrspace(5)131 %3 = addrspacecast ptr addrspace(5) %2 to ptr132 store ptr %0, ptr %3, align 8133 #dbg_declare(ptr addrspace(5) %2, !40, !DIExpression(), !41)134 %4 = load ptr, ptr %3, align 8, !dbg !42135 call void @__omp_offloading_fd02_727e9_h_l12_debug__(ptr %4) #5, !dbg !42136 ret void, !dbg !42137}138 139declare i32 @__kmpc_target_init(ptr, ptr)140 141; Function Attrs: convergent142declare void @f(...) #2143 144declare void @__kmpc_target_deinit()145 146; Function Attrs: convergent noinline nounwind optnone147define hidden void @g() #3 !dbg !43 {148 %1 = alloca i32, align 4, addrspace(5)149 %2 = alloca [2 x i32], align 4, addrspace(5)150 %3 = addrspacecast ptr addrspace(5) %1 to ptr151 %4 = addrspacecast ptr addrspace(5) %2 to ptr152 #dbg_declare(ptr addrspace(5) %1, !46, !DIExpression(), !47)153 #dbg_declare(ptr addrspace(5) %2, !48, !DIExpression(), !49)154 call void @f() #4, !dbg !50155 call void @g() #4, !dbg !51156 ret void, !dbg !52157}158 159attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }160attributes #1 = { convergent mustprogress noinline norecurse nounwind optnone "amdgpu-flat-work-group-size"="1,256" "frame-pointer"="all" "kernel" "no-trapping-math"="true" "omp_target_thread_limit"="256" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" }161attributes #2 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }162attributes #3 = { convergent noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx906" "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }163attributes #4 = { convergent }164attributes #5 = { nounwind }165 166!llvm.dbg.cu = !{!0}167!omp_offload.info = !{!2}168!llvm.module.flags = !{!3, !4, !5, !6, !7, !8, !9, !10, !11}169!llvm.ident = !{!12, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13, !13}170!opencl.ocl.version = !{!14, !14, !14, !14, !14, !14, !14, !14, !14, !14, !14, !14, !14, !14, !14, !14}171 172!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git (/tmp/llvm/clang b9447c03a9ef2eed55b685a33511df86f7f94e89)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)173!1 = !DIFile(filename: "test.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "27a878d5e894ab6d41bfe96f997f8821")174!2 = !{i32 0, i32 64770, i32 468969, !"h", i32 12, i32 0, i32 0}175!3 = !{i32 1, !"amdhsa_code_object_version", i32 500}176!4 = !{i32 7, !"Dwarf Version", i32 5}177!5 = !{i32 2, !"Debug Info Version", i32 3}178!6 = !{i32 1, !"wchar_size", i32 4}179!7 = !{i32 7, !"openmp", i32 51}180!8 = !{i32 7, !"openmp-device", i32 51}181!9 = !{i32 8, !"PIC Level", i32 2}182!10 = !{i32 7, !"frame-pointer", i32 2}183!11 = !{i32 4, !"amdgpu_hostcall", i32 1}184!12 = !{!"clang version 20.0.0git (/tmp/llvm/clang b9447c03a9ef2eed55b685a33511df86f7f94e89)"}185!13 = !{!"AMD clang version 17.0.0 (https://github.com/ROCm/llvm-project roc-6.0.2 24012 af27734ed982b52a9f1be0f035ac91726fc697e4)"}186!14 = !{i32 2, i32 0}187!15 = distinct !DISubprogram(name: "__omp_offloading_fd02_727e9_h_l12_debug__", scope: !16, file: !16, line: 13, type: !17, scopeLine: 13, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !22)188!16 = !DIFile(filename: "test.c", directory: "/tmp")189!17 = !DISubroutineType(types: !18)190!18 = !{null, !19}191!19 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !20)192!20 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !21)193!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)194!22 = !{}195!23 = !DILocalVariable(name: "dyn_ptr", arg: 1, scope: !15, type: !19, flags: DIFlagArtificial)196!24 = !DILocation(line: 0, scope: !15)197!25 = !DILocation(line: 13, column: 3, scope: !15)198!26 = !DILocalVariable(name: "i", scope: !27, file: !16, line: 14, type: !28)199!27 = distinct !DILexicalBlock(scope: !15, file: !16, line: 13, column: 3)200!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)201!29 = !DILocation(line: 14, column: 9, scope: !27)202!30 = !DILocalVariable(name: "a", scope: !27, file: !16, line: 15, type: !31)203!31 = !DICompositeType(tag: DW_TAG_array_type, baseType: !28, size: 64, elements: !32)204!32 = !{!33}205!33 = !DISubrange(count: 2)206!34 = !DILocation(line: 15, column: 9, scope: !27)207!35 = !DILocation(line: 16, column: 5, scope: !27)208!36 = !DILocation(line: 17, column: 5, scope: !27)209!37 = !DILocation(line: 18, column: 3, scope: !27)210!38 = !DILocation(line: 18, column: 3, scope: !15)211!39 = distinct !DISubprogram(name: "__omp_offloading_fd02_727e9_h_l12", scope: !16, file: !16, line: 12, type: !17, scopeLine: 12, flags: DIFlagArtificial | DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !22)212!40 = !DILocalVariable(name: "dyn_ptr", arg: 1, scope: !39, type: !19, flags: DIFlagArtificial)213!41 = !DILocation(line: 0, scope: !39)214!42 = !DILocation(line: 12, column: 1, scope: !39)215!43 = distinct !DISubprogram(name: "g", scope: !16, file: !16, line: 3, type: !44, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !22)216!44 = !DISubroutineType(types: !45)217!45 = !{null}218!46 = !DILocalVariable(name: "i", scope: !43, file: !16, line: 4, type: !28)219!47 = !DILocation(line: 4, column: 7, scope: !43)220!48 = !DILocalVariable(name: "a", scope: !43, file: !16, line: 5, type: !31)221!49 = !DILocation(line: 5, column: 7, scope: !43)222!50 = !DILocation(line: 6, column: 3, scope: !43)223!51 = !DILocation(line: 7, column: 3, scope: !43)224!52 = !DILocation(line: 8, column: 1, scope: !43)225