diff options
author | IƱaki Amatria Barral <140811900+inaki-amatria@users.noreply.github.com> | 2025-03-05 08:27:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-05 08:27:17 +0100 |
commit | 6eefadd8efc0584211cb5283e0acc00a45588242 (patch) | |
tree | ba151bf15c78498f66d85453416dc2aeba5a2fcb /flang/lib/Semantics/mod-file.cpp | |
parent | 107fe0ec6cb36dca6bfafbfdf2996ce38d84e5bd (diff) | |
download | llvm-6eefadd8efc0584211cb5283e0acc00a45588242.zip llvm-6eefadd8efc0584211cb5283e0acc00a45588242.tar.gz llvm-6eefadd8efc0584211cb5283e0acc00a45588242.tar.bz2 |
[flang][Semantics] Ensure deterministic mod file output (#129669)
This PR is a follow-up to #128655.
It adds another test to ensure deterministic ordering in `.mod` files
and includes related changes to prevent non-deterministic ordering
caused by iterating over a set ordered by heap pointers. This issue is
particularly noticeable when using Flang as a library and compiling the
same files multiple times.
The reduced test case is as minimal as possible. We were unable to
reproduce the issue with a smaller set of files.
Diffstat (limited to 'flang/lib/Semantics/mod-file.cpp')
-rw-r--r-- | flang/lib/Semantics/mod-file.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp index 1dfd9c3..ac17697 100644 --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -47,7 +47,7 @@ struct ModHeader { static std::optional<SourceName> GetSubmoduleParent(const parser::Program &); static void CollectSymbols( - const Scope &, SymbolVector &, SymbolVector &, UnorderedSymbolSet &); + const Scope &, SymbolVector &, SymbolVector &, SourceOrderedSymbolSet &); static void PutPassName(llvm::raw_ostream &, const std::optional<SourceName> &); static void PutInit(llvm::raw_ostream &, const Symbol &, const MaybeExpr &, const parser::Expr *); @@ -363,7 +363,7 @@ void ModFileWriter::PutSymbols( auto &renamings{context_.moduleFileOutputRenamings()}; auto previousRenamings{std::move(renamings)}; PrepareRenamings(scope); - UnorderedSymbolSet modules; + SourceOrderedSymbolSet modules; CollectSymbols(scope, sorted, uses, modules); // Write module files for dependencies first so that their // hashes are known. @@ -839,7 +839,7 @@ void ModFileWriter::PutUseExtraAttr( // Collect the symbols of this scope sorted by their original order, not name. // Generics and namelists are exceptions: they are sorted after other symbols. void CollectSymbols(const Scope &scope, SymbolVector &sorted, - SymbolVector &uses, UnorderedSymbolSet &modules) { + SymbolVector &uses, SourceOrderedSymbolSet &modules) { SymbolVector namelist, generics; auto symbols{scope.GetSymbols()}; std::size_t commonSize{scope.commonBlocks().size()}; |