Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp =================================================================== --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -1139,7 +1139,13 @@ case Builtin::BI_alloca: case Builtin::BI__builtin_alloca: { Value *Size = EmitScalarExpr(E->getArg(0)); - return RValue::get(Builder.CreateAlloca(Builder.getInt8Ty(), Size)); + const TargetInfo &TI = getContext().getTargetInfo(); + // The alignment of the alloca should correspond to __BIGGEST_ALIGNMENT__. + unsigned SuitableAlignmentInBytes = + TI.getSuitableAlign() / TI.getCharWidth(); + AllocaInst *AI = Builder.CreateAlloca(Builder.getInt8Ty(), Size); + AI->setAlignment(SuitableAlignmentInBytes); + return RValue::get(AI); } case Builtin::BIbzero: case Builtin::BI__builtin_bzero: { Index: cfe/trunk/test/CodeGen/builtins-ms.c =================================================================== --- cfe/trunk/test/CodeGen/builtins-ms.c +++ cfe/trunk/test/CodeGen/builtins-ms.c @@ -4,6 +4,6 @@ void capture(void *); void test_alloca(int n) { capture(_alloca(n)); - // CHECK: %[[arg:.*]] = alloca i8, i32 % + // CHECK: %[[arg:.*]] = alloca i8, i32 %{{.*}}, align 16 // CHECK: call void @capture(i8* %[[arg]]) }