1; This test checks if debug loc is propagated to load/store created by GVN/Instcombine. 2; RUN: opt < %s -gvn -S | FileCheck %s --check-prefixes=ALL 3; RUN: opt < %s -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(void *v, void* n); 15 16; int test(struct desc *desc) 17; { 18; void *v, *n; 19; v = !desc ? ((void *)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 { %struct.node* } 32%struct.node = type { i32*, %struct.desc* } 33 34define i32 @test_no_null_opt(%struct.desc* readonly %desc) local_unnamed_addr #0 !dbg !4 { 35entry: 36 %tobool = icmp eq %struct.desc* %desc, null 37 br i1 %tobool, label %cond.end, label %cond.false, !dbg !9 38; ALL: br i1 %tobool, label %entry.cond.end_crit_edge, label %cond.false, !dbg [[LOC_15_6:![0-9]+]] 39; ALL: entry.cond.end_crit_edge: 40; ALL: load %struct.node*, %struct.node** null, align {{[0-9]+}}, !dbg [[LOC_16_13:![0-9]+]] 41 42cond.false: 43 %0 = bitcast %struct.desc* %desc to i8***, !dbg !11 44 %1 = load i8**, i8*** %0, align 8, !dbg !11 45 %2 = load i8*, i8** %1, align 8 46 br label %cond.end, !dbg !9 47 48cond.end: 49; ALL: phi %struct.node* [ %3, %cond.false ], [ %.pre, %entry.cond.end_crit_edge ] 50; ALL: phi i8* [ %2, %cond.false ], [ null, %entry.cond.end_crit_edge ] 51 52 %3 = phi i8* [ %2, %cond.false ], [ null, %entry ], !dbg !9 53 %node2 = getelementptr inbounds %struct.desc, %struct.desc* %desc, i64 0, i32 0 54 %4 = load %struct.node*, %struct.node** %node2, align 8, !dbg !10 55 %descs = getelementptr inbounds %struct.node, %struct.node* %4, i64 0, i32 1 56 %5 = bitcast %struct.desc** %descs to i8** 57 %6 = load i8*, i8** %5, align 8 58 %call = tail call i32 @bar(i8* %3, i8* %6) 59 ret i32 %call 60} 61attributes #0 = { null_pointer_is_valid } 62 63declare i32 @bar(i8*, i8*) local_unnamed_addr #1 64!llvm.dbg.cu = !{!0} 65!llvm.module.flags = !{!2, !3} 66 67!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug) 68!1 = !DIFile(filename: "test.c", directory: ".") 69!2 = !{i32 2, !"Dwarf Version", i32 4} 70!3 = !{i32 2, !"Debug Info Version", i32 3} 71!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) 72!5 = !DISubroutineType(types: !6) 73!6 = !{!7} 74!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 75!8 = !{} 76!9 = !DILocation(line: 15, column: 6, scope: !4) 77!10 = !DILocation(line: 16, column: 13, scope: !4) 78!11 = !DILocation(line: 15, column: 34, scope: !4) 79 80;ALL: [[SCOPE:![0-9]+]] = distinct !DISubprogram(name: "test_no_null_opt",{{.*}} 81;ALL: [[LOC_15_6]] = !DILocation(line: 15, column: 6, scope: [[SCOPE]]) 82;ALL: [[LOC_16_13]] = !DILocation(line: 16, column: 13, scope: [[SCOPE]]) 83