[flang-commits] [flang] f80866b - [flang] Make -fget-symbols-sources output deterministic
peter klausler via flang-commits
flang-commits at lists.llvm.org
Wed Sep 2 09:32:50 PDT 2020
Author: peter klausler
Date: 2020-09-02T09:32:26-07:00
New Revision: f80866bd4a2a4e8b650aef1f9a88870dd336e20f
URL: https://github.com/llvm/llvm-project/commit/f80866bd4a2a4e8b650aef1f9a88870dd336e20f
DIFF: https://github.com/llvm/llvm-project/commit/f80866bd4a2a4e8b650aef1f9a88870dd336e20f.diff
LOG: [flang] Make -fget-symbols-sources output deterministic
The DumpSymbolsSources() routine ordered its output by the addresses
of the names of the symbols, and was susceptible to variation across
environments. Fixed by using a multimap using the values of the names.
Differential Revision: https://reviews.llvm.org/D87035
Added:
Modified:
flang/lib/Semantics/semantics.cpp
flang/test/Semantics/getsymbols01.f90
flang/test/Semantics/getsymbols02.f90
flang/test/Semantics/getsymbols03-a.f90
flang/test/Semantics/getsymbols04.f90
flang/test/Semantics/getsymbols05.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/semantics.cpp b/flang/lib/Semantics/semantics.cpp
index 24d0baa9c2ae..af5b120d9393 100644
--- a/flang/lib/Semantics/semantics.cpp
+++ b/flang/lib/Semantics/semantics.cpp
@@ -45,17 +45,17 @@
namespace Fortran::semantics {
-using NameToSymbolMap = std::map<const char *, SymbolRef>;
+using NameToSymbolMap = std::multimap<parser::CharBlock, SymbolRef>;
static void DoDumpSymbols(llvm::raw_ostream &, const Scope &, int indent = 0);
static void PutIndent(llvm::raw_ostream &, int indent);
static void GetSymbolNames(const Scope &scope, NameToSymbolMap &symbols) {
// Finds all symbol names in the scope without collecting duplicates.
for (const auto &pair : scope) {
- symbols.emplace(pair.second->name().begin(), *pair.second);
+ symbols.emplace(pair.second->name(), *pair.second);
}
for (const auto &pair : scope.commonBlocks()) {
- symbols.emplace(pair.second->name().begin(), *pair.second);
+ symbols.emplace(pair.second->name(), *pair.second);
}
for (const auto &child : scope.children()) {
GetSymbolNames(child, symbols);
diff --git a/flang/test/Semantics/getsymbols01.f90 b/flang/test/Semantics/getsymbols01.f90
index 8f50304825dc..bdb7bf053823 100644
--- a/flang/test/Semantics/getsymbols01.f90
+++ b/flang/test/Semantics/getsymbols01.f90
@@ -16,10 +16,10 @@ recursive pure function f() result(x)
end module
! RUN: %f18 -fget-symbols-sources -fparse-only %s 2>&1 | FileCheck %s
+! CHECK-COUNT-1:f:{{.*}}getsymbols01.f90, 12, 26-27
! CHECK-COUNT-1:mm1:{{.*}}getsymbols01.f90, 2, 8-11
! CHECK-COUNT-1:s:{{.*}}getsymbols01.f90, 5, 18-19
-! CHECK-COUNT-1:x:{{.*}}getsymbols01.f90, 5, 21-22
-! CHECK-COUNT-1:y:{{.*}}getsymbols01.f90, 5, 24-25
! CHECK-COUNT-1:ss:{{.*}}getsymbols01.f90, 9, 19-21
-! CHECK-COUNT-1:f:{{.*}}getsymbols01.f90, 12, 26-27
+! CHECK-COUNT-1:x:{{.*}}getsymbols01.f90, 5, 21-22
! CHECK-COUNT-1:x:{{.*}}getsymbols01.f90, 13, 24-25
+! CHECK-COUNT-1:y:{{.*}}getsymbols01.f90, 5, 24-25
diff --git a/flang/test/Semantics/getsymbols02.f90 b/flang/test/Semantics/getsymbols02.f90
index 4c8f0710eb23..1eed3e922e82 100644
--- a/flang/test/Semantics/getsymbols02.f90
+++ b/flang/test/Semantics/getsymbols02.f90
@@ -10,5 +10,5 @@ PROGRAM helloworld
! RUN: %f18 -fparse-only %S/Inputs/getsymbols02-a.f90
! RUN: %f18 -fparse-only %S/Inputs/getsymbols02-b.f90
! RUN: %f18 -fget-symbols-sources -fparse-only %s 2>&1 | FileCheck %s
-! CHECK: get5: mm2a
! CHECK: callget5: mm2b
+! CHECK: get5: mm2a
diff --git a/flang/test/Semantics/getsymbols03-a.f90 b/flang/test/Semantics/getsymbols03-a.f90
index c11aee03048c..980d6bc58c1a 100644
--- a/flang/test/Semantics/getsymbols03-a.f90
+++ b/flang/test/Semantics/getsymbols03-a.f90
@@ -8,7 +8,7 @@ program main
end program
! RUN: %f18 -fget-symbols-sources -fparse-only %s 2>&1 | FileCheck %s
-! CHECK:mm3:{{.*}}getsymbols03-b.f90, 1, 8-11
! CHECK:f:{{.*}}getsymbols03-b.f90, 2, 12-13
! CHECK:main:{{.*}}getsymbols03-a.f90, 4, 9-13
+! CHECK:mm3:{{.*}}getsymbols03-b.f90, 1, 8-11
! CHECK:x:{{.*}}getsymbols03-a.f90, 6, 13-14
diff --git a/flang/test/Semantics/getsymbols04.f90 b/flang/test/Semantics/getsymbols04.f90
index 4decfc78560a..fc9b177abd90 100644
--- a/flang/test/Semantics/getsymbols04.f90
+++ b/flang/test/Semantics/getsymbols04.f90
@@ -8,5 +8,5 @@ program main
! RUN: %f18 -fget-symbols-sources -fparse-only %s 2>&1 | FileCheck %s
! CHECK:x:{{.*}}getsymbols04.f90, 3, 14-15
-! CHECK:y:{{.*}}getsymbols04.f90, 4, 14-15
! CHECK:x:{{.*}}getsymbols04.f90, 5, 11-12
+! CHECK:y:{{.*}}getsymbols04.f90, 4, 14-15
diff --git a/flang/test/Semantics/getsymbols05.f90 b/flang/test/Semantics/getsymbols05.f90
index 30dcb2278e00..624f37a74b76 100644
--- a/flang/test/Semantics/getsymbols05.f90
+++ b/flang/test/Semantics/getsymbols05.f90
@@ -11,5 +11,5 @@ program main
! RUN: %f18 -fget-symbols-sources -fparse-only %s 2>&1 | FileCheck %s
! CHECK:x:{{.*}}getsymbols05.f90, 3, 14-15
-! CHECK:y:{{.*}}getsymbols05.f90, 4, 14-15
! CHECK:x:{{.*}}getsymbols05.f90, 6, 16-17
+! CHECK:y:{{.*}}getsymbols05.f90, 4, 14-15
More information about the flang-commits
mailing list