Skip to content

Conversation

@nanavati
Copy link
Collaborator

There are two headline improvements here:

  1. Allowing the %s digraph in dump file names to get the compiler pass included in the output file name.
  2. Allowing -dall to take a file argument as well.

To get -dall=file (with no digraphs) to work, I had the compiler start appending to dump files after the first write.

That turned out to be tricky because of how we were using dump flags in the testsuite. In one case I redirected dumps with %m so that tests didn't see the dumps of multiple modules mixed together. The other issue was how our double-parsing (once for dependencies and once for compilation) interacted with the dump code. I decided the least-surprising behavior that worked with our tests was to have the parsing stages be an exception to the append after first write rule (when they are being explicitly dumped).

- Include headers and footers when dumping to files, just like when dumping to stdout
- Only overwrite a file the first time we dump to it in a run. Subsequent dumps append to the existing file.
  This means -dall=foo.txt collects everything instead of just the last dump.
so have them overwrite files to prevent double-dumps.
Some splitIf testcases compile a submodule. Previously, the submodule splitIf
dump was overwritten so the testing code only saw the top-level dump.
That changed when we started accumulating dumps, so we redirect each module's
dump to a different file with %m.
Copy link
Collaborator

@quark17 quark17 left a comment

Choose a reason for hiding this comment

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

Awesome. Just a couple comments.

"You may substitute -KILL for -d" ++
" to stop compilation after the named pass",
"",
"-dall supports filename arguments including digraphs",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since -dall was removed from externalFlags below, that not only removed the parsing, but also removed the display of the description in the help message. This line below the digraphs is now the only place that mentions -dall to the user at all. So I think it needs to say more than just that -dall supports arguments, but to also say what -dall is even is. Maybe something like, "-dall enables dumping after every pass. -dall also supports an optional filename including digraphs. If a filename is given for an individual pass, it takes precedence over the -dall filename."

then appendFileCatch
else writeFileCatch
-- Add a header and footer to -dall dumps in case they end up in the same file.
let a' = if hasDumpStrict flags d then a else header ++ a ++ footer
Copy link
Collaborator

Choose a reason for hiding this comment

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

One, you might want to replace hasDumpStrict flags d with isSpecificDump.

But, two, I think we should always write the header and footer. It's possible for specific dumps to write to the same file -- the current behavior means that they'll be appended without any header/footer delimiters. (We might even consider including the names in the headers.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, I see that the testsuite uses -dparsed in bsc.syntax/bh_parse_pretty/, for example, and expects to be able to run BSC directly on the file. So if we added headers and footers, then the testsuite would need to be able to remove them. (Is that so bad?)

let isSpecificDump = hasDumpStrict flags d
-- Don't allow explicit parsed dumps to accumulate to avoid a double dump
-- from the double parse (first for dependencies and then for code).
let doubleParsedPasses = [DFvpp, DFbsvlex, DFparsed]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not wholly satisfied with the handling of parser passes. I guess it's OK for now. If someone didn't provide enough digraphs, multiple passes can be written to the same file; except that the parser passes would overwrite the file. Would it be better to give separate names to the dependency parser stages (like how you did for wrapper stages)? Or just live with multiples in the file, if you ran BSC with the -u flag.

Was this added because of uses in the testsuite?

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