xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/builtins.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple=x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR8839
4*f4a2713aSLionel Sambuc extern "C" char memmove();
5*f4a2713aSLionel Sambuc 
main()6*f4a2713aSLionel Sambuc int main() {
7*f4a2713aSLionel Sambuc   // CHECK: call {{signext i8|i8}} @memmove()
8*f4a2713aSLionel Sambuc   return memmove();
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc struct S;
12*f4a2713aSLionel Sambuc // CHECK: define {{.*}} @_Z9addressofbR1SS0_(
addressof(bool b,S & s,S & t)13*f4a2713aSLionel Sambuc S *addressof(bool b, S &s, S &t) {
14*f4a2713aSLionel Sambuc   // CHECK: %[[LVALUE:.*]] = phi
15*f4a2713aSLionel Sambuc   // CHECK: ret {{.*}}* %[[LVALUE]]
16*f4a2713aSLionel Sambuc   return __builtin_addressof(b ? s : t);
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc extern "C" int __builtin_abs(int); // #1
20*f4a2713aSLionel Sambuc long __builtin_abs(long);          // #2
21*f4a2713aSLionel Sambuc extern "C" int __builtin_abs(int); // #3
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc int x = __builtin_abs(-2);
24*f4a2713aSLionel Sambuc // CHECK:  store i32 2, i32* @x, align 4
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc long y = __builtin_abs(-2l);
27*f4a2713aSLionel Sambuc // CHECK:  [[Y:%.+]] = call i64 @_Z13__builtin_absl(i64 -2)
28*f4a2713aSLionel Sambuc // CHECK:  store i64 [[Y]], i64* @y, align 8
29