xref: /llvm-project/clang/test/CodeGenCXX/builtin-calling-conv.cpp (revision 5c2a133b1342881dc4f42a896e7e5f4b85d20508)
1 // RUN: %clang_cc1 -triple x86_64-linux-pc -DREDECL -emit-llvm %s -o - | FileCheck %s -check-prefix LINUX
2 // RUN: %clang_cc1 -triple spir-unknown-unknown -DREDECL -DSPIR -emit-llvm %s -o - | FileCheck %s -check-prefix SPIR
3 // RUN: %clang_cc1 -triple x86_64-linux-pc -emit-llvm %s -o - | FileCheck %s -check-prefix LINUX
4 // RUN: %clang_cc1 -triple spir-unknown-unknown -DSPIR -emit-llvm %s -o - | FileCheck %s -check-prefix SPIR
5 // RUN: %clang_cc1 -triple i386-windows-pc -fdefault-calling-conv=stdcall -emit-llvm %s -o - | FileCheck %s -check-prefix WIN32
6 
7 #ifdef REDECL
8 namespace std {
9 #ifdef SPIR
10 using size_t = unsigned int;
11 #else
12 using size_t = unsigned long;
13 #endif // SPIR
14 } // namespace std
15 
16 float __builtin_erff(float);
17 void *operator new(std::size_t);
18 #endif // REDECL
19 
20 void foo();
21 
22 void user() {
23   int i;
24   ::operator new(5);
25   (void)__builtin_erff(1.1);
26   foo();
27 }
28 
29 // LINUX: define{{.*}} void @_Z4userv()
30 // LINUX: call noalias noundef nonnull ptr @_Znwm
31 // LINUX: call float @erff
32 // LINUX: call void @_Z3foov
33 // LINUX: declare noundef nonnull ptr @_Znwm(i64 noundef)
34 // LINUX: declare float @erff(float noundef)
35 // LINUX: declare void @_Z3foov()
36 
37 // SPIR: define{{.*}} spir_func void @_Z4userv()
38 // SPIR: call spir_func noalias noundef nonnull ptr @_Znwj
39 // SPIR: call spir_func float @erff
40 // SPIR: call spir_func void @_Z3foov
41 // SPIR: declare spir_func noundef nonnull ptr @_Znwj(i32 noundef)
42 // SPIR: declare spir_func float @erff(float noundef)
43 // SPIR: declare spir_func void @_Z3foov()
44 
45 // Note: Windows /G options should not change the platform default calling
46 // convention of builtins.
47 // WIN32: define dso_local x86_stdcallcc void @"?user@@YGXXZ"()
48 // WIN32: call noalias noundef nonnull ptr @"??2@YAPAXI@Z"
49 // WIN32: call float @erff
50 // WIN32: call x86_stdcallcc void @"?foo@@YGXXZ"
51 // WIN32: declare dso_local noundef nonnull ptr @"??2@YAPAXI@Z"(
52 // WIN32: declare dso_local float @erff(float noundef)
53 // WIN32: declare dso_local x86_stdcallcc void @"?foo@@YGXXZ"()
54