Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give builtins and alloc/dealloc operators the default calling convent…
…ion. On SPIR targets, the default calling convention is SpirFunction. However, operator new/delete and builtins were being created with CC_C. The result is indirect references to new/delete (or builtins that are permitted to be called indirectly have a mismatched type, as well as questionable codegen in some cases. This patch sets both to the default calling convention, so that it properly matches the calling convention of the target. Differential Revision: https://reviews.llvm.org/D58844 Change-Id: I52065bb00bc2655945caea8f29c409ba1e0ac24a llvm-svn: 355317
- Loading branch information
Erich Keane
committed
Mar 4, 2019
1 parent
eeb1144
commit 881e83d
Showing
3 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |