Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
flang/docs/FlangDriver.md
Show First 20 Lines • Show All 540 Lines • ▼ Show 20 Lines | |||||
be Polly, e.g., using `-DLLVM_POLLY_LINK_INTO_TOOLS=ON` would link Polly passes | be Polly, e.g., using `-DLLVM_POLLY_LINK_INTO_TOOLS=ON` would link Polly passes | ||||
into `flang-new` as built-in middle-end passes. | into `flang-new` as built-in middle-end passes. | ||||
See the | See the | ||||
[`WritingAnLLVMNewPMPass`](https://llvm.org/docs/WritingAnLLVMNewPMPass.html#id9) | [`WritingAnLLVMNewPMPass`](https://llvm.org/docs/WritingAnLLVMNewPMPass.html#id9) | ||||
documentation for more details. | documentation for more details. | ||||
## Ofast and Fast Math | ## Ofast and Fast Math | ||||
`-Ofast` in Flang means `-O3 -ffast-math`. `-fstack-arrays` will be added to | `-Ofast` in Flang means `-O3 -ffast-math -fstack-arrays`. | ||||
`-Ofast` in the future (https://github.com/llvm/llvm-project/issues/59231). | |||||
`-ffast-math` means the following: | `-ffast-math` means the following: | ||||
- `-fno-honor-infinities` | - `-fno-honor-infinities` | ||||
- `-fno-honor-nans` | - `-fno-honor-nans` | ||||
- `-fassociative-math` | - `-fassociative-math` | ||||
- `-freciprocal-math` | - `-freciprocal-math` | ||||
- `-fapprox-func` | - `-fapprox-func` | ||||
- `-fno-signed-zeros` | - `-fno-signed-zeros` | ||||
- `-ffp-contract=fast` | - `-ffp-contract=fast` | ||||
These correspond to LLVM IR Fast Math attributes: | These correspond to LLVM IR Fast Math attributes: | ||||
https://llvm.org/docs/LangRef.html#fast-math-flags | https://llvm.org/docs/LangRef.html#fast-math-flags | ||||
When `-ffast-math` is specified, any linker steps generated by the compiler | When `-ffast-math` is specified, any linker steps generated by the compiler | ||||
driver will also link to `crtfastmath.o`, which adds a static constructor | driver will also link to `crtfastmath.o`, which adds a static constructor | ||||
that sets the FTZ/DAZ bits in MXCSR, affecting not only the current only the | that sets the FTZ/DAZ bits in MXCSR, affecting not only the current only the | ||||
current compilation unit but all static and shared libraries included in the | current compilation unit but all static and shared libraries included in the | ||||
program. Setting these bits causes denormal floating point numbers to be flushed | program. Setting these bits causes denormal floating point numbers to be flushed | ||||
to zero. | to zero. | ||||
### Comparison with GCC/GFortran | ### Comparison with GCC/GFortran | ||||
GCC/GFortran translate `-Ofast` to | GCC/GFortran translate `-Ofast` to | ||||
`-O3 -ffast-math -fstack-arrays -fno-semantic-interposition`. `-fstack-arrays` | `-O3 -ffast-math -fstack-arrays -fno-semantic-interposition`. | ||||
is TODO for Flang. | |||||
`-fno-semantic-interposition` is not used because clang does not enable this as | `-fno-semantic-interposition` is not used because clang does not enable this as | ||||
awarzynski: [nit] "Clang" is a sub-project. It's not clear what "clang" would be - also a sub-project or… | |||||
part of `-Ofast` as the default behaviour is similar. | part of `-Ofast` as the default behaviour is similar. | ||||
GCC/GFortran has a wider definition of `-ffast-math`: also including | GCC/GFortran has a wider definition of `-ffast-math`: also including | ||||
`-fno-trapping-math`, `-fno-rounding-math`, and `-fsignaling-nans`; these | `-fno-trapping-math`, `-fno-rounding-math`, and `-fsignaling-nans`; these | ||||
aren't included in Flang because Flang currently has no support for strict | aren't included in Flang because Flang currently has no support for strict | ||||
floating point and so always acts as though these flags were specified. | floating point and so always acts as though these flags were specified. | ||||
GCC/GFortran will also set flush-to-zero mode: linking `crtfastmath.o`, the same | GCC/GFortran will also set flush-to-zero mode: linking `crtfastmath.o`, the same | ||||
Show All 16 Lines |
[nit] "Clang" is a sub-project. It's not clear what "clang" would be - also a sub-project or the binary?