Skip to content

Commit 8676027

Browse files
authored
[flang] Minor speed-up to module file parsing (#152178)
Module files shouldn't ever produce parsing errors, and if they did in the case of a badly-generated module file, the compiler will notice and crash. So we can run the parser on module files with message deferral enabled, and that saves time that would otherwise be spent generating messages on failed parsing alternatives that are discarded anyway when backtracking. It's not a big savings (single digit percentage on overall compilation time for a big application with lots of modules), but worth doing.
1 parent fc9a080 commit 8676027

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

flang/lib/Parser/parsing.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ void Parsing::Parse(llvm::raw_ostream &out) {
285285
.set_log(&log_);
286286
ParseState parseState{cooked()};
287287
parseState.set_inFixedForm(options_.isFixedForm).set_userState(&userState);
288+
// Don't bother managing message buffers when parsing module files.
289+
parseState.set_deferMessages(options_.isModuleFile);
288290
parseTree_ = program.Parse(parseState);
289291
CHECK(
290292
!parseState.anyErrorRecovery() || parseState.messages().AnyFatalError());

0 commit comments

Comments
 (0)