[flang-dev] Difficulties with In-Tree Build of Flang
Kiran Chandramohan via flang-dev
flang-dev at lists.llvm.org
Fri Jun 26 00:09:23 PDT 2020
Hi Justin,
I think basically you have to walk the parse tree with a mutator class. The mutator class needs to have Pre and Post functions defined. The Pre/Post functions can be specialised for the nodes that you are interested in. And these functions get called while visiting those nodes. You can perform the transformations in these Pre/Post functions.
-> OpenMP loop rewriting might be a good example to consult.
https://github.com/llvm/llvm-project/blob/master/flang/lib/Semantics/canonicalize-omp.cpp
In the parse-tree representation (include/flang/Parser/parse-tree.h), the OpenMPLoopConstruct is a tuple of OmpBeginLoopDirective, DoConstruct and OmpEndLoopDirective. The DoConstruct and OmpEndLoopDirective fields are not filled during parsing. The pass in the above file fills these fields. The pass does the following rewriting transformation (copied from the source file).
// Original:
// ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
// OmpBeginLoopDirective
// ExecutableConstruct -> DoConstruct
// ExecutableConstruct -> OmpEndLoopDirective (if available)
// After rewriting:
// ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
// OmpBeginLoopDirective
// DoConstruct
// OmpEndLoopDirective (if available)
-> Another example would be lib/Semantics/rewrite-parse-tree.cpp. The pass here corrects some ambiguous parsing performed by the Flang parser.
Thanks,
Kiran
________________________________
From: flang-dev <flang-dev-bounces at lists.llvm.org> on behalf of Steve Scalpone via flang-dev <flang-dev at lists.llvm.org>
Sent: 25 June 2020 17:01
To: Szaday, Justin Josef <szaday2 at illinois.edu>; Andrzej Warzynski <Andrzej.Warzynski at arm.com>; flang-dev at lists.llvm.org <flang-dev at lists.llvm.org>
Subject: Re: [flang-dev] Difficulties with In-Tree Build of Flang
Hi Justin,
You can use the flang front end (f18) to do source-to-source transformations. Check out the -funparse option. Sorry, I’m not familiar with the APIs to rewrite the AST. Maybe someone else can answer that.
- Steve
From: flang-dev <flang-dev-bounces at lists.llvm.org> on behalf of flang-dev <flang-dev at lists.llvm.org>
Reply-To: "Szaday, Justin Josef" <szaday2 at illinois.edu>
Date: Thursday, June 25, 2020 at 8:45 AM
To: Andrzej Warzynski <andrzej.warzynski at arm.com>, flang-dev <flang-dev at lists.llvm.org>
Subject: Re: [flang-dev] Difficulties with In-Tree Build of Flang
External email: Use caution opening links or attachments
Thanks for the replies, Andrzej and Steve,
This placeholder driver may be sufficient for my purposes for now. My goal is to use Flang to implement some high-level transformations for the Adaptive MPI project, those being converting: global variables into !omp threadprivate() variables, and LUNs with hardcoded values into virtualized ones. Does Flang provide a mechanism for manipulating the AST directly? If not, are there any code rewriting mechanisms (a la Clang) or should these manipulations be performed at the FIR-level? Any guidance on this matter would be appreciated, I scanned through the documentation and did not immediately see any discussion of code manipulation.
Thanks,
Justin Szaday
PhD Student in Computer Science
University of Illinois at Urbana-Champaign
From: Andrzej Warzynski via flang-dev<mailto:flang-dev at lists.llvm.org>
Sent: Thursday, June 25, 2020 7:45 AM
To: flang-dev at lists.llvm.org<mailto:flang-dev at lists.llvm.org>
Subject: Re: [flang-dev] Difficulties with In-Tree Build of Flang
Hello Justin,
The new driver will take a while to implement. Internally we are aiming
for LLVM 12, but that depends on many factors. First we'd like to
refactor some bits of Clang's driver so that it is easy to re-use them
in Flang.
- Andrzej
On 24/06/2020 22:50, Steve Scalpone via flang-dev wrote:
> Hi Justin,
>
> The flang script reads from standard input if a source file is not
> provided on the command line. It appears to hang, but it’s really just
> waiting for input.
>
> Flang isn’t hooked up to a code generator yet, so instead, by default,
> flang generates another Fortran source file and tries to compile that
> file with a different compiler. The default is pgf90, but you can set
> the environment variable F18_FC to be a different compiler, like gfortran.
>
> The flang script that you are running is just a throwaway driver until
> the real driver is ready. That work is under development right now, but
> I don’t know when it will be ready. Until then, we have this quirky
> script that lets us test flang semantics.
>
> - Steve
>
> *From: *flang-dev <flang-dev-bounces at lists.llvm.org> on behalf of
> flang-dev <flang-dev at lists.llvm.org>
> *Reply-To: *"Szaday, Justin Josef" <szaday2 at illinois.edu>
> *Date: *Wednesday, June 24, 2020 at 2:02 PM
> *To: *flang-dev <flang-dev at lists.llvm.org>
> *Subject: *[flang-dev] Difficulties with In-Tree Build of Flang
>
> *External email: Use caution opening links or attachments*
>
> Hello all,
>
> I am having a very difficult time getting in-tree builds of Flang
> working. My build commands are as follows:
>
> cmake -G Ninja -DLLVM_ENABLE_PROJECTS="flang"
> -DCMAKE_INSTALL_PREFIX=$(pwd) -DCMAKE_BUILD_TYPE=MinSizeRel ../llvm
>
> cmake --build . --target check-flang
>
> cmake --build . --target install
>
> The build itself completes successfully, and all the Flang tests pass
> when using “check-flang”; however, “flang -v” and “flang -h” hang (it
> does not produce any output and has to be killed) and, when trying to
> compile a program, I get the error message “execvp(pgf90) failed: No
> such file or directory” (which fails even if I set F18_FC to gfortran or
> flang). I have tried building it on a few machines to no avail. I have
> tested both the Debug and MinSizeRel build types, used both Ninja and
> Unix Makefiles to build it, and tested a few different versions of
> GCC/G++, ultimately settling on v9.1.0. I am building from master of the
> llvm-project GitHub repository.
>
> Any insights here would be appreciated, I am at a loss about what else
> to try here. Any other debugging suggestions or usage tips would be
> appreciated as well.
>
> Thanks,
>
> Justin
>
>
> _______________________________________________
> flang-dev mailing list
> flang-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev
>
_______________________________________________
flang-dev mailing list
flang-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20200626/75ad8b01/attachment.html>
More information about the flang-dev
mailing list