[Inline] Add a basic test for the module inliner
authorKazu Hirata <kazu@google.com>
Fri, 2 Dec 2022 21:37:57 +0000 (13:37 -0800)
committerKazu Hirata <kazu@google.com>
Fri, 2 Dec 2022 21:37:57 +0000 (13:37 -0800)
The new test ensures that the module inliner works with all currently
supported priority modes.

Different priority modes result in no difference in terms of the
output for these simple cases, so this is more of a "better than
nothing" test.

Differential Revision: https://reviews.llvm.org/D139222

llvm/test/Transforms/Inline/module-inliner-basic.ll [new file with mode: 0644]

diff --git a/llvm/test/Transforms/Inline/module-inliner-basic.ll b/llvm/test/Transforms/Inline/module-inliner-basic.ll
new file mode 100644 (file)
index 0000000..4fede8a
--- /dev/null
@@ -0,0 +1,20 @@
+; RUN: opt -passes=module-inline                                    -S < %s | FileCheck %s
+; RUN: opt -passes=module-inline -inline-priority-mode=size         -S < %s | FileCheck %s
+; RUN: opt -passes=module-inline -inline-priority-mode=cost         -S < %s | FileCheck %s
+; RUN: opt -passes=module-inline -inline-priority-mode=cost-benefit -S < %s | FileCheck %s
+
+define i32 @callee(i32 %a) {
+entry:
+  %add = add nsw i32 %a, 1
+  ret i32 %add
+}
+
+define i32 @caller(i32 %a) {
+entry:
+  %call = call i32 @callee(i32 %a)
+  ret i32 %call
+}
+
+; CHECK-LABEL: @caller
+; CHECK-NOT:     call
+; CHECK:         ret