summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/StackColoring.ll
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-09-13 12:38:37 +0000
committerNadav Rotem <nrotem@apple.com>2012-09-13 12:38:37 +0000
commit0cd19b93017fcaba737b15ea4da39c460feb5670 (patch)
treec617b980559e63ac861c6ae97eaccc43fc89ddd9 /test/CodeGen/X86/StackColoring.ll
parent2d9eb72178af8e79dc6432cd1b7d29bde16da1b9 (diff)
downloadllvm-0cd19b93017fcaba737b15ea4da39c460feb5670.tar.gz
llvm-0cd19b93017fcaba737b15ea4da39c460feb5670.tar.bz2
llvm-0cd19b93017fcaba737b15ea4da39c460feb5670.tar.xz
Stack Coloring: We have code that checks that all of the uses of allocas
are within the lifetime zone. Sometime legitimate usages of allocas are hoisted outside of the lifetime zone. For example, GEPS may calculate the address of a member of an allocated struct. This commit makes sure that we only check (abort regions or assert) for instructions that read and write memory using stack frames directly. Notice that by allowing legitimate usages outside the lifetime zone we also stop checking for instructions which use derivatives of allocas. We will catch less bugs in user code and in the compiler itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/StackColoring.ll')
-rw-r--r--test/CodeGen/X86/StackColoring.ll24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/CodeGen/X86/StackColoring.ll b/test/CodeGen/X86/StackColoring.ll
index a83a4ebbe2..f8ae74f292 100644
--- a/test/CodeGen/X86/StackColoring.ll
+++ b/test/CodeGen/X86/StackColoring.ll
@@ -376,6 +376,30 @@ block2:
}
+; Check that we don't assert and crash even when there are usages
+; of allocas which do not read or write outside the declared lifetime regions.
+;YESCOLOR: shady_range
+;NOCOLOR: shady_range
+
+%struct.Klass = type { i32, i32 }
+
+define i32 @shady_range(i32 %argc, i8** nocapture %argv) uwtable {
+ %a.i = alloca [4 x %struct.Klass], align 16
+ %b.i = alloca [4 x %struct.Klass], align 16
+ %a8 = bitcast [4 x %struct.Klass]* %a.i to i8*
+ %b8 = bitcast [4 x %struct.Klass]* %b.i to i8*
+ ; I am used outside the lifetime zone below:
+ %z2 = getelementptr inbounds [4 x %struct.Klass]* %a.i, i64 0, i64 0, i32 0
+ call void @llvm.lifetime.start(i64 -1, i8* %a8)
+ call void @llvm.lifetime.start(i64 -1, i8* %b8)
+ %z3 = load i32* %z2, align 16
+ %r = call i32 @foo(i32 %z3, i8* %a8)
+ %r2 = call i32 @foo(i32 %z3, i8* %b8)
+ call void @llvm.lifetime.end(i64 -1, i8* %a8)
+ call void @llvm.lifetime.end(i64 -1, i8* %b8)
+ ret i32 9
+}
+
declare void @bar([100 x i32]* , [100 x i32]*) nounwind
declare void @llvm.lifetime.start(i64, i8* nocapture) nounwind