r194617 - -fms-extensions: Recognize _alloca as an alias for the alloca builtin
Reid Kleckner
reid at kleckner.net
Wed Nov 13 14:58:54 PST 2013
Author: rnk
Date: Wed Nov 13 16:58:53 2013
New Revision: 194617
URL: http://llvm.org/viewvc/llvm-project?rev=194617&view=rev
Log:
-fms-extensions: Recognize _alloca as an alias for the alloca builtin
Differential Revision: http://llvm-reviews.chandlerc.com/D1989
Added:
cfe/trunk/test/CodeGen/builtins-ms.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=194617&r1=194616&r2=194617&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Nov 13 16:58:53 2013
@@ -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)
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=194617&r1=194616&r2=194617&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Nov 13 16:58:53 2013
@@ -604,6 +604,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
}
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));
Added: cfe/trunk/test/CodeGen/builtins-ms.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ms.c?rev=194617&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/builtins-ms.c (added)
+++ cfe/trunk/test/CodeGen/builtins-ms.c Wed Nov 13 16:58:53 2013
@@ -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]])
+}
More information about the cfe-commits
mailing list