1cee313d2SEric Christopher; RUN: opt < %s -passes=add-discriminators -S | FileCheck %s 2cee313d2SEric Christopher 3cee313d2SEric Christopher; Basic DWARF discriminator test. All the instructions in block 4cee313d2SEric Christopher; 'if.then' should have a different discriminator value than 5cee313d2SEric Christopher; the conditional branch at the end of block 'entry'. 6cee313d2SEric Christopher; 7cee313d2SEric Christopher; Original code: 8cee313d2SEric Christopher; 9cee313d2SEric Christopher; void foo(int i) { 10cee313d2SEric Christopher; int x; 11cee313d2SEric Christopher; if (i < 10) x = i; 12cee313d2SEric Christopher; } 13cee313d2SEric Christopher 14cee313d2SEric Christopherdefine void @foo(i32 %i) #0 !dbg !4 { 15cee313d2SEric Christopherentry: 16cee313d2SEric Christopher %i.addr = alloca i32, align 4 17cee313d2SEric Christopher %x = alloca i32, align 4 18*fc655a9eSNikita Popov store i32 %i, ptr %i.addr, align 4 19*fc655a9eSNikita Popov %0 = load i32, ptr %i.addr, align 4, !dbg !10 20cee313d2SEric Christopher %cmp = icmp slt i32 %0, 10, !dbg !10 21cee313d2SEric Christopher br i1 %cmp, label %if.then, label %if.end, !dbg !10 22cee313d2SEric Christopher 23cee313d2SEric Christopherif.then: ; preds = %entry 24*fc655a9eSNikita Popov %1 = load i32, ptr %i.addr, align 4, !dbg !10 25*fc655a9eSNikita Popov; CHECK: %1 = load i32, ptr %i.addr, align 4, !dbg ![[THEN:[0-9]+]] 26cee313d2SEric Christopher 27*fc655a9eSNikita Popov store i32 %1, ptr %x, align 4, !dbg !10 28*fc655a9eSNikita Popov; CHECK: store i32 %1, ptr %x, align 4, !dbg ![[THEN]] 29cee313d2SEric Christopher 30cee313d2SEric Christopher br label %if.end, !dbg !10 31cee313d2SEric Christopher; CHECK: br label %if.end, !dbg ![[THEN]] 32cee313d2SEric Christopher 33cee313d2SEric Christopherif.end: ; preds = %if.then, %entry 34cee313d2SEric Christopher ret void, !dbg !12 35cee313d2SEric Christopher; CHECK: ret void, !dbg ![[END:[0-9]+]] 36cee313d2SEric Christopher} 37cee313d2SEric Christopher 3879c00d3fSYuanfang Chenattributes #0 = { nounwind uwtable noinline optnone "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 39cee313d2SEric Christopher 40cee313d2SEric Christopher!llvm.dbg.cu = !{!0} 41cee313d2SEric Christopher!llvm.module.flags = !{!7, !8} 42cee313d2SEric Christopher!llvm.ident = !{!9} 43cee313d2SEric Christopher 44cee313d2SEric Christopher!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 ", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 45cee313d2SEric Christopher!1 = !DIFile(filename: "basic.c", directory: ".") 46cee313d2SEric Christopher!2 = !{} 47cee313d2SEric Christopher!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2) 48cee313d2SEric Christopher!5 = !DIFile(filename: "basic.c", directory: ".") 49cee313d2SEric Christopher!6 = !DISubroutineType(types: !2) 50cee313d2SEric Christopher!7 = !{i32 2, !"Dwarf Version", i32 4} 51cee313d2SEric Christopher!8 = !{i32 1, !"Debug Info Version", i32 3} 52cee313d2SEric Christopher!9 = !{!"clang version 3.5 "} 53cee313d2SEric Christopher!10 = !DILocation(line: 3, scope: !11) 54cee313d2SEric Christopher!11 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !4) 55cee313d2SEric Christopher!12 = !DILocation(line: 4, scope: !4) 56cee313d2SEric Christopher 57cee313d2SEric Christopher; CHECK: ![[FOO:[0-9]+]] = distinct !DISubprogram(name: "foo" 58cee313d2SEric Christopher; CHECK: ![[BLOCK:[0-9]+]] = distinct !DILexicalBlock(scope: ![[FOO]],{{.*}} line: 3) 59cee313d2SEric Christopher; CHECK: ![[THEN]] = !DILocation(line: 3, scope: ![[BLOCKFILE:[0-9]+]]) 60cee313d2SEric Christopher; CHECK: ![[BLOCKFILE]] = !DILexicalBlockFile(scope: ![[BLOCK]],{{.*}} discriminator: 2) 61cee313d2SEric Christopher; CHECK: ![[END]] = !DILocation(line: 4, scope: ![[FOO]]) 62