1 ; RUN: opt -passes=simplifycfg -S < %s | FileCheck %s
3 ; Simplified from the following code:
5 ; if(c) { return a; } else { return b; }
7 define i32 @foo(i32 %c, i32 %a, i32 %b) !dbg !4 {
8 ; CHECK: define i32 @foo({{.*}}) !dbg [[FOO_SUBPROGRAM:![0-9]+]]
10 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[C:%.*]], 0, !dbg [[DBG_CMP:![0-9]+]]
11 ; CHECK-NEXT: [[A_B:%.*]] = select i1 [[TOBOOL]], i32 [[A:%.*]], i32 [[B:%.*]]
12 ; CHECK-NEXT: ret i32 [[A_B]], !dbg [[DBG_RET:![0-9]+]]
13 ; CHECK: [[DBG_CMP]] = !DILocation(line: 2, column: 1, scope: [[FOO_SUBPROGRAM]])
14 ; CHECK: [[DBG_RET]] = !DILocation(line: 4, scope: [[FOO_SUBPROGRAM]])
16 %tobool = icmp ne i32 %c, 0, !dbg !7
17 br i1 %tobool, label %cond.true, label %cond.false, !dbg !8
19 cond.true: ; preds = %entry
22 cond.false: ; preds = %entry
27 !llvm.module.flags = !{!2, !3}
29 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 16.0.0)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, nameTableKind: None)
30 !1 = !DIFile(filename: "test.c", directory: "/")
31 !2 = !{i32 7, !"Dwarf Version", i32 5}
32 !3 = !{i32 2, !"Debug Info Version", i32 3}
33 !4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !6)
34 !5 = !DISubroutineType(types: !6)
36 !7 = !DILocation(line: 2, column: 1, scope: !4)
37 !8 = !DILocation(line: 3, column: 1, scope: !4)
38 !9 = !DILocation(line: 4, column: 1, scope: !4)
39 !10 = !DILocation(line: 4, column: 2, scope: !4)