]> granicus.if.org Git - clang/commitdiff
force size of alloca to i32, which is currently required by LLVM IR.
authorChris Lattner <sabre@nondot.org>
Mon, 16 Jun 2008 17:15:14 +0000 (17:15 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 16 Jun 2008 17:15:14 +0000 (17:15 +0000)
This fixes use of alloca on 64-bit systems.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52334 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBuiltin.cpp

index 51d7ced2d83ba25344224703a0c4d6726ed29a78..f8132f417de74e6816c1959742230c14cd2e2f8c 100644 (file)
@@ -261,10 +261,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) {
     return RValue::get(Builder.CreateZExt(LHS, ConvertType(E->getType()),
                                           "tmp"));
   }
-  case Builtin::BI__builtin_alloca:
-    return RValue::get(Builder.CreateAlloca(llvm::Type::Int8Ty,
-                                            EmitScalarExpr(E->getArg(0)),
+  case Builtin::BI__builtin_alloca: {
+    // FIXME: LLVM IR Should allow alloca with an i64 size!
+    Value *Size = EmitScalarExpr(E->getArg(0));
+    Size = Builder.CreateIntCast(Size, llvm::Type::Int32Ty, false, "tmp");
+    return RValue::get(Builder.CreateAlloca(llvm::Type::Int8Ty, Size,
                                             "tmp"));
+  }
   case Builtin::BI__builtin_memcpy: {
     Value* MemCpyOps[4] = {
       EmitScalarExpr(E->getArg(0)),