<div dir="ltr"><div dir="ltr">On Mon, Feb 25, 2019 at 5:46 PM Chandler Carruth via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Mon, Feb 25, 2019 at 10:06 AM Stephen Scalpone via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381WordSection1">
<p class="MsoNormal"><span style="color:black">* The current f18 code will be committed to the new LLVM subproject. </span><span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space" style="color:black"> </span><span style="color:black">The f18 code is a set of libraries that implements the Fortran compiler.</span></p></div></div></blockquote><div><br></div><div>Awesome. This is an important aspect of the design of LLVM projects IMO -> they build their functionality primarily as re-usable libraries, and then expose that in useful command line utilities.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381WordSection1"><p class="MsoNormal"><span style="color:black">The f18 compiler source code complies with most of LLVM's coding guidelines; however, the code uses several C++17 features.  We've documented our use of C++17 here:</span><br></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> <u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> <span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span><a href="https://github.com/flang-compiler/f18/blob/master/documentation/C++17.md" target="_blank"><span style="color:rgb(149,79,114)">https://github.com/flang-compiler/f18/blob/master/documentation/C++17.md</span></a><u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> <u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">In particular, the parse tree and the lowered forms of expressions and variables are defined in terms of C++17<span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span>std::variant. Most of the compiler uses C++17<span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span>std::visit
 to walk these data structures.<u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> <u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">It’s possible to reimplement the most important functionality of<span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span>std:variant<span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span>as a subset class, say<span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span>llvm:variant;
 however, variant gets its power from the C++17 features generic lambdas and parameter pack expansion on “using”. <span class="m_3845191697310253353m_-5237989680949029285m_-1528165471991243786m_-2913213418944299931gmail-m_-2678614120066624263gmail-m_-1195941680496066381apple-converted-space"> </span>Without these C++17 features, use of variant would be impractical.<u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> <u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">Our thinking when we started was that llvm would adopt C++17 before mid-2020, which lines up with our projected completion date. If we were to adopt C++11 or C++14, we would likely create substitutes for these classes, certainly at
 a cost of calendar time and perhaps type safety and notational convenience.  One of our principles is to take advantage of the standard library as much as possible, so casual readers will better understand our code and so we avoid the time and bugs associated
 with writing class libraries.<u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> <u></u><u></u></span></p>
<p class="MsoNormal" style="font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">Our request would be to get a waiver for the C++11 requirement based on the fact that we're skating to where the puck will be.  In the meantime, because F18 only exists as a stand-alone program, early adopters would still have a useful
 parser and analyzer for Fortran.</span></p></div></div></blockquote><div><br></div><div>Hold on, either it is a collection of libraries or it is a stand-alone program. It can't really be both?</div><div><br></div><div>Generally, I think the idea that diverging from the rest of the project here is low-cost for a subproject isn't supported by experience with other projects.</div><div><br></div><div>Notably, it has a strong tendancy to create tension. You want some ADT or support library in LLVM to work well with your C++17 code. But it is C++11. Every time this has been done in the past, the result has been that generically useful tools and libraries get added to the subproject rather than to LLVM as a whole.</div></div></div></blockquote><div><br></div><div>If there are such features that ought to be added to the support libraries in LLVM for better C++17 support, then they can indeed be added, with an appropriate #ifdef on language version, no?</div><div><br></div><div>The primary reason that I think it makes sense to allow f18 to require C++17 is that this will be a _temporary_ divergence -- the rest of the LLVM project will certainly move to require C++17 as well at some point relatively soon. Any C++17-specific improvements made to llvm common libraries will be useful for the rest of LLVM too.</div><div><br></div><div>I don't know what the expected timeline of f18 completion is, nor would I like to predict excatly how long it'll be before LLVM might start requiring C++17, but it certainly seems possible that LLVM might be ready to require c++17 before f18 is even finished.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>So FWIW, I'd be really opposed to this. Instead, I think that F18 should have rich libraries, and develop them exactly the same way as the rest of LLVM.</div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div><div>We're getting close to switching to C++14, so maybe due to timing, you could merge F18 when that happens?</div><div><br></div><div>Ultimately, I think you either need to raise the LLVM base language version or lower the F18 one so that they match when merged IMO. Anything else I think will hamper integration with the larger project.</div></div></div></blockquote><div><br></div><div>Even if a decision is made to rewrite parts of the code in order to not rely on C++17 features, I don't think that the initial import of the project ought to be tied to that task being completed. More generally, I think the prerequisite to merging it should be having an agreed-upon target state and an understood path on how to reach that state, rather than the code actually being _in_ that state already. Merging sooner is generally better than waiting and merging later.</div></div></div>