xref: /llvm-project/llvm/test/DebugInfo/return-same-line-merge.ll (revision b25ad38307fdf162d7030a002b6ef1d2048fda55)
1; RUN: opt -passes=simplifycfg -S < %s | FileCheck %s
2;
3; Simplified from the following code:
4; int foo() {
5;   if(c) { return a; } else { return b; }
6; }
7define i32 @foo(i32 %c, i32 %a, i32 %b) !dbg !4 {
8; CHECK: define i32 @foo({{.*}}) !dbg [[FOO_SUBPROGRAM:![0-9]+]]
9; CHECK-NEXT:  entry:
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]])
15entry:
16  %tobool = icmp ne i32 %c, 0, !dbg !7
17  br i1 %tobool, label %cond.true, label %cond.false, !dbg !8
18
19cond.true:                                        ; preds = %entry
20  ret i32 %a, !dbg !9
21
22cond.false:                                       ; preds = %entry
23  ret i32 %b, !dbg !10
24}
25
26!llvm.dbg.cu = !{!0}
27!llvm.module.flags = !{!2, !3}
28
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)
35!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)
40