xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/builtin-attributes.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // REQUIRES: arm-registered-target
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // CHECK: declare i32 @printf(i8*, ...)
f0()5*f4a2713aSLionel Sambuc void f0() {
6*f4a2713aSLionel Sambuc   printf("a\n");
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc // CHECK: call void @exit
10*f4a2713aSLionel Sambuc // CHECK: unreachable
f1()11*f4a2713aSLionel Sambuc void f1() {
12*f4a2713aSLionel Sambuc   exit(1);
13*f4a2713aSLionel Sambuc }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc // CHECK: call i8* @strstr{{.*}} [[NUW:#[0-9]+]]
f2(char * a,char * b)16*f4a2713aSLionel Sambuc char* f2(char* a, char* b) {
17*f4a2713aSLionel Sambuc   return __builtin_strstr(a, b);
18*f4a2713aSLionel Sambuc }
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc // frexp is NOT readnone. It writes to its pointer argument.
21*f4a2713aSLionel Sambuc // <rdar://problem/10070234>
22*f4a2713aSLionel Sambuc //
23*f4a2713aSLionel Sambuc // CHECK: f3
24*f4a2713aSLionel Sambuc // CHECK: call double @frexp(double %
25*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
26*f4a2713aSLionel Sambuc // CHECK: call float @frexpf(float %
27*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
28*f4a2713aSLionel Sambuc // CHECK: call double @frexpl(double %
29*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
30*f4a2713aSLionel Sambuc //
31*f4a2713aSLionel Sambuc // Same thing for modf and friends.
32*f4a2713aSLionel Sambuc //
33*f4a2713aSLionel Sambuc // CHECK: call double @modf(double %
34*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
35*f4a2713aSLionel Sambuc // CHECK: call float @modff(float %
36*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
37*f4a2713aSLionel Sambuc // CHECK: call double @modfl(double %
38*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
39*f4a2713aSLionel Sambuc //
40*f4a2713aSLionel Sambuc // CHECK: call double @remquo(double %
41*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
42*f4a2713aSLionel Sambuc // CHECK: call float @remquof(float %
43*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
44*f4a2713aSLionel Sambuc // CHECK: call double @remquol(double %
45*f4a2713aSLionel Sambuc // CHECK-NOT: readnone
46*f4a2713aSLionel Sambuc // CHECK: ret
f3(double x)47*f4a2713aSLionel Sambuc int f3(double x) {
48*f4a2713aSLionel Sambuc   int e;
49*f4a2713aSLionel Sambuc   __builtin_frexp(x, &e);
50*f4a2713aSLionel Sambuc   __builtin_frexpf(x, &e);
51*f4a2713aSLionel Sambuc   __builtin_frexpl(x, &e);
52*f4a2713aSLionel Sambuc   __builtin_modf(x, &e);
53*f4a2713aSLionel Sambuc   __builtin_modff(x, &e);
54*f4a2713aSLionel Sambuc   __builtin_modfl(x, &e);
55*f4a2713aSLionel Sambuc   __builtin_remquo(x, x, &e);
56*f4a2713aSLionel Sambuc   __builtin_remquof(x, x, &e);
57*f4a2713aSLionel Sambuc   __builtin_remquol(x, x, &e);
58*f4a2713aSLionel Sambuc   return e;
59*f4a2713aSLionel Sambuc }
60*f4a2713aSLionel Sambuc 
61*f4a2713aSLionel Sambuc // CHECK: attributes [[NUW]] = { nounwind{{.*}} }
62