-fms-extensions: Recognize _alloca as an alias for the alloca builtin

Differential Revision: http://llvm-reviews.chandlerc.com/D1989

llvm-svn: 194617
This commit is contained in:
Reid Kleckner 2013-11-13 22:58:53 +00:00
parent aae88013c7
commit 59e4a6f5e2
3 changed files with 11 additions and 0 deletions

View File

@ -675,6 +675,7 @@ BUILTIN(__builtin_index, "c*cC*i", "Fn")
BUILTIN(__builtin_rindex, "c*cC*i", "Fn")
// Microsoft builtins. These are only active with -fms-extensions.
LANGBUILTIN(_alloca, "v*z", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__assume, "vb", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__noop, "v.", "n", ALL_MS_LANGUAGES)
LANGBUILTIN(__debugbreak, "v", "n", ALL_MS_LANGUAGES)

View File

@ -604,6 +604,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
}
case Builtin::BIalloca:
case Builtin::BI_alloca:
case Builtin::BI__builtin_alloca: {
Value *Size = EmitScalarExpr(E->getArg(0));
return RValue::get(Builder.CreateAlloca(Builder.getInt8Ty(), Size));

View File

@ -0,0 +1,9 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -fms-extensions -triple i686-pc-win32 | FileCheck %s
// CHECK-LABEL: define void @test_alloca
void capture(void *);
void test_alloca(int n) {
capture(_alloca(n));
// CHECK: %[[arg:.*]] = alloca i8, i32 %
// CHECK: call void @capture(i8* %[[arg]])
}