aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/CodeExtractor
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/CodeExtractor')
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineCallRef.ll56
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineOptRemark.ll73
-rw-r--r--test/Transforms/CodeExtractor/unreachable-block.ll38
3 files changed, 167 insertions, 0 deletions
diff --git a/test/Transforms/CodeExtractor/PartialInlineCallRef.ll b/test/Transforms/CodeExtractor/PartialInlineCallRef.ll
new file mode 100644
index 000000000000..4465a0fd4852
--- /dev/null
+++ b/test/Transforms/CodeExtractor/PartialInlineCallRef.ll
@@ -0,0 +1,56 @@
+; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
+
+
+; Function Attrs: nounwind
+declare void @foo(...) local_unnamed_addr #0
+
+; Function Attrs: noinline
+define i32 @caller(i32 (i32)* nocapture %arg, i32 (i32)* nocapture %arg1, i32 %arg2) local_unnamed_addr #1 {
+bb:
+ %tmp = tail call i32 %arg(i32 %arg2) #0
+ %tmp3 = tail call i32 %arg1(i32 %arg2) #0
+ %tmp4 = add nsw i32 %tmp3, %tmp
+ ret i32 %tmp4
+}
+
+; Function Attrs: nounwind
+define i32 @bar(i32 %arg) #0 {
+bb:
+ %tmp = icmp slt i32 %arg, 0
+ br i1 %tmp, label %bb1, label %bb2
+
+bb1: ; preds = %bb
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ tail call void (...) @foo() #0
+ br label %bb2
+
+bb2: ; preds = %bb1, %bb
+ %tmp3 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
+ ret i32 %tmp3
+}
+
+; Function Attrs: nounwind
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
+bb:
+; CHECK-LABEL: @dummy_caller
+; check that caller is not wrongly inlined by partial inliner
+; CHECK: call i32 @caller
+; CHECK-NOT: call .* @bar
+ %tmp = tail call i32 @caller(i32 (i32)* nonnull @bar, i32 (i32)* nonnull @bar, i32 %arg)
+ ret i32 %tmp
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { noinline }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 5.0.0 (trunk 300897) (llvm/trunk 300947)"}
diff --git a/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll b/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll
new file mode 100644
index 000000000000..3ba03843046c
--- /dev/null
+++ b/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll
@@ -0,0 +1,73 @@
+; RUN: opt -S -partial-inliner -pass-remarks=partial-inlining -disable-output < %s 2>&1 | FileCheck %s
+; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining -disable-output < %s 2>&1 | FileCheck %s
+; RUN: opt -S -partial-inliner -pass-remarks=partial-inlining -disable-output -max-partial-inlining=1 < %s 2>&1 | FileCheck %s
+; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining -disable-output -max-partial-inlining=1 < %s 2>&1 | FileCheck %s
+
+; RUN: opt -S -partial-inliner -pass-remarks=partial-inlining -disable-partial-inlining < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
+; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining --disable-partial-inlining < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
+; RUN: opt -S -partial-inliner -pass-remarks=partial-inlining -max-partial-inlining=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
+; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining -max-partial-inlining=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
+
+define i32 @bar(i32 %arg) local_unnamed_addr #0 !dbg !5 {
+bb:
+ %tmp = icmp slt i32 %arg, 0, !dbg !7
+ br i1 %tmp, label %bb1, label %bb2, !dbg !8
+
+bb1: ; preds = %bb
+ tail call void (...) @foo() #0, !dbg !9
+ tail call void (...) @foo() #0, !dbg !10
+ tail call void (...) @foo() #0, !dbg !11
+ tail call void (...) @foo() #0, !dbg !12
+ tail call void (...) @foo() #0, !dbg !13
+ tail call void (...) @foo() #0, !dbg !14
+ tail call void (...) @foo() #0, !dbg !15
+ tail call void (...) @foo() #0, !dbg !16
+ tail call void (...) @foo() #0, !dbg !17
+ br label %bb2, !dbg !18
+
+bb2: ; preds = %bb1, %bb
+ %tmp3 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
+ ret i32 %tmp3, !dbg !19
+}
+
+; Function Attrs: nounwind
+declare void @foo(...) local_unnamed_addr #0
+
+; Function Attrs: nounwind
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 !dbg !20 {
+bb:
+; CHECK:remark{{.*}}bar partially inlined into dummy_caller
+; LIMIT-NOT:remark{{.*}}bar partially inlined into dummy_caller
+ %tmp = tail call i32 @bar(i32 %arg), !dbg !21
+ ret i32 %tmp, !dbg !22
+}
+
+attributes #0 = { nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!llvm.ident = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
+!1 = !DIFile(filename: "t.c", directory: "/tmp")
+!2 = !{}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{!"clang "}
+!5 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !6, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
+!6 = !DISubroutineType(types: !2)
+!7 = !DILocation(line: 4, column: 14, scope: !5)
+!8 = !DILocation(line: 4, column: 6, scope: !5)
+!9 = !DILocation(line: 5, column: 5, scope: !5)
+!10 = !DILocation(line: 6, column: 5, scope: !5)
+!11 = !DILocation(line: 7, column: 5, scope: !5)
+!12 = !DILocation(line: 8, column: 5, scope: !5)
+!13 = !DILocation(line: 9, column: 5, scope: !5)
+!14 = !DILocation(line: 10, column: 5, scope: !5)
+!15 = !DILocation(line: 11, column: 5, scope: !5)
+!16 = !DILocation(line: 12, column: 5, scope: !5)
+!17 = !DILocation(line: 13, column: 5, scope: !5)
+!18 = !DILocation(line: 14, column: 5, scope: !5)
+!19 = !DILocation(line: 17, column: 1, scope: !5)
+!20 = distinct !DISubprogram(name: "dummy_caller", scope: !1, file: !1, line: 19, type: !6, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
+!21 = !DILocation(line: 21, column: 11, scope: !20)
+!22 = !DILocation(line: 21, column: 4, scope: !20)
diff --git a/test/Transforms/CodeExtractor/unreachable-block.ll b/test/Transforms/CodeExtractor/unreachable-block.ll
new file mode 100644
index 000000000000..d20a35718e68
--- /dev/null
+++ b/test/Transforms/CodeExtractor/unreachable-block.ll
@@ -0,0 +1,38 @@
+; RUN: opt -S -partial-inliner %s | FileCheck %s
+
+; CHECK-LABEL: define void @dipsy(
+; CHECK-NEXT: call void @tinkywinky.1_ontrue()
+; CHECK-NEXT: call void @patatuccio()
+; CHECK-NEXT: ret void
+; CHECK-NEXT: }
+
+; CHECK-LABEL: define internal void @tinkywinky.1_ontrue() {
+; CHECK-NEXT: newFuncRoot:
+; CHECK-NEXT: br label %ontrue
+; CHECK: .exitStub:
+; CHECK-NEXT: ret void
+; CHECK: ontrue:
+; CHECK-NEXT: call void @patatino()
+; CHECK-NEXT: br label %onfalse
+; CHECK: onfalse:
+; CHECK-NEXT: br label %.exitStub
+; CHECK-NEXT: }
+
+declare void @patatino()
+declare void @patatuccio()
+
+define fastcc void @tinkywinky() {
+ br i1 true, label %ontrue, label %onfalse
+ontrue:
+ call void @patatino()
+ br label %onfalse
+onfalse:
+ call void @patatuccio()
+ ret void
+cantreachme:
+ ret void
+}
+define void @dipsy() {
+ call fastcc void @tinkywinky()
+ ret void
+}