summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-01-08 21:45:23 +0000
committerDale Johannesen <dalej@apple.com>2009-01-08 21:45:23 +0000
commit4362387c74d8fb07ec914b3173abf834d639ff39 (patch)
tree0c7c4308429d7eea8c254da50dfa688bf5c64fc3 /test/Transforms
parent86062afbc49b549a653d38fb03702051f3917df7 (diff)
downloadllvm-4362387c74d8fb07ec914b3173abf834d639ff39.tar.gz
llvm-4362387c74d8fb07ec914b3173abf834d639ff39.tar.bz2
llvm-4362387c74d8fb07ec914b3173abf834d639ff39.tar.xz
Do not inline functions with (dynamic) alloca into
functions that don't already have a (dynamic) alloca. Dynamic allocas cause inefficient codegen and we shouldn't propagate this (behavior follows gcc). Two existing tests assumed such inlining would be done; they are hacked by adding an alloca in the caller, preserving the point of the tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/Inline/2009-01-08-NoInlineDynamicAlloca.ll36
-rw-r--r--test/Transforms/Inline/dynamic_alloca_test.ll4
-rw-r--r--test/Transforms/PruneEH/2008-09-05-CGUpdate.ll5
3 files changed, 45 insertions, 0 deletions
diff --git a/test/Transforms/Inline/2009-01-08-NoInlineDynamicAlloca.ll b/test/Transforms/Inline/2009-01-08-NoInlineDynamicAlloca.ll
new file mode 100644
index 0000000000..14840bac67
--- /dev/null
+++ b/test/Transforms/Inline/2009-01-08-NoInlineDynamicAlloca.ll
@@ -0,0 +1,36 @@
+; RUN: llvm-as < %s | opt -inline | llvm-dis | grep call
+; Do not inline calls to variable-sized alloca.
+
+@q = common global i8* null ; <i8**> [#uses=1]
+
+define i8* @a(i32 %i) nounwind {
+entry:
+ %i_addr = alloca i32 ; <i32*> [#uses=2]
+ %retval = alloca i8* ; <i8**> [#uses=1]
+ %p = alloca i8* ; <i8**> [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ store i32 %i, i32* %i_addr
+ %0 = load i32* %i_addr, align 4 ; <i32> [#uses=1]
+ %1 = alloca i8, i32 %0 ; <i8*> [#uses=1]
+ store i8* %1, i8** %p, align 4
+ %2 = load i8** %p, align 4 ; <i8*> [#uses=1]
+ store i8* %2, i8** @q, align 4
+ br label %return
+
+return: ; preds = %entry
+ %retval1 = load i8** %retval ; <i8*> [#uses=1]
+ ret i8* %retval1
+}
+
+define void @b(i32 %i) nounwind {
+entry:
+ %i_addr = alloca i32 ; <i32*> [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
+ store i32 %i, i32* %i_addr
+ %0 = load i32* %i_addr, align 4 ; <i32> [#uses=1]
+ %1 = call i8* @a(i32 %0) nounwind ; <i8*> [#uses=0]
+ br label %return
+
+return: ; preds = %entry
+ ret void
+}
diff --git a/test/Transforms/Inline/dynamic_alloca_test.ll b/test/Transforms/Inline/dynamic_alloca_test.ll
index 87707120e6..b8ff7dedc4 100644
--- a/test/Transforms/Inline/dynamic_alloca_test.ll
+++ b/test/Transforms/Inline/dynamic_alloca_test.ll
@@ -1,5 +1,7 @@
; Test that functions with dynamic allocas get inlined in a case where
; naively inlining it would result in a miscompilation.
+; Functions with dynamic allocas can only be inlined into functions that
+; already have dynamic allocas.
; RUN: llvm-as < %s | opt -inline | llvm-dis | \
; RUN: grep llvm.stacksave
@@ -16,6 +18,8 @@ define internal void @callee(i32 %N) {
define void @foo(i32 %N) {
; <label>:0
+ %P = alloca i32, i32 %N ; <i32*> [#uses=1]
+ call void @ext( i32* %P )
br label %Loop
Loop: ; preds = %Loop, %0
diff --git a/test/Transforms/PruneEH/2008-09-05-CGUpdate.ll b/test/Transforms/PruneEH/2008-09-05-CGUpdate.ll
index 6e847fcfdc..c3600ab84c 100644
--- a/test/Transforms/PruneEH/2008-09-05-CGUpdate.ll
+++ b/test/Transforms/PruneEH/2008-09-05-CGUpdate.ll
@@ -636,6 +636,9 @@ lpad: ; preds = %entry, %invcont
define internal fastcc i32 @ce3806g__fxio__put__4.1215(i8* %to.0, %struct.string___XUB* %to.1, i8 signext %item) {
entry:
+ %P0 = load i32 * @__gnat_all_others_value, align 4 ; <i32*> [#uses=1]
+ %P = alloca i32, i32 %P0 ; <i32*> [#uses=1]
+ call void @ext( i32* %P )
%to_addr = alloca %struct.system__file_control_block__pstring ; <%struct.system__file_control_block__pstring*> [#uses=4]
%FRAME.358 = alloca %struct.FRAME.ce3806g__fxio__put__4 ; <%struct.FRAME.ce3806g__fxio__put__4*> [#uses=65]
%0 = getelementptr %struct.system__file_control_block__pstring* %to_addr, i32 0, i32 0 ; <i8**> [#uses=1]
@@ -1435,6 +1438,8 @@ declare %struct.ada__text_io__text_afcb* @ada__text_io__standard_output()
declare void @report__failed(i8*, %struct.string___XUB*)
+declare void @ext(i32*)
+
declare %struct.ada__text_io__text_afcb* @ada__text_io__delete(%struct.ada__text_io__text_afcb*)
declare void @report__result()