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