[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / builtin-attributes.c
blobe5b0faccfd23f209d1486a7bf493687852693875
1 // REQUIRES: arm-registered-target
2 // RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s
4 int printf(const char *, ...);
5 void exit(int);
7 float frexpf(float, int*);
8 double frexp(double, int*);
9 long double frexpl(long double, int*);
11 // CHECK: declare i32 @printf(ptr noundef, ...)
12 void f0() {
13 printf("a\n");
16 // CHECK: call void @exit
17 // CHECK: unreachable
18 void f1() {
19 exit(1);
22 // CHECK: call ptr @strstr{{.*}} [[NUW:#[0-9]+]]
23 char* f2(char* a, char* b) {
24 return __builtin_strstr(a, b);
27 // frexp is NOT readnone. It writes to its pointer argument.
29 // CHECK: f3
30 // CHECK: call double @frexp(double noundef %
31 // CHECK-NOT: readnone
32 // CHECK: call float @frexpf(float noundef %
33 // CHECK-NOT: readnone
34 // CHECK: call double @frexpl(double noundef %
35 // CHECK-NOT: readnone
37 // Same thing for modf and friends.
39 // CHECK: call double @modf(double noundef %
40 // CHECK-NOT: readnone
41 // CHECK: call float @modff(float noundef %
42 // CHECK-NOT: readnone
43 // CHECK: call double @modfl(double noundef %
44 // CHECK-NOT: readnone
46 // CHECK: call double @remquo(double noundef %
47 // CHECK-NOT: readnone
48 // CHECK: call float @remquof(float noundef %
49 // CHECK-NOT: readnone
50 // CHECK: call double @remquol(double noundef %
51 // CHECK-NOT: readnone
52 // CHECK: ret
53 int f3(double x) {
54 int e;
55 frexp(x, &e);
56 frexpf(x, &e);
57 frexpl(x, &e);
58 __builtin_modf(x, &e);
59 __builtin_modff(x, &e);
60 __builtin_modfl(x, &e);
61 __builtin_remquo(x, x, &e);
62 __builtin_remquof(x, x, &e);
63 __builtin_remquol(x, x, &e);
64 return e;
67 // CHECK: attributes [[NUW]] = { nounwind{{.*}} }