[flang-dev] Flang Coding Style

Steve Scalpone via flang-dev flang-dev at lists.llvm.org
Fri Apr 2 08:40:56 PDT 2021


Hi Johannes,

I believe every file committed to flang runs through clang-format. There are three formats being used.  The front-end files use the llvm style with some modifications.  The files related to MLIR follow the MLIR style.  And the files closest to LLVM follow the LLVM style.  This all seems reasonable to me.

There was a huge file-renaming pass done over the code before the initial merge.  Do you have an example that doesn't follow the convention?

The compilation slowness may be related to heavy use of std::variant.  I'm not trying to be difficult here but perhaps you can bring up the compilation speed issue with cfe?  Michael Kruse measured the time required to compile flang with gcc, vc++, and clang; my recollection is that clang was slowest of the batch. 

 - Steve

On 4/1/21, 1:51 PM, "flang-dev on behalf of Johannes Doerfert via flang-dev" <flang-dev-bounces at lists.llvm.org on behalf of flang-dev at lists.llvm.org> wrote:

    External email: Use caution opening links or attachments

    I was struggling with myself because I don't want to derail the current
    progress,
    however, I figured it is still worth pointing this out (again), the
    earlier the better.

    ---

    I read over Flang patches regularly and I got more and more annoyed by
    the coding style. I don't
    know who designed it and why but it causes actual burden for people that
    otherwise work with the LLVM style.

    I am aware this was discussed before but I vaguely remember we wanted to
    get closer to LLVM style
    and I am worried that goal has been forgotten by now.

    My initial suggestion is to change the online style guide, highlighted
    with *ABC*.

      * Use /clang-format/ from llvm *trunk* on all C++ source and header
        files before every merge to master. All code layout should be
        determined by means of clang-format.
      * *Where LLVM’s C++ style guide
        <https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fllvm.org%2Fdocs%2FCodingStandards.html%23style-issues&data=04%7C01%7Csscalpone%40nvidia.com%7C07c2f559151e4a5efb2108d8f54ff435%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637529071045010597%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=8LdRWMwrS3gqSyGDqlGZM2ZvQbiD9Jpd6iCEDPave%2BY%3D&reserved=0> is clear
        on usage, follow it.*
      * *Otherwise,* where a clear precedent exists in the project, follow it.

    Filenames should follow the LLVM naming style.

    The "Overall design preferences" should be rewritten. The content is not
    only add odds with existing
    practices in LLVM (& MLIR, OpenACC, OpenMP, ...) but probably also one
    of the reasons we have to discuss
    Flang compile times regularly. I mean, I love really crafty C++
    meta-programming solutions as much as the next
    person but we should rethink the trade-off we are advocating for.

    Once we redefine the rules we can adopt the LLVM style piece by piece or
    in one big swoop. Either way, let's
    actually follow through on those discussions we had Feb 2020.

    ~ Johannes


    --
    ───────────────────
    ∽ Johannes (he/his)

    _______________________________________________
    flang-dev mailing list
    flang-dev at lists.llvm.org
    https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fflang-dev&data=04%7C01%7Csscalpone%40nvidia.com%7C07c2f559151e4a5efb2108d8f54ff435%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637529071045010597%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=L2mtxInFuEdlgJkLr51%2FtKNtXUwIAKHNr1L9R2yOv%2FI%3D&reserved=0



More information about the flang-dev mailing list