1 ; This test checks if debug loc is propagated to load/store created by GVN/Instcombine.
2 ; RUN: opt < %s -passes=gvn -S | FileCheck %s --check-prefixes=ALL
3 ; RUN: opt < %s -passes=gvn,instcombine -S | FileCheck %s --check-prefixes=ALL
14 ; extern int bar(void *v, void* n);
16 ; int test(struct desc *desc)
19 ; v = !desc ? ((void *)0) : desc->node->v; // Line 15
20 ; n = &desc->node->descs[0]; // Line 16
25 ; n = &desc->node->descs[0];
28 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
29 target triple = "aarch64--linux-gnu"
31 %struct.desc = type { ptr }
32 %struct.node = type { ptr, ptr }
34 define i32 @test_no_null_opt(ptr readonly %desc) local_unnamed_addr #0 !dbg !4 {
36 %tobool = icmp eq ptr %desc, null
37 br i1 %tobool, label %cond.end, label %cond.false, !dbg !9
38 ; ALL: %.pre = load ptr, ptr %desc, align 8, !dbg [[LOC_16_13:![0-9]+]]
39 ; ALL: br i1 %tobool, label %cond.end, label %cond.false, !dbg [[LOC_15_6:![0-9]+]]
43 %0 = load ptr, ptr %desc, align 8, !dbg !11
44 %1 = load ptr, ptr %0, align 8
45 br label %cond.end, !dbg !9
48 ; ALL: phi ptr [ %0, %cond.false ], [ null, %entry ]
50 %2 = phi ptr [ %1, %cond.false ], [ null, %entry ], !dbg !9
51 %3 = load ptr, ptr %desc, align 8, !dbg !10
52 %descs = getelementptr inbounds %struct.node, ptr %3, i64 0, i32 1
53 %4 = load ptr, ptr %descs, align 8
54 %call = tail call i32 @bar(ptr %2, ptr %4)
57 attributes #0 = { null_pointer_is_valid }
59 declare i32 @bar(ptr, ptr) local_unnamed_addr #1
61 !llvm.module.flags = !{!2, !3}
63 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
64 !1 = !DIFile(filename: "test.c", directory: ".")
65 !2 = !{i32 2, !"Dwarf Version", i32 4}
66 !3 = !{i32 2, !"Debug Info Version", i32 3}
67 !4 = distinct !DISubprogram(name: "test_no_null_opt", scope: !1, file: !1, line: 12, type: !5, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8)
68 !5 = !DISubroutineType(types: !6)
70 !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
72 !9 = !DILocation(line: 15, column: 6, scope: !4)
73 !10 = !DILocation(line: 16, column: 13, scope: !4)
74 !11 = !DILocation(line: 15, column: 34, scope: !4)
76 ;ALL: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "test_no_null_opt",{{.*}}
77 ;ALL: [[LOC_16_13]] = !DILocation(line: 16, column: 13, scope: [[SCOPE]])
78 ;ALL: [[LOC_15_6]] = !DILocation(line: 15, column: 6, scope: [[SCOPE]])