1 ; RUN: opt -passes=instcombine -S -o - < %s | FileCheck %s
2 ; RUN: opt --try-experimental-debuginfo-iterators -passes=instcombine -S -o - < %s | FileCheck %s
4 ; CHECK-LABEL: %3 = load i32, ptr %i1_311
5 ; CHECK: #dbg_value(i32 %3
6 ; Next instruction should not be duplicate dbg.value intrinsic.
7 ; CHECK-NEXT: @f90io_sc_i_ldw
9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
22 ; integer, intent (in) :: a
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ; ModuleID = 'duplicate_dbgvalue.ll'
29 source_filename = "duplicate_dbgvalue.ll"
30 target datalayout = "e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
31 target triple = "x86_64-unknown-linux-gnu"
33 %struct.BSS1 = type <{ [4 x i8] }>
35 @.BSS1 = internal unnamed_addr global %struct.BSS1 zeroinitializer, align 32, !dbg !0
36 @.C303_MAIN_ = internal constant i32 6
37 @.C300_MAIN_ = internal constant [22 x i8] c"duplicate_dbgvalue.f90"
38 @.C302_MAIN_ = internal constant i32 4
39 @.C283_MAIN_ = internal constant i32 0
40 @.C283_main_mfun = internal constant i32 0
41 @.C302_main_mfun = internal constant i32 6
42 @.C300_main_mfun = internal constant [22 x i8] c"duplicate_dbgvalue.f90"
43 @.C313_main_mfun = internal constant i32 10
45 define void @MAIN_() local_unnamed_addr !dbg !2 {
47 call void (ptr, ...) @fort_init(ptr @.C283_MAIN_), !dbg !16
48 %0 = call fastcc i32 @main_mfun(), !dbg !18
49 store i32 %0, ptr @.BSS1, align 32, !dbg !18
50 call void (ptr, ptr, i64, ...) @f90io_src_info03a(ptr @.C302_MAIN_, ptr @.C300_MAIN_, i64 22), !dbg !23
51 %1 = call i32 (ptr, ptr, ptr, ptr, ...) @f90io_print_init(ptr @.C303_MAIN_, ptr null, ptr @.C283_MAIN_, ptr @.C283_MAIN_), !dbg !23
52 call void @llvm.dbg.value(metadata i32 %1, metadata !24, metadata !DIExpression()), !dbg !25
53 %2 = load i32, ptr @.BSS1, align 32, !dbg !23
54 %3 = call i32 (i32, i32, ...) @f90io_sc_i_ldw(i32 %2, i32 25), !dbg !23
55 call void @llvm.dbg.value(metadata i32 %3, metadata !24, metadata !DIExpression()), !dbg !25
56 %4 = call i32 (...) @f90io_ldw_end(), !dbg !23
57 call void @llvm.dbg.value(metadata i32 %4, metadata !24, metadata !DIExpression()), !dbg !25
61 define internal fastcc signext i32 @main_mfun() unnamed_addr !dbg !27 {
63 %i1_311 = alloca i32, align 4
64 call void @llvm.dbg.declare(metadata ptr undef, metadata !31, metadata !DIExpression()), !dbg !33
65 call void @llvm.dbg.declare(metadata ptr %i1_311, metadata !35, metadata !DIExpression()), !dbg !33
66 store i32 5, ptr %i1_311, align 4, !dbg !36
67 %0 = call fastcc float @main_fun(ptr %i1_311), !dbg !41
68 %1 = fptosi float %0 to i32, !dbg !41
69 call void (ptr, ptr, i64, ...) @f90io_src_info03a(ptr @.C313_main_mfun, ptr @.C300_main_mfun, i64 22), !dbg !42
70 %2 = call i32 (ptr, ptr, ptr, ptr, ...) @f90io_print_init(ptr @.C302_main_mfun, ptr null, ptr @.C283_main_mfun, ptr @.C283_main_mfun), !dbg !42
71 call void @llvm.dbg.value(metadata i32 %2, metadata !43, metadata !DIExpression()), !dbg !33
72 %3 = load i32, ptr %i1_311, align 4, !dbg !42
73 call void @llvm.dbg.value(metadata i32 %3, metadata !35, metadata !DIExpression()), !dbg !33
74 %4 = call i32 (i32, i32, ...) @f90io_sc_i_ldw(i32 %3, i32 25), !dbg !42
75 call void @llvm.dbg.value(metadata i32 %4, metadata !43, metadata !DIExpression()), !dbg !33
76 %5 = call i32 (...) @f90io_ldw_end(), !dbg !42
77 call void @llvm.dbg.value(metadata i32 %5, metadata !43, metadata !DIExpression()), !dbg !33
81 define internal fastcc float @main_fun(ptr noalias %a) unnamed_addr !dbg !45 {
83 call void @llvm.dbg.declare(metadata ptr %a, metadata !50, metadata !DIExpression()), !dbg !51
84 call void @llvm.dbg.declare(metadata ptr undef, metadata !53, metadata !DIExpression()), !dbg !51
85 %0 = load i32, ptr %a, align 4, !dbg !54
86 %1 = sitofp i32 %0 to float, !dbg !54
87 ret float %1, !dbg !59
90 declare signext i32 @f90io_ldw_end(...) local_unnamed_addr
92 declare signext i32 @f90io_sc_i_ldw(...) local_unnamed_addr
94 ; Function Attrs: nounwind readnone speculatable willreturn
95 declare void @llvm.dbg.declare(metadata, metadata, metadata)
97 declare signext i32 @f90io_print_init(...) local_unnamed_addr
99 declare void @f90io_src_info03a(...) local_unnamed_addr
101 declare void @fort_init(...) local_unnamed_addr
103 ; Function Attrs: nounwind readnone speculatable willreturn
104 declare void @llvm.dbg.value(metadata, metadata, metadata)
106 !llvm.module.flags = !{!14, !15}
109 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
110 !1 = distinct !DIGlobalVariable(name: "res", scope: !2, file: !3, type: !9, isLocal: true, isDefinition: true)
111 !2 = distinct !DISubprogram(name: "main", scope: !4, file: !3, line: 1, type: !12, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !4)
112 !3 = !DIFile(filename: "duplicate-dbgvalue.f90", directory: "/dir")
113 !4 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !3, producer: " F90 Flang - 1.5", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
116 !7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
117 !8 = distinct !DIGlobalVariable(name: "res", scope: !4, file: !3, type: !9, isLocal: true, isDefinition: true)
118 !9 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
119 !10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())
120 !11 = distinct !DIGlobalVariable(name: "res", scope: !4, file: !3, type: !9, isLocal: true, isDefinition: true)
121 !12 = !DISubroutineType(cc: DW_CC_program, types: !13)
123 !14 = !{i32 2, !"Dwarf Version", i32 4}
124 !15 = !{i32 2, !"Debug Info Version", i32 3}
125 !16 = !DILocation(line: 1, column: 1, scope: !17)
126 !17 = !DILexicalBlock(scope: !2, file: !3, line: 1, column: 1)
127 !18 = !DILocation(line: 3, column: 1, scope: !17)
128 !19 = !{!20, !20, i64 0}
129 !20 = !{!"t1.2", !21, i64 0}
130 !21 = !{!"unlimited ptr", !22, i64 0}
131 !22 = !{!"Flang FAA 1"}
132 !23 = !DILocation(line: 4, column: 1, scope: !17)
133 !24 = !DILocalVariable(scope: !17, file: !3, type: !9, flags: DIFlagArtificial)
134 !25 = !DILocation(line: 0, scope: !17)
135 !26 = !DILocation(line: 5, column: 1, scope: !17)
136 !27 = distinct !DISubprogram(name: "mfun", scope: !2, file: !3, line: 6, type: !28, scopeLine: 6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4)
137 !28 = !DISubroutineType(types: !29)
139 !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64, align: 64)
140 !31 = !DILocalVariable(arg: 1, scope: !27, file: !3, type: !32, flags: DIFlagArtificial)
141 !32 = !DIBasicType(name: "uinteger*8", size: 64, align: 64, encoding: DW_ATE_unsigned)
142 !33 = !DILocation(line: 0, scope: !34)
143 !34 = !DILexicalBlock(scope: !27, file: !3, line: 6, column: 1)
144 !35 = !DILocalVariable(name: "i1", scope: !34, file: !3, type: !9)
145 !36 = !DILocation(line: 8, column: 1, scope: !34)
146 !37 = !{!38, !38, i64 0}
147 !38 = !{!"t2.2", !39, i64 0}
148 !39 = !{!"unlimited ptr", !40, i64 0}
149 !40 = !{!"Flang FAA 2"}
150 !41 = !DILocation(line: 9, column: 1, scope: !34)
151 !42 = !DILocation(line: 10, column: 1, scope: !34)
152 !43 = !DILocalVariable(scope: !34, file: !3, type: !9, flags: DIFlagArtificial)
153 !44 = !DILocation(line: 11, column: 1, scope: !34)
154 !45 = distinct !DISubprogram(name: "fun", scope: !2, file: !3, line: 12, type: !46, scopeLine: 12, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4)
155 !46 = !DISubroutineType(types: !47)
157 !48 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !49, size: 64, align: 64)
158 !49 = !DIBasicType(name: "real", size: 32, align: 32, encoding: DW_ATE_float)
159 !50 = !DILocalVariable(name: "a", arg: 1, scope: !45, file: !3, type: !9)
160 !51 = !DILocation(line: 0, scope: !52)
161 !52 = !DILexicalBlock(scope: !45, file: !3, line: 12, column: 1)
162 !53 = !DILocalVariable(arg: 2, scope: !45, file: !3, type: !32, flags: DIFlagArtificial)
163 !54 = !DILocation(line: 14, column: 1, scope: !52)
164 !55 = !{!56, !56, i64 0}
165 !56 = !{!"t3.2", !57, i64 0}
166 !57 = !{!"unlimited ptr", !58, i64 0}
167 !58 = !{!"Flang FAA 3"}
168 !59 = !DILocation(line: 15, column: 1, scope: !52)