summaryrefslogtreecommitdiff
path: root/test/Transforms/Inline/dynamic_alloca_test.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-01-13 19:35:05 +0000
committerChris Lattner <sabre@nondot.org>2006-01-13 19:35:05 +0000
commitf0638c5f710996d355f91866179bd49fa991750f (patch)
tree353f4d1f5b3e8de4f14f0b7518cbdc35223a1369 /test/Transforms/Inline/dynamic_alloca_test.ll
parentbf229f488a7541abd979cc3fbe9c3ce1c100e5c0 (diff)
downloadllvm-f0638c5f710996d355f91866179bd49fa991750f.tar.gz
llvm-f0638c5f710996d355f91866179bd49fa991750f.tar.bz2
llvm-f0638c5f710996d355f91866179bd49fa991750f.tar.xz
New testcase that functions with dynamic allocas can be inlined, and are
inlined correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/Inline/dynamic_alloca_test.ll')
-rw-r--r--test/Transforms/Inline/dynamic_alloca_test.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Transforms/Inline/dynamic_alloca_test.ll b/test/Transforms/Inline/dynamic_alloca_test.ll
new file mode 100644
index 0000000000..27c7d717a1
--- /dev/null
+++ b/test/Transforms/Inline/dynamic_alloca_test.ll
@@ -0,0 +1,28 @@
+; Test that functions with dynamic allocas get inlined in a case where
+; naively inlining it would result in a miscompilation.
+
+; RUN: llvm-as < %s | opt -inline &&
+; RUN: llvm-as < %s | opt -inline | llvm-dis | grep llvm.stacksave &&
+; RUN: llvm-as < %s | opt -inline | llvm-dis | not grep callee
+
+declare void %ext(int*)
+implementation
+
+internal void %callee(uint %N) {
+ %P = alloca int, uint %N ;; dynamic alloca
+ call void %ext(int* %P)
+ ret void
+}
+
+void %foo(uint %N) {
+ br label %Loop
+Loop:
+ %count = phi uint [0, %0], [%next, %Loop]
+ %next = add uint %count, 1
+ call void %callee(uint %N)
+ %cond = seteq uint %count, 100000
+ br bool %cond, label %out, label %Loop
+out:
+ ret void
+}
+