1 ; RUN: llc %s -mtriple=x86_64-unknown-unknown -o - -stop-after=livedebugvalues | FileCheck %s
3 ; In the C below, 'baz' is re-assigned with a value that gets salvaged, making
4 ; it's dbg.value base itself on 'bar', but with a complex expression.
5 ; LiveDebugValues should recognize that these are different locations, and not
6 ; propagate a location for 'baz' into the return block.
8 ; void escape1(int bees);
9 ; void escape2(int bees);
23 ; We should get a plain DBG_VALUE in the entry block, a plain one then complex
24 ; one in the block two, and none in block three.
25 ; CHECK: ![[BAZVAR:[0-9]+]] = !DILocalVariable(name: "baz",
26 ; CHECK-LABEL: bb.0.entry:
27 ; CHECK: DBG_VALUE {{[0-9a-zA-Z$%_]*}}, $noreg, ![[BAZVAR]],
28 ; CHECK-SAME: !DIExpression()
29 ; CHECK-LABEL: bb.1.if.then:
30 ; CHECK-LABEL: bb.2.if.else:
31 ; CHECK: DBG_VALUE {{[0-9a-zA-Z$%_]*}}, $noreg, ![[BAZVAR]],
32 ; CHECK-SAME: !DIExpression()
33 ; CHECK: DBG_VALUE {{[0-9a-zA-Z$%_]*}}, $noreg, ![[BAZVAR]],
34 ; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)
35 ; CHECK-LABEL: bb.3.if.end:
36 ; CHECK-NOT: DBG_VALUE
38 declare void @escape1(i32)
39 declare void @escape2(i32)
40 declare void @llvm.dbg.value(metadata, metadata, metadata)
42 define i32 @foo(i32 returned %bar) !dbg !7 {
44 call void @llvm.dbg.value(metadata i32 %bar, metadata !13, metadata !DIExpression()), !dbg !14
45 %cmp = icmp eq i32 %bar, 12, !dbg !14
46 br i1 %cmp, label %if.then, label %if.else, !dbg !14
49 tail call void @escape1(i32 12) #3, !dbg !14
50 br label %if.end, !dbg !14
53 call void @llvm.dbg.value(metadata i32 %bar, metadata !13, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !14
54 tail call void @escape2(i32 %bar) #3, !dbg !14
58 ret i32 %bar, !dbg !14
62 !llvm.module.flags = !{!3, !4}
64 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
65 !1 = !DIFile(filename: "exprconflict.c", directory: "/home/jmorse")
67 !3 = !{i32 2, !"Dwarf Version", i32 4}
68 !4 = !{i32 2, !"Debug Info Version", i32 3}
69 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
70 !8 = !DISubroutineType(types: !9)
72 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
74 !13 = !DILocalVariable(name: "baz", scope: !7, file: !1, line: 6, type: !10)
75 !14 = !DILocation(line: 1, scope: !7)