blob: c290f795854fa2e35c5b8bfdc60731e3a910aacb [file] [log] [blame]
Davide Italiano1985e9b2017-07-19 21:39:51 +00001; RUN: opt %s -tailcallelim -pass-remarks=tailcallelim -o /dev/null 2>&1 | FileCheck %s
2; RUN: opt %s -o /dev/null -passes='require<opt-remark-emit>,tailcallelim' -pass-remarks=tailcallelim 2>&1 | FileCheck %s
3
4; CHECK: /home/davide/pat.c:2:20: marked as tail call candidate
5; CHECK: /home/davide/pat.c:2:20: transforming tail recursion into loop
6define i32 @fib(i32 %n) nounwind ssp {
7entry:
8 %cmp = icmp slt i32 %n, 2
9 br i1 %cmp, label %if.then, label %if.end
10
11if.then: ; preds = %entry
12 br label %return
13
14if.end: ; preds = %entry
15 %sub = add nsw i32 %n, -2
16 %call = call i32 @fib(i32 %sub)
17 %sub3 = add nsw i32 %n, -1
18 %call4 = call i32 @fib(i32 %sub3), !dbg !8
19 %add = add nsw i32 %call, %call4
20 br label %return
21
22return: ; preds = %if.end, %if.then
23 %retval.0 = phi i32 [ 1, %if.then ], [ %add, %if.end ]
24 ret i32 %retval.0
25}
26
27!llvm.dbg.cu = !{!0}
28!llvm.module.flags = !{!3, !4}
29!llvm.ident = !{!5}
30
31!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
32!1 = !DIFile(filename: "/home/davide/pat.c", directory: "/tmp")
33!2 = !{}
34!3 = !{i32 2, !"Debug Info Version", i32 3}
35!4 = !{i32 1, !"PIC Level", i32 2}
36!5 = !{!"clang version 3.9.0 "}
37!6 = distinct !DISubprogram(name: "success", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
38!7 = !DISubroutineType(types: !2)
39!8 = !DILocation(line: 2, column: 20, scope: !6)