(Strawman) Costed plan for LLVM-ification of F18

Hi list

As discussed on previous threads, we need to propose a plan for making F18 more LLVM-like in style and use of LLVM APIs and facilities. David is working on getting the permissions to put this into a github project in LLVM so we can collaborate . In order to make progress ahead of that happening, I’d like to have a go on email.

For each area I would like to capture a list of work items we’ll commit to doing before merge to monorepo. I want us to be happy we can achieve these in a short time period so we can propose a new merging date. I’d also like to create a list of items we’ll commit to fixing after merging to the monorepo and a timeline for getting that done.

Note that I’ll only cover API and coding style work items in this thread. The other initiatives we can discuss in other threads. I’ll just say that we’ll propose cmake changes and porting test suite to lit in the pre-merge stuff and setting up build bots in the post-merge stuff.

When he has access, David can create two projects one for pre-merge and one for post-merge and we’ll put everything in there.

Please consider the below a strawman. All dates can change, all list items can change position, new ones can be added, items can be deleted, etc.

What do people think about these lists? Do we think those two dates are do-able?

Ta
Rich

Proposal:
We will make the following style changes before merging to the monorepo

F18 changes to make it more LLVM-like in code style

  1. Rationalise headers to put public headers in /include and not /lib
  2. Unify F18’s clang-format file to match LLVMs
  3. Rename all .cc files to .cpp
  4. Switch module names to starting with capital letters

Increase use of LLVM APIs and utilities in F18
a. Switch F18 custom File handling to LLVM’s File handling (helps with non-POSIX platform support)
b. Change uses of to LLVM’s streams
c. Migrate use of std::list to a suitable alternative in LLVM’s API
d. Use llvm_unreachable with an error message for unreachable cases
e. Use llvm::Error instead of error codes if and when error codes are used.

We would like to aim for a merge date of Monday 24th Feb to merge to the monorepo with all of the above changes committed to F18 master.

We then propose to make the following changes after merging to the monorepo.

F18 changes to make it more LLVM-like in code style
We will commit to a perform a one-off exercise where we automatically audit the code to find these instances and bring them in line.

  1. Eliminate braces from all single-line if statements
  2. Eliminate all uses of else-after-return
  3. Add doxygen infrastructure so we can generate docs

Increase use of LLVM APIs and utilities in F18
a. std::string → StringRef where appropriate
b. std::vector → llvm::SmallVector where appropriate
c. std::set → llvm::SmallSet/llvm::StringSet/llvm::DenseSet where appropriate
d. std::map → llvm::StringMap/llvm::DenseMap where appropriate
e. Audit functions in include/flang/common and port to LLVM equivalents (e.g. builtin_popcount)

Assuming we hit the above merge date, we think we can commit to making these changes before the LLVM11 branch is taken in June.

After that date, we will continue to make progress towards LLVM style and API usage by fixing things as we find them during development and enforce the new style through code review.

A few specific areas that have been mentioned before that we will tackle in this way are:

  • Add doxygen style comments and file comments
  • Find more expressive names for classes, files, etc.
  • Refactor code to use early exits