[PATCH] D58844: Give builtins and alloc/dealloc operators the default calling convention.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 06:54:42 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL355317: Give builtins and alloc/dealloc operators the default calling convention. (authored by erichkeane, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58844?vs=188963&id=189139#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58844/new/

https://reviews.llvm.org/D58844

Files:
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/test/CodeGenCXX/builtin-calling-conv.cpp


Index: cfe/trunk/test/CodeGenCXX/builtin-calling-conv.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/builtin-calling-conv.cpp
+++ cfe/trunk/test/CodeGenCXX/builtin-calling-conv.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-linux-pc -DREDECL -emit-llvm %s -o - | FileCheck %s -check-prefix LINUX
+// RUN: %clang_cc1 -triple spir-unknown-unknown -DREDECL -DSPIR -emit-llvm %s -o - | FileCheck %s -check-prefix SPIR
+// RUN: %clang_cc1 -triple x86_64-linux-pc -emit-llvm %s -o - | FileCheck %s -check-prefix LINUX
+// RUN: %clang_cc1 -triple spir-unknown-unknown -DSPIR -emit-llvm %s -o - | FileCheck %s -check-prefix SPIR
+
+#ifdef REDECL
+namespace std {
+#ifdef SPIR
+using size_t = unsigned int;
+#else
+using size_t = unsigned long;
+#endif // SPIR
+} // namespace std
+
+float __builtin_atan2f(float, float);
+void *operator new(std::size_t);
+#endif // REDECL
+
+void foo();
+
+void user() {
+  int i;
+  ::operator new(5);
+  (void)__builtin_atan2f(1.1, 2.2);
+  foo();
+}
+
+// LINUX: define void @_Z4userv()
+// LINUX: call i8* @_Znwm
+// LINUX: call float @atan2f
+// LINUX: call void @_Z3foov
+// LINUX: declare noalias i8* @_Znwm(i64)
+// LINUX: declare float @atan2f(float, float)
+// LINUX: declare void @_Z3foov()
+
+// SPIR: define spir_func void @_Z4userv()
+// SPIR: call spir_func i8* @_Znwj
+// SPIR: call spir_func float @atan2f
+// SPIR: call spir_func void @_Z3foov
+// SPIR: declare spir_func noalias i8* @_Znwj(i32)
+// SPIR: declare spir_func float @atan2f(float, float)
+// SPIR: declare spir_func void @_Z3foov()
Index: cfe/trunk/lib/AST/ASTContext.cpp
===================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp
+++ cfe/trunk/lib/AST/ASTContext.cpp
@@ -9565,10 +9565,12 @@
   assert((TypeStr[0] != '.' || TypeStr[1] == 0) &&
          "'.' should only occur at end of builtin type list!");
 
-  FunctionType::ExtInfo EI(CC_C);
+  bool Variadic = (TypeStr[0] == '.');
+
+  FunctionType::ExtInfo EI(
+      getDefaultCallingConvention(Variadic, /*IsCXXMethod=*/false));
   if (BuiltinInfo.isNoReturn(Id)) EI = EI.withNoReturn(true);
 
-  bool Variadic = (TypeStr[0] == '.');
 
   // We really shouldn't be making a no-proto type here.
   if (ArgTypes.empty() && Variadic && !getLangOpts().CPlusPlus)
Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -2795,7 +2795,8 @@
     }
   }
 
-  FunctionProtoType::ExtProtoInfo EPI;
+  FunctionProtoType::ExtProtoInfo EPI(Context.getDefaultCallingConvention(
+      /*IsVariadic=*/false, /*IsCXXMethod=*/false));
 
   QualType BadAllocType;
   bool HasBadAllocExceptionSpec


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58844.189139.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190304/ed64f2e7/attachment.bin>


More information about the cfe-commits mailing list