1cee313d2SEric Christopher; RUN: opt < %s -passes=add-discriminators -S | FileCheck %s 2cee313d2SEric Christopher 3cee313d2SEric Christopher; Discriminator support for multiple CFG paths on the same line. 4cee313d2SEric Christopher; 5cee313d2SEric Christopher; void foo(int i) { 6cee313d2SEric Christopher; int x; 7cee313d2SEric Christopher; if (i < 10) x = i; else x = -i; 8cee313d2SEric Christopher; } 9cee313d2SEric Christopher; 10cee313d2SEric Christopher; The two stores inside the if-then-else line must have different discriminator 11cee313d2SEric Christopher; values. 12cee313d2SEric Christopher 13cee313d2SEric Christopherdefine void @foo(i32 %i) #0 !dbg !4 { 14cee313d2SEric Christopherentry: 15cee313d2SEric Christopher %i.addr = alloca i32, align 4 16cee313d2SEric Christopher %x = alloca i32, align 4 17*fc655a9eSNikita Popov store i32 %i, ptr %i.addr, align 4 18*fc655a9eSNikita Popov %0 = load i32, ptr %i.addr, align 4, !dbg !10 19cee313d2SEric Christopher %cmp = icmp slt i32 %0, 10, !dbg !10 20cee313d2SEric Christopher br i1 %cmp, label %if.then, label %if.else, !dbg !10 21cee313d2SEric Christopher 22cee313d2SEric Christopherif.then: ; preds = %entry 23*fc655a9eSNikita Popov %1 = load i32, ptr %i.addr, align 4, !dbg !10 24*fc655a9eSNikita Popov; CHECK: %1 = load i32, ptr %i.addr, align 4, !dbg ![[THEN:[0-9]+]] 25cee313d2SEric Christopher 26*fc655a9eSNikita Popov store i32 %1, ptr %x, align 4, !dbg !10 27*fc655a9eSNikita Popov; CHECK: store i32 %1, ptr %x, align 4, !dbg ![[THEN]] 28cee313d2SEric Christopher 29cee313d2SEric Christopher br label %if.end, !dbg !10 30cee313d2SEric Christopher; CHECK: br label %if.end, !dbg ![[THEN]] 31cee313d2SEric Christopher 32cee313d2SEric Christopherif.else: ; preds = %entry 33*fc655a9eSNikita Popov %2 = load i32, ptr %i.addr, align 4, !dbg !10 34*fc655a9eSNikita Popov; CHECK: %2 = load i32, ptr %i.addr, align 4, !dbg ![[ELSE:[0-9]+]] 35cee313d2SEric Christopher 36cee313d2SEric Christopher %sub = sub nsw i32 0, %2, !dbg !10 37cee313d2SEric Christopher; CHECK: %sub = sub nsw i32 0, %2, !dbg ![[ELSE]] 38cee313d2SEric Christopher 39*fc655a9eSNikita Popov store i32 %sub, ptr %x, align 4, !dbg !10 40*fc655a9eSNikita Popov; CHECK: store i32 %sub, ptr %x, align 4, !dbg ![[ELSE]] 41cee313d2SEric Christopher 42cee313d2SEric Christopher br label %if.end 43cee313d2SEric Christopher 44cee313d2SEric Christopherif.end: ; preds = %if.else, %if.then 45cee313d2SEric Christopher ret void, !dbg !12 46cee313d2SEric Christopher} 47cee313d2SEric Christopher 484ab3041aSserge-sans-pailleattributes #0 = { nounwind uwtable "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" } 49cee313d2SEric Christopher 50cee313d2SEric Christopher!llvm.dbg.cu = !{!0} 51cee313d2SEric Christopher!llvm.module.flags = !{!7, !8} 52cee313d2SEric Christopher!llvm.ident = !{!9} 53cee313d2SEric Christopher 54cee313d2SEric Christopher!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 (trunk 199750) (llvm/trunk 199751)", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 55cee313d2SEric Christopher!1 = !DIFile(filename: "multiple.c", directory: ".") 56cee313d2SEric Christopher!2 = !{} 57cee313d2SEric 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) 58cee313d2SEric Christopher!5 = !DIFile(filename: "multiple.c", directory: ".") 59cee313d2SEric Christopher!6 = !DISubroutineType(types: !{null, !13}) 60cee313d2SEric Christopher!13 = !DIBasicType(encoding: DW_ATE_signed, name: "int", size: 32, align: 32) 61cee313d2SEric Christopher!7 = !{i32 2, !"Dwarf Version", i32 4} 62cee313d2SEric Christopher!8 = !{i32 1, !"Debug Info Version", i32 3} 63cee313d2SEric Christopher!9 = !{!"clang version 3.5 (trunk 199750) (llvm/trunk 199751)"} 64cee313d2SEric Christopher!10 = !DILocation(line: 3, scope: !11) 65cee313d2SEric Christopher!11 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !4) 66cee313d2SEric Christopher!12 = !DILocation(line: 4, scope: !4) 67cee313d2SEric Christopher 68cee313d2SEric Christopher; CHECK: ![[THEN]] = !DILocation(line: 3, scope: ![[THENBLOCK:[0-9]+]]) 69cee313d2SEric Christopher; CHECK: ![[THENBLOCK]] = !DILexicalBlockFile(scope: ![[SCOPE:[0-9]+]],{{.*}} discriminator: 2) 70cee313d2SEric Christopher; CHECK: ![[ELSE]] = !DILocation(line: 3, scope: ![[ELSEBLOCK:[0-9]+]]) 71cee313d2SEric Christopher; CHECK: ![[ELSEBLOCK]] = !DILexicalBlockFile(scope: ![[SCOPE]],{{.*}} discriminator: 4) 72