]> granicus.if.org Git - clang/commitdiff
-fms-extensions: Recognize _alloca as an alias for the alloca builtin
authorReid Kleckner <reid@kleckner.net>
Wed, 13 Nov 2013 22:58:53 +0000 (22:58 +0000)
committerReid Kleckner <reid@kleckner.net>
Wed, 13 Nov 2013 22:58:53 +0000 (22:58 +0000)
Differential Revision: http://llvm-reviews.chandlerc.com/D1989

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

include/clang/Basic/Builtins.def
lib/CodeGen/CGBuiltin.cpp
test/CodeGen/builtins-ms.c [new file with mode: 0644]

index b1f92a15c6f020d5fbe2b919e9d6bb20acd3c0cc..55c6ed7deead90476047ec25c50a168a6fb96003 100644 (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)
index 1c62615f815055758d3494d5e024b0707fac95e3..d2f8662b54b36d6a91173e3223be2abef1552652 100644 (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));
diff --git a/test/CodeGen/builtins-ms.c b/test/CodeGen/builtins-ms.c
new file mode 100644 (file)
index 0000000..0676e9d
--- /dev/null
@@ -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]])
+}