aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-09-14 00:42:34 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-09-14 00:42:34 +0000
commit4ada2ca7d82dab68d3646f3eb6dcdfee072e8ea4 (patch)
treecdc1b145e91170c4a18d5c5466390e905c5c8321
parent1f6206ed21e026ca7ddaf0bff9599c476301a695 (diff)
Fix VLA miscompilation.
llvm.stacksave/llvm.stackrestore wasn't emitted for VLAs in inner scopes. Fixes r8403108. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113822 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CodeGenFunction.h1
-rw-r--r--test/CodeGen/vla.c17
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 37795ed5db..acf1e4d7b3 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -562,6 +562,7 @@ public:
{
CleanupStackDepth = CGF.EHStack.stable_begin();
OldDidCallStackSave = CGF.DidCallStackSave;
+ CGF.DidCallStackSave = false;
}
/// \brief Exit this cleanup scope, emitting any accumulated
diff --git a/test/CodeGen/vla.c b/test/CodeGen/vla.c
index 0c53900384..17704727b0 100644
--- a/test/CodeGen/vla.c
+++ b/test/CodeGen/vla.c
@@ -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*
+}