[flang-commits] [flang] 8676027 - [flang] Minor speed-up to module file parsing (#152178)

via flang-commits flang-commits at lists.llvm.org
Tue Aug 5 13:40:33 PDT 2025


Author: Peter Klausler
Date: 2025-08-05T13:40:30-07:00
New Revision: 867602742cf392849b5f1cfc9038ad679333fd59

URL: https://github.com/llvm/llvm-project/commit/867602742cf392849b5f1cfc9038ad679333fd59
DIFF: https://github.com/llvm/llvm-project/commit/867602742cf392849b5f1cfc9038ad679333fd59.diff

LOG: [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.

Added: 
    

Modified: 
    flang/lib/Parser/parsing.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/parsing.cpp b/flang/lib/Parser/parsing.cpp
index 93737d99567dd..ceea74766d7ea 100644
--- a/flang/lib/Parser/parsing.cpp
+++ b/flang/lib/Parser/parsing.cpp
@@ -285,6 +285,8 @@ void Parsing::Parse(llvm::raw_ostream &out) {
       .set_log(&log_);
   ParseState parseState{cooked()};
   parseState.set_inFixedForm(options_.isFixedForm).set_userState(&userState);
+  // Don't bother managing message buffers when parsing module files.
+  parseState.set_deferMessages(options_.isModuleFile);
   parseTree_ = program.Parse(parseState);
   CHECK(
       !parseState.anyErrorRecovery() || parseState.messages().AnyFatalError());


        


More information about the flang-commits mailing list