Hello everyone,
I’d like to add support for for optimisation flags in flang-new
in the near future (e.g. -O1
or -O3
). Below is a rough summary of the approach that I’d like to take. Please let me know whether this makes sense to you and meets your requirements.
- I would like to focus on LLVM’s middle-end and back-end optimisation first. I feel that we should wait a bit before discussing which MLIR/FIR optimisations to include.
- Similarly to Clang, I would like to re-use the definition of optimisation pipelines from LLVM (I’ve discussed them briefly here: https://discourse.llvm.org/t/optimisation-pipelines).
- In my initial implementation, I will skip LTO, sanitizers or anything that affects the meaning of these flags in Clang.
Essentially, the initial implementation will allow us to replace this:
flang-new -S -emit-llvm file.f90 -o - | clang -O3 -o file.o
with:
flang-new -c -O3 file.f90
The only real downside of this is that we will be enabling all LLVM optimisations that Clang does. I imagine that some of them might be irrelevant for Fortran (i.e. have been implemented with inputs from Clang in mind). But this will become more obvious once we have -O3
and can experiment.
Thanks for taking a look!
-Andrzej