1 ; RUN: opt -simplifycfg -simplifycfg-require-and-preserve-domtree=1 -hoist-common-insts=true -S < %s | FileCheck %s
2 ; Verify that we don't crash due an invalid !dbg location on the hoisted llvm.dbg.value
4 define i64 @caller(i64* %ptr, i64 %flag) !dbg !10 {
6 %v9 = icmp eq i64 %flag, 0
7 br i1 %v9, label %a, label %b
9 ; CHECK: %vala = load i64, i64* %ptr
10 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD:![0-9]*]]
11 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %vala, metadata [[MD]]
12 ; CHECK-NEXT: %valbmasked = and i64 %vala, 1
15 %vala = load i64, i64* %ptr, align 8
16 call void @llvm.dbg.value(metadata i64 %vala, metadata !8, metadata !DIExpression()), !dbg !12
20 %valb = load i64, i64* %ptr, align 8
21 call void @llvm.dbg.value(metadata i64 %valb, metadata !8, metadata !DIExpression()), !dbg !13
22 %valbmasked = and i64 %valb, 1
25 test.exit: ; preds = %a, %b
26 %retv = phi i64 [ %vala, %a ], [ %valbmasked, %b ]
30 ; CHECK: [[MD]] = !DILocalVariable(name: "var"
32 ; Function Attrs: nounwind readnone speculatable
33 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
35 attributes #0 = { nounwind readnone speculatable }
37 !llvm.module.flags = !{!0}
40 !0 = !{i32 2, !"Debug Info Version", i32 3}
41 !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3)
42 !2 = !DIFile(filename: "optbug", directory: "")
44 !4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !1, retainedNodes: !7)
45 !5 = !DISubroutineType(types: !6)
48 !8 = !DILocalVariable(name: "var", scope: !4, file: !2, type: !9)
49 !9 = !DIBasicType(name: "var_t", size: 64, encoding: DW_ATE_unsigned)
50 !10 = distinct !DISubprogram(name: "caller", scope: !2, file: !2, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, isOptimized: false, unit: !1, retainedNodes: !3)
51 !11 = distinct !DILocation(line: 6, scope: !10)
52 !12 = !DILocation(line: 2, scope: !4, inlinedAt: !11)
53 !13 = !DILocation(line: 3, scope: !4, inlinedAt: !11)