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 4 5; struct node { 6; int *v; 7; struct desc *descs; 8; }; 9 10; struct desc { 11; struct node *node; 12; }; 13 14; extern int bar(ptr v, ptr n); 15 16; int test(struct desc *desc) 17; { 18; ptr v, *n; 19; v = !desc ? ((ptr)0) : desc->node->v; // Line 15 20; n = &desc->node->descs[0]; // Line 16 21; return bar(v, n); 22; } 23 24; Line 16, Column 13: 25; n = &desc->node->descs[0]; 26; ^ 27 28target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" 29target triple = "aarch64--linux-gnu" 30 31%struct.desc = type { ptr } 32%struct.node = type { ptr, ptr } 33 34define i32 @test(ptr readonly %desc) local_unnamed_addr #0 !dbg !4 { 35entry: 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]+]] 40; ALL: cond.false: 41 42cond.false: 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 46 47cond.end: 48 %2 = phi ptr [ %1, %cond.false ], [ null, %entry ], !dbg !9 49 %3 = load ptr, ptr %desc, align 8, !dbg !10 50 %descs = getelementptr inbounds %struct.node, ptr %3, i64 0, i32 1 51 %4 = load ptr, ptr %descs, align 8 52 %call = tail call i32 @bar(ptr %2, ptr %4) 53 ret i32 %call 54} 55 56declare i32 @bar(ptr, ptr) local_unnamed_addr #1 57!llvm.dbg.cu = !{!0} 58!llvm.module.flags = !{!2, !3} 59 60!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug) 61!1 = !DIFile(filename: "test.c", directory: ".") 62!2 = !{i32 2, !"Dwarf Version", i32 4} 63!3 = !{i32 2, !"Debug Info Version", i32 3} 64!4 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 12, type: !5, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8) 65!5 = !DISubroutineType(types: !6) 66!6 = !{!7} 67!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 68!8 = !{} 69!9 = !DILocation(line: 15, column: 6, scope: !4) 70!10 = !DILocation(line: 16, column: 13, scope: !4) 71!11 = !DILocation(line: 15, column: 34, scope: !4) 72 73;ALL: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "test",{{.*}} 74;ALL: [[LOC_16_13]] = !DILocation(line: 16, column: 13, scope: [[SCOPE]]) 75;ALL: [[LOC_15_6]] = !DILocation(line: 15, column: 6, scope: [[SCOPE]]) 76