[cfe-commits] r113822 - in /cfe/trunk: lib/CodeGen/CodeGenFunction.h test/CodeGen/vla.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Sep 13 17:42:34 PDT 2010
Author: akirtzidis
Date: Mon Sep 13 19:42:34 2010
New Revision: 113822
URL: http://llvm.org/viewvc/llvm-project?rev=113822&view=rev
Log:
Fix VLA miscompilation.
llvm.stacksave/llvm.stackrestore wasn't emitted for VLAs in inner scopes.
Fixes r8403108.
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/vla.c
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=113822&r1=113821&r2=113822&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Sep 13 19:42:34 2010
@@ -562,6 +562,7 @@
{
CleanupStackDepth = CGF.EHStack.stable_begin();
OldDidCallStackSave = CGF.DidCallStackSave;
+ CGF.DidCallStackSave = false;
}
/// \brief Exit this cleanup scope, emitting any accumulated
Modified: cfe/trunk/test/CodeGen/vla.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vla.c?rev=113822&r1=113821&r2=113822&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/vla.c (original)
+++ cfe/trunk/test/CodeGen/vla.c Mon Sep 13 19:42:34 2010
@@ -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 @@
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*
+}
More information about the cfe-commits
mailing list