Skip to content

Add PFT tests #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: jpr-mono-split
Choose a base branch
from
Open

Add PFT tests #6

wants to merge 24 commits into from

Conversation

jeanPerier
Copy link
Owner

  • f18 driver is slightly modified to dump the PFT.
  • I modified the dump a little so that it dumps the node and parents address,
    we can then capture with FileCheck regex to check the tree structure in a much easier and stronger
    way than checking the indentation.
    I think checking the address also gives us the guarantee that there was no weird copies made and that the node are indeed uniq.

I wrote a bunch of tests related to that, the high level structure is fully checked (fixed a bug on the way), I still lack some test for some action statements, I will finish this before moving this to the PR959
but I would rather have your opinion on the tests method now.

jeanPerier and others added 21 commits January 28, 2020 03:56
Note:
This commit does not reflect an actual work log, it is a feature based split of the
changes done in the FIR experimental branch. The related work log can be found in the commits between:
schweitzpgi@8c320e3
and:
schweitzpgi@9b9ea05
The ASTBuilder structure is a temporary data structure that
is meant to be built from the parse tree just before lowering to
FIR and that will be deleted just afterwards. It is not meant to perfrom
optimization analysis and transformations. It only provides temporary
information, such as label target information or parse tree parent nodes,
that is meant to be used to lower the parse tree structure into
FIR operations.
A pretty printer is available to visualize this data structure.

Note:
This commit does not reflect an actual work log, it is a feature based split of the
changes done in the FIR experimental branch. The related work log can be found in the
commits between:
864898c
and
137c23d
Review: flang-compiler#959
Fixes file names in LLVM copyright.
- change Evaluation ctor argument order to match member order
- db -> bd for BlockData argument name
- Use dump-parse-tree.h for the AST pretty printer.
Remove Fortran:: and Fortran::lower when not needed.
After discussions, it turns out this change is not needed.
This patch is a forward integration of an issue fix that will be
fixed in parallel in f18, remove when rebasing whith next f18
containing the fix.
- Add lit test to test:
  1. that the PFT tree structure is as expected
  2. that the PFT captures all intented nodes

- Fix:
  FunctionLike units were added in wrong lists after a module
  subprogram or an internal suprogram was visited by ASTBuilder.
Copy link

@schweitzpgi schweitzpgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. Nice work on these tests.

if (isConstruct() && evals) {
return evals;
}
llvm_unreachable("evaluation subs is inconsistent");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

if (eval.isConstruct()) {
annotateEvalListCFG(*eval.getConstructEvals(), &eval);
if (auto *subs{eval.getConstructEvals()}) {
annotateEvalListCFG(*subs, &eval);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this the bug? Don't all constructs have a body (with 0 or more evals)?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, there was one bug here that I did not mentioned in the commit, not sure if it came from the refactoring, the issue was that eval.isConstruct() and eval.isStmt() were not equivalent so eval.isConstruct() was not ensuring eval.getConstructEvals() was not null and that led to weird things, like visiting ConstructStmt as if they were constructs. The eval.isConstruct() is fixed, but it feels safer to test the pointer here as a user.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks for fixing the bug!

Fortran::lower::annotateControl(*ast);
Fortran::lower::dumpPFT(llvm::outs(), *ast);
} else {
std::cerr << "Pre FIR Tree is NULL.\n";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm::errs() vs. std::cerr?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, actually ~ so so, std::cerr is already used in this f18 file, I do not want to spearhead the change to llvm stream here (I actually tried to hide the llvm::outs() to avoid troubles here, but I then hit llvm runtime issues (I think the driver should initialized it or something) so I left it that way).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants