xref: /llvm-project/clang/test/CodeGen/func-attr.c (revision dd8181055494d8f973dfaaba282bb1ae6eab4d40)
1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math \
2 // RUN: -ffp-contract=fast -emit-llvm -o - %s | \
3 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-UNSAFE,FINITEONLY
4 
5 // RUN: %clang_cc1 -triple x86_64-linux-gnu -funsafe-math-optimizations \
6 // RUN: -ffp-contract=fast -emit-llvm -o - %s | \
7 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-UNSAFE,NOFINITEONLY
8 
9 // RUN: %clang_cc1 -triple x86_64-linux-gnu -funsafe-math-optimizations \
10 // RUN: -ffp-contract=on -emit-llvm -o - %s | \
11 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-NOUNSAFE,NOFINITEONLY
12 
13 // RUN: %clang_cc1 -triple x86_64-linux-gnu -funsafe-math-optimizations \
14 // RUN: -ffp-contract=off -emit-llvm -o - %s | \
15 // RUN: FileCheck %s --check-prefixes=CHECK,CHECK-NOUNSAFE,NOFINITEONLY
16 
foo(float a,float b)17 float foo(float a, float b) {
18   return a+b;
19 }
20 
21 // FINITEONLY:    define{{.*}} float @foo(float noundef nofpclass(nan inf) %{{.*}}, float noundef nofpclass(nan inf) %{{.*}}){{.*}} [[ATTRS:#[0-9]+]]
22 // NOFINITEONLY:    define{{.*}} float @foo(float noundef %{{.*}}, float noundef %{{.*}}){{.*}} [[ATTRS:#[0-9]+]]
23 
24 // CHECK:              attributes [[ATTRS]] = {
25 // CHECK-SAME:           "approx-func-fp-math"="true"
26 // CHECK-SAME:           "no-signed-zeros-fp-math"="true"
27 // CHECK-SAME:           "no-trapping-math"="true"
28 // CHECK-UNSAFE-SAME:    "unsafe-fp-math"="true"
29 // CHECK-NOUNSAFE-NOT:   "unsafe-fp-math"="true"
30 // CHECK-SAME:         }
31