diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 12 | ||||
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 16 |
2 files changed, 9 insertions, 19 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 86bc347576..db6aae6dfd 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -192,17 +192,9 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { // Allocate memory for the array. llvm::Value *VLA = Builder.CreateAlloca(llvm::Type::Int8Ty, VLASize, "vla"); - VLA = Builder.CreateBitCast(VLA, LElemPtrTy, "tmp"); - - llvm::AllocaInst *Alloc = - CreateTempAlloca(LElemPtrTy, D.getIdentifier()->getName()); - - // FIXME: Volatile? - Builder.CreateStore(VLA, Alloc); - - DeclPtr = Alloc; + DeclPtr = Builder.CreateBitCast(VLA, LElemPtrTy, "tmp"); } - + llvm::Value *&DMEntry = LocalDeclMap[&D]; assert(DMEntry == 0 && "Decl already exists in localdeclmap!"); DMEntry = DeclPtr; diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index ffb5164782..4984d0df35 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -513,16 +513,14 @@ Value *ScalarExprEmitter::VisitImplicitCastExpr(const ImplicitCastExpr *E) { // FIXME: For now we assume that all source arrays map to LLVM arrays. This // will not true when we add support for VLAs. Value *V = EmitLValue(Op).getAddress(); // Bitfields can't be arrays. - - if (!(isa<llvm::PointerType>(V->getType()) && - isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType()) - ->getElementType()))) { - CGF.ErrorUnsupported(E, "variable-length array cast", true); - if (E->getType()->isVoidType()) - return 0; - return llvm::UndefValue::get(CGF.ConvertType(E->getType())); + + if (!Op->getType()->isVariableArrayType()) { + assert(isa<llvm::PointerType>(V->getType()) && "Expected pointer"); + assert(isa<llvm::ArrayType>(cast<llvm::PointerType>(V->getType()) + ->getElementType()) && + "Expected pointer to array"); + V = Builder.CreateStructGEP(V, 0, "arraydecay"); } - V = Builder.CreateStructGEP(V, 0, "arraydecay"); // The resultant pointer type can be implicitly casted to other pointer // types as well (e.g. void*) and can be implicitly converted to integer. |