Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/X86/dimodule-external-fortran.ll

raw
1 ; This test verifies that the debug info for an external Fortran module
2 ; is correctly generated.
3 ;
4 ; To generate the test source, compile the following two files in order in
5 ; the same directory (as the second compilation uses the .mod from the first):
6 ; external_module.f90 (to compile: <fortran compiler> -g -c external_module.f90)
7 ; module external_module
8 ; real :: dummy
9 ; end module external_module
10 ;
11 ; em.f90 (to compile: <fortran compierl> -g -llvm-emit -c -S em.f90)
12 ; program use_external_module
13 ; use external_module
14 ; implicit none
15 ;
16 ; real :: x
17 ; x = 2.0 + dummy
18 ;
19 ; end program use_external_module
20 ;
21 ; The test would be in em.ll.
22
23 ; RUN: llvm-as < %s -o %t.bc
24 ; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_debug_module %t.bc -o %t.spv
25 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
26 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj %t.ll -o - | llvm-dwarfdump - | FileCheck %s
27
28 ; CHECK: [[DIE_ID:0x[0-9a-f]+]]: DW_TAG_module
29 ; CHECK-NEXT: DW_AT_name ("external_module")
30 ; CHECK-NEXT: DW_AT_declaration (true)
31
32 ; CHECK: DW_TAG_imported_module
33 ; CHECK-NEXT: DW_AT_decl_file
34 ; CHECK-NEXT: DW_AT_decl_line
35 ; CHECK-NEXT: DW_AT_import ([[DIE_ID]])
36
37 ; When the debugger sees the module being imported is a declaration,
38 ; it should go to the global scope to find the module's definition.
39
40 ; ModuleID = 'em.f90'
41 source_filename = "em.f90"
42 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
43 target triple = "spir64-unknown-unknown"
44
45 @external_module_mp_dummy_ = available_externally global float 0.000000e+00, align 8, !dbg !0
46 @0 = internal unnamed_addr constant i32 2
47
48 ; Function Attrs: noinline nounwind uwtable
49 define void @MAIN__() #0 !dbg !2 {
50 alloca_0:
51 %"var$1" = alloca [8 x i64], align 8
52 %"use_external_module_$X" = alloca float, align 8
53 call void @llvm.dbg.declare(metadata float* %"use_external_module_$X", metadata !13, metadata !DIExpression()), !dbg !17
54 %func_result = call i32 @for_set_reentrancy(i32* @0), !dbg !18
55 %external_module_mp_dummy__fetch = load float, float* @external_module_mp_dummy_, align 1, !dbg !19
56 %add = fadd reassoc ninf nsz arcp contract afn float 2.000000e+00, %external_module_mp_dummy__fetch, !dbg !20
57 store float %add, float* %"use_external_module_$X", align 1, !dbg !19
58 ret void, !dbg !21
59 }
60
61 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
62 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
63
64 declare i32 @for_set_reentrancy(i32*)
65
66 attributes #0 = { noinline nounwind uwtable "intel-lang"="fortran" "min-legal-vector-width"="0" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
67 attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
68
69 !llvm.module.flags = !{!15, !16}
70 !llvm.dbg.cu = !{!6}
71 !omp_offload.info = !{}
72
73 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
74 !1 = distinct !DIGlobalVariable(name: "dummy", linkageName: "external_module_mp_dummy_", scope: !2, file: !3, line: 1, type: !14, isLocal: false, isDefinition: true)
75 !2 = distinct !DISubprogram(name: "use_external_module", linkageName: "MAIN__", scope: !3, file: !3, line: 1, type: !4, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !12)
76 !3 = !DIFile(filename: "em.f90", directory: "tests")
77 !4 = !DISubroutineType(types: !5)
78 !5 = !{null}
79 !6 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3, producer: "Intel(R) Fortran 21.0-2165", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !7, globals: !8, imports: !9, splitDebugInlining: false, nameTableKind: None)
80 !7 = !{}
81 !8 = !{!0}
82 !9 = !{!10}
83 !10 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !2, entity: !11, file: !3, line: 2)
84 !11 = !DIModule(scope: !2, name: "external_module", isDecl: true)
85 !12 = !{!13}
86 !13 = !DILocalVariable(name: "x", scope: !2, file: !3, line: 5, type: !14)
87 !14 = !DIBasicType(name: "REAL*4", size: 32, encoding: DW_ATE_float)
88 !15 = !{i32 2, !"Debug Info Version", i32 3}
89 !16 = !{i32 2, !"Dwarf Version", i32 4}
90 !17 = !DILocation(line: 5, column: 12, scope: !2)
91 !18 = !DILocation(line: 1, column: 9, scope: !2)
92 !19 = !DILocation(line: 6, column: 4, scope: !2)
93 !20 = !DILocation(line: 6, column: 12, scope: !2)
94 !21 = !DILocation(line: 8, column: 1, scope: !2)