Chandler Carruth | abf07a7 | 2012-01-02 14:19:45 +0000 | [diff] [blame] | 1 | // Test that the GCC fast-math floating point flags get lowered to the correct |
| 2 | // permutation of Clang frontend flags. This is non-trivial for a few reasons. |
| 3 | // First, the GCC flags have many different and surprising effects. Second, |
| 4 | // LLVM only supports three switches which is more coarse grained than GCC's |
| 5 | // support. |
| 6 | // |
NAKAMURA Takumi | ba82a61 | 2012-04-27 04:36:27 +0000 | [diff] [blame] | 7 | // Both of them use gcc driver for as. |
| 8 | // XFAIL: cygwin,mingw32 |
| 9 | // |
Chandler Carruth | abf07a7 | 2012-01-02 14:19:45 +0000 | [diff] [blame] | 10 | // RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \ |
| 11 | // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s |
| 12 | // CHECK-NO-INFS: "-cc1" |
| 13 | // CHECK-NO-INFS: "-menable-no-infs" |
| 14 | // |
| 15 | // RUN: %clang -### -fno-honor-nans -c %s 2>&1 \ |
| 16 | // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s |
| 17 | // CHECK-NO-NANS: "-cc1" |
| 18 | // CHECK-NO-NANS: "-menable-no-nans" |
| 19 | // |
| 20 | // RUN: %clang -### -fmath-errno -c %s 2>&1 \ |
| 21 | // RUN: | FileCheck --check-prefix=CHECK-MATH-ERRNO %s |
| 22 | // CHECK-MATH-ERRNO: "-cc1" |
| 23 | // CHECK-MATH-ERRNO: "-fmath-errno" |
| 24 | // |
Chandler Carruth | 4f50c50 | 2012-04-26 02:10:51 +0000 | [diff] [blame] | 25 | // RUN: %clang -### -fmath-errno -fno-math-errno -c %s 2>&1 \ |
| 26 | // RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s |
| 27 | // RUN: %clang -### -target i686-apple-darwin -c %s 2>&1 \ |
| 28 | // RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s |
Benjamin Kramer | 769aa2d | 2012-05-02 14:55:48 +0000 | [diff] [blame] | 29 | // RUN: %clang -### -target x86_64-unknown-freebsd -c %s 2>&1 \ |
| 30 | // RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s |
| 31 | // RUN: %clang -### -target x86_64-unknown-netbsd -c %s 2>&1 \ |
| 32 | // RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s |
| 33 | // RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \ |
| 34 | // RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s |
| 35 | // RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \ |
| 36 | // RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s |
Chandler Carruth | 4f50c50 | 2012-04-26 02:10:51 +0000 | [diff] [blame] | 37 | // CHECK-NO-MATH-ERRNO: "-cc1" |
| 38 | // CHECK-NO-MATH-ERRNO-NOT: "-fmath-errno" |
| 39 | // |
| 40 | // RUN: %clang -### -fno-math-errno -fassociative-math -freciprocal-math \ |
| 41 | // RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \ |
Chandler Carruth | abf07a7 | 2012-01-02 14:19:45 +0000 | [diff] [blame] | 42 | // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s |
| 43 | // CHECK-UNSAFE-MATH: "-cc1" |
| 44 | // CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math" |
| 45 | // |
| 46 | // Check that various umbrella flags also enable these frontend options. |
| 47 | // RUN: %clang -### -ffast-math -c %s 2>&1 \ |
| 48 | // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s |
| 49 | // RUN: %clang -### -ffast-math -c %s 2>&1 \ |
| 50 | // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s |
| 51 | // RUN: %clang -### -ffast-math -c %s 2>&1 \ |
| 52 | // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s |
| 53 | // RUN: %clang -### -ffinite-math-only -c %s 2>&1 \ |
| 54 | // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s |
| 55 | // RUN: %clang -### -ffinite-math-only -c %s 2>&1 \ |
| 56 | // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s |
Chandler Carruth | 4f50c50 | 2012-04-26 02:10:51 +0000 | [diff] [blame] | 57 | // RUN: %clang -### -funsafe-math-optimizations -fno-math-errno -c %s 2>&1 \ |
Chandler Carruth | abf07a7 | 2012-01-02 14:19:45 +0000 | [diff] [blame] | 58 | // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s |
| 59 | // |
| 60 | // One umbrella flag is *really* weird and also changes the semantics of the |
| 61 | // program by adding a special preprocessor macro. Check that the frontend flag |
| 62 | // modeling this semantic change is provided. Also check that the semantic |
| 63 | // impact remains even if every optimization is disabled. |
| 64 | // RUN: %clang -### -ffast-math -c %s 2>&1 \ |
| 65 | // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s |
| 66 | // RUN: %clang -### -ffast-math -fno-finite-math-only \ |
| 67 | // RUN: -fno-unsafe-math-optimizations -fmath-errno -c %s 2>&1 \ |
| 68 | // RUN: | FileCheck --check-prefix=CHECK-FAST-MATH %s |
| 69 | // CHECK-FAST-MATH: "-cc1" |
| 70 | // CHECK-FAST-MATH: "-ffast-math" |
| 71 | // |
| 72 | // Check various means of disabling these flags, including disabling them after |
| 73 | // they've been enabled via an umbrella flag. |
| 74 | // RUN: %clang -### -fno-honor-infinities -fhonor-infinities -c %s 2>&1 \ |
| 75 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s |
| 76 | // RUN: %clang -### -ffinite-math-only -fhonor-infinities -c %s 2>&1 \ |
| 77 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s |
| 78 | // RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \ |
| 79 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s |
| 80 | // RUN: %clang -### -ffast-math -fhonor-infinities -c %s 2>&1 \ |
| 81 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s |
| 82 | // RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ |
| 83 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-INFS %s |
| 84 | // CHECK-NO-NO-INFS: "-cc1" |
| 85 | // CHECK-NO-NO-INFS-NOT: "-menable-no-infs" |
| 86 | // CHECK-NO-NO-INFS: "-o" |
| 87 | // |
| 88 | // RUN: %clang -### -fno-honor-nans -fhonor-nans -c %s 2>&1 \ |
| 89 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s |
| 90 | // RUN: %clang -### -ffinite-math-only -fhonor-nans -c %s 2>&1 \ |
| 91 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s |
| 92 | // RUN: %clang -### -ffinite-math-only -fno-finite-math-only -c %s 2>&1 \ |
| 93 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s |
| 94 | // RUN: %clang -### -ffast-math -fhonor-nans -c %s 2>&1 \ |
| 95 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s |
| 96 | // RUN: %clang -### -ffast-math -fno-finite-math-only -c %s 2>&1 \ |
| 97 | // RUN: | FileCheck --check-prefix=CHECK-NO-NO-NANS %s |
| 98 | // CHECK-NO-NO-NANS: "-cc1" |
| 99 | // CHECK-NO-NO-NANS-NOT: "-menable-no-nans" |
| 100 | // CHECK-NO-NO-NANS: "-o" |
| 101 | // |
| 102 | // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ |
| 103 | // RUN: -fno-trapping-math -fno-associative-math -c %s 2>&1 \ |
| 104 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 105 | // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ |
| 106 | // RUN: -fno-trapping-math -fno-reciprocal-math -c %s 2>&1 \ |
| 107 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 108 | // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ |
| 109 | // RUN: -fno-trapping-math -fsigned-zeros -c %s 2>&1 \ |
| 110 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 111 | // RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ |
| 112 | // RUN: -fno-trapping-math -ftrapping-math -c %s 2>&1 \ |
| 113 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 114 | // RUN: %clang -### -funsafe-math-optimizations -fno-associative-math -c %s \ |
| 115 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 116 | // RUN: %clang -### -funsafe-math-optimizations -fno-reciprocal-math -c %s \ |
| 117 | // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 118 | // RUN: %clang -### -funsafe-math-optimizations -fsigned-zeros -c %s 2>&1 \ |
| 119 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 120 | // RUN: %clang -### -funsafe-math-optimizations -ftrapping-math -c %s 2>&1 \ |
| 121 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 122 | // RUN: %clang -### -funsafe-math-optimizations -fno-unsafe-math-optimizations \ |
| 123 | // RUN: -c %s 2>&1 \ |
| 124 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 125 | // RUN: %clang -### -ffast-math -fno-associative-math -c %s 2>&1 \ |
| 126 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 127 | // RUN: %clang -### -ffast-math -fno-reciprocal-math -c %s 2>&1 \ |
| 128 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 129 | // RUN: %clang -### -ffast-math -fsigned-zeros -c %s 2>&1 \ |
| 130 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 131 | // RUN: %clang -### -ffast-math -ftrapping-math -c %s 2>&1 \ |
| 132 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 133 | // RUN: %clang -### -ffast-math -fno-unsafe-math-optimizations -c %s 2>&1 \ |
| 134 | // RUN: | FileCheck --check-prefix=CHECK-NO-UNSAFE-MATH %s |
| 135 | // CHECK-NO-UNSAFE-MATH: "-cc1" |
| 136 | // CHECK-NO-UNSAFE-MATH-NOT: "-menable-unsafe-fp-math" |
| 137 | // CHECK-NO-UNSAFE-MATH: "-o" |