This is an archive of the discontinued LLVM Phabricator instance.

[flang] Order Symbols by source provenance
ClosedPublic

Authored by klausler on Mar 16 2021, 2:37 PM.

Details

Summary

In parser::AllCookedSources, implement a map from CharBlocks to
the CookedSource instances that they cover. This permits a fast
Find() operation based on std::map::equal_range to map a CharBlock
to its enclosing CookedSource instance.

Add a creation order number to each CookedSource. This allows
AllCookedSources to provide a Precedes(x,y) predicate that is a
true source stream ordering between two CharBlocks -- x is less
than y if it is in an earlier CookedSource, or in the same
CookedSource at an earlier position.

Add a reference to the singleton SemanticsContext to each Scope.

All of this allows operator< to be implemented on Symbols by
means of a true source ordering. From a Symbol, we get to
its Scope, then to the SemanticsContext, and then use its
AllCookedSources reference to call Precedes().

Diff Detail

Event Timeline

klausler created this revision.Mar 16 2021, 2:37 PM
klausler requested review of this revision.Mar 16 2021, 2:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2021, 2:37 PM
PeteSteinfeld accepted this revision.Mar 16 2021, 3:02 PM

All builds, tests, and looks good.

This revision is now accepted and ready to land.Mar 16 2021, 3:02 PM
This revision was landed with ongoing or failed builds.Mar 16 2021, 3:25 PM
This revision was automatically updated to reflect the committed changes.

Hi @klausler , looks like this patch is causing failures in one of our public builders:

******************** TEST 'Flang :: Semantics/resolve102.f90' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/llvm-project/flang/test/Semantics/test_errors.sh /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/llvm-project/flang/test/Semantics/resolve102.f90 /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/tools/flang/test/Semantics/Output/resolve102.f90.tmp /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/bin/f18 -intrinsic-module-directory /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/include/flang
--
Exit Code: 1
Command Output (stdout):
--
/home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/bin/f18 -intrinsic-module-directory /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/include/flang -fsyntax-only /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/llvm-project/flang/test/Semantics/resolve102.f90
expect at 84: 'p2' must be an abstract interface or a procedure with an explicit interface
--
Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/llvm-project/flang/test/Semantics/test_errors.sh /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/llvm-project/flang/test/Semantics/resolve102.f90 /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/tools/flang/test/Semantics/Output/resolve102.f90.tmp /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/bin/f18 -intrinsic-module-directory /home/flang/flang-aarch64-ubuntu-clang/flang-aarch64-ubuntu-clang/build/include/flang
test_errors.sh: FAIL
--
********************

You can reproduce this with clang (I used clang-10). Also, use libc++ rather than libstdc++ (`-DLLVM_ENABLE_LIBCXX=On'). That's what's unique about this particular builder.

Could you take a look? I couldn't find a fix.

Hi @klausler , looks like this patch is causing failures in one of our public builders:

A fix is coming in a few minutes.