[cfe-commits] r64028 - /cfe/trunk/lib/CodeGen/CGObjC.cpp

Mike Stump mrs at apple.com
Sat Feb 7 12:09:00 PST 2009


Author: mrs
Date: Sat Feb  7 14:09:00 2009
New Revision: 64028

URL: http://llvm.org/viewvc/llvm-project?rev=64028&view=rev
Log:
Ensure that we don't miscodegen if vlas creap into the top of the for.
This will allow us to generate break and continue even if vlas are
involved without worry that we'll silently generate bad code.

Modified:
    cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=64028&r1=64027&r2=64028&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Sat Feb  7 14:09:00 2009
@@ -446,6 +446,10 @@
   llvm::BasicBlock *LoopStart = createBasicBlock("loopstart");
   EmitBlock(LoopStart);
 
+  // We want to ensure there are no vlas between here and when we
+  // push the break and continue context below.
+  llvm::Value *saveStackDepth = StackDepth;
+
   llvm::Value *CounterPtr = CreateTempAlloca(UnsignedLongLTy, "counter.ptr");
   Builder.CreateStore(Zero, CounterPtr);
   
@@ -515,6 +519,8 @@
   llvm::BasicBlock *LoopEnd = createBasicBlock("loopend");
   llvm::BasicBlock *AfterBody = createBasicBlock("afterbody");
   
+  assert (StackDepth == saveStackDepth && "vla unhandled in for");
+
   BreakContinuePush(LoopEnd, AfterBody);
 
   EmitStmt(S.getBody());





More information about the cfe-commits mailing list