Fix VLA miscompilation.

llvm.stacksave/llvm.stackrestore wasn't emitted for VLAs in inner scopes.
Fixes r8403108.

llvm-svn: 113822
This commit is contained in:
Argyrios Kyrtzidis 2010-09-14 00:42:34 +00:00
parent 2967e28ee7
commit 9efa1ce145
2 changed files with 17 additions and 1 deletions

View File

@ -562,6 +562,7 @@ public:
{
CleanupStackDepth = CGF.EHStack.stable_begin();
OldDidCallStackSave = CGF.DidCallStackSave;
CGF.DidCallStackSave = false;
}
/// \brief Exit this cleanup scope, emitting any accumulated

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 %s -emit-llvm -o %t
// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
int b(char* x);
@ -35,3 +35,18 @@ void g(int count) {
int (*a[5])[count];
int (*b)[][count];
}
// rdar://8403108
// CHECK: define void @f_8403108
void f_8403108(unsigned x) {
// CHECK: call i8* @llvm.stacksave()
char s1[x];
while (1) {
// CHECK: call i8* @llvm.stacksave()
char s2[x];
if (1)
break;
// CHECK: call void @llvm.stackrestore(i8*
}
// CHECK: call void @llvm.stackrestore(i8*
}