Commit Graph
3306 Commits
Author SHA1 Message Date
c5fd8f42b8 ImplWitness (#4679)
* Change `InterfaceWitness` -> `ImplWitness`
* Include a `SpecificId` in the `ImplWitness`. This allows the
`InstBlock` it contains to have its own identity, allowing it to be
changed as the impl is processed. Evaluation only updates the specific.
* Create the `ImplWitness` at the start of the impl definition. In the
future, this will be populated with the values of non-function
associated constants. For now, it starts full of invalid instruction
ids.
* Implements the model suggested in #4672 .

Note that the non-SemIR testdata changes are to these file:
* `toolchain/check/testdata/impl/lookup/fail_todo_undefined_impl.carbon`
* `toolchain/check/testdata/struct/import.carbon`
* `toolchain/check/testdata/tuple/import.carbon`

The last two are due to an import of generics bug exposed by this PR,
which will be fixed in a follow-on.

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2025-01-02 23:03:11 +00:00
Richard Smith 4a7aefefaa Add support for operators on Core.IntLiteral. (#4716)
Fixes integer builtins to produce the correct values (and not
CHECK-fail) when used on integer literals. Also adds impls to the
prelude to use the new builtins to perform operations on integer
literals.

Perhaps most importantly, this allows directly initializing `i32` values
with negative numbers, as the negation operation on integer literals now
works.

For testing I've added tests for use of literals with one operator in
each class (addition, multiplication, ordering, bitwise, etc) for which
there are distinct rules or overflow behavior, rather than exhaustively
testing all the combinations. This is aimed at finding a good tradeoff
between maintainability of the tests and thorough test coverage.

Also fixes lowering of heterogeneous shifts and comparisons. These are
currently disabled when one of the operands is an integer literal, but
we may want to allow that when the integer literal operand has a known
constant value.
v0.0.0-0.nightly.2025.01.02 v0.0.0-0.nightly.2025.01.01
2024-12-31 06:36:43 +00:00
624950c62c Store hash in the probed_indices array in common/raw_hashtable.h to avoid its recomputation. (#4726)
Store hash in probed_indices array to avoid its recomputation.

Benchmarks on ARM (altra, aarch64).
```
name                                                  old CYCLES/op        new CYCLES/op        delta
BM_MapInsertSeq<Map<int, int>>/1                         119 ± 2%             119 ± 1%     ~     (p=0.961 n=55+54)
BM_MapInsertSeq<Map<int, int>>/2                         133 ± 1%             134 ± 1%     ~     (p=0.342 n=56+57)
BM_MapInsertSeq<Map<int, int>>/3                         150 ± 1%             150 ± 1%     ~     (p=0.856 n=56+57)
BM_MapInsertSeq<Map<int, int>>/4                         167 ± 2%             167 ± 2%     ~     (p=0.430 n=56+57)
BM_MapInsertSeq<Map<int, int>>/8                         234 ± 5%             234 ± 3%     ~     (p=0.957 n=57+57)
BM_MapInsertSeq<Map<int, int>>/16                        368 ± 4%             368 ± 4%     ~     (p=0.762 n=57+57)
BM_MapInsertSeq<Map<int, int>>/32                        650 ± 4%             650 ± 4%     ~     (p=0.955 n=57+57)
BM_MapInsertSeq<Map<int, int>>/64                      1.93k ± 4%           1.98k ± 4%   +2.35%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/256                     9.68k ± 5%           9.85k ± 3%   +1.74%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/4096                     177k ± 3%            163k ± 2%   -8.17%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/65536                   3.99M ± 3%           3.87M ± 4%   -3.12%  (p=0.000 n=56+56)
BM_MapInsertSeq<Map<int, int>>/1048576                 90.5M ± 5%           91.3M ± 6%   +0.87%  (p=0.025 n=55+55)
BM_MapInsertSeq<Map<int, int>>/16777216                2.77G ± 8%           2.74G ± 9%     ~     (p=0.076 n=57+57)
BM_MapInsertSeq<Map<int, int>>/56                      1.05k ± 5%           1.05k ± 5%     ~     (p=0.727 n=57+57)
BM_MapInsertSeq<Map<int, int>>/224                     6.29k ± 5%           6.37k ± 4%   +1.32%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/3584                     124k ± 4%            109k ± 3%  -12.46%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/57344                   2.67M ± 4%           2.50M ± 4%   -6.40%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/917504                  65.3M ± 6%           65.8M ± 6%   +0.89%  (p=0.050 n=55+56)
BM_MapInsertSeq<Map<int, int>>/14680064                2.17G ±10%           2.14G ± 9%   -1.55%  (p=0.032 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/1                       122 ± 1%             122 ± 1%     ~     (p=0.415 n=56+56)
BM_MapInsertSeq<Map<int*, int*>>/2                       136 ± 1%             136 ± 1%     ~     (p=0.861 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/3                       153 ± 1%             153 ± 1%     ~     (p=0.607 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/4                       170 ± 2%             174 ± 3%   +2.34%  (p=0.001 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/8                       238 ± 4%             242 ± 3%   +1.59%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/16                      382 ± 4%             383 ± 4%     ~     (p=0.977 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/32                      701 ± 7%             682 ± 5%   -2.69%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/64                    2.13k ± 6%           2.09k ± 3%   -1.89%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/256                   10.3k ± 3%           10.2k ± 3%   -0.94%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/4096                   184k ± 2%            179k ± 2%   -2.62%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/65536                 3.63M ± 2%           3.68M ± 3%   +1.22%  (p=0.000 n=54+57)
BM_MapInsertSeq<Map<int*, int*>>/1048576                129M ±10%            129M ±10%     ~     (p=0.874 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/16777216              3.27G ±11%           3.24G ±10%     ~     (p=0.451 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/56                    1.18k ± 9%           1.10k ± 5%   -6.52%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/224                   6.76k ± 5%           6.59k ± 4%   -2.55%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/3584                   117k ± 2%            115k ± 3%   -1.93%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/57344                 2.22M ± 3%           2.24M ± 2%   +0.87%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/917504                95.0M ± 8%           94.8M ± 9%     ~     (p=0.894 n=55+57)
BM_MapInsertSeq<Map<int*, int*>>/14680064              2.42G ±14%           2.40G ±13%     ~     (p=0.852 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/1             124 ± 1%             124 ± 1%     ~     (p=0.604 n=56+55)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/2             140 ± 1%             140 ± 1%     ~     (p=0.181 n=56+56)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/3             158 ± 1%             158 ± 3%     ~     (p=1.000 n=56+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/4             176 ± 2%             176 ± 3%     ~     (p=0.125 n=56+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/8             247 ± 4%             247 ± 2%     ~     (p=0.614 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/16            391 ± 3%             391 ± 2%     ~     (p=0.993 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/32            690 ± 3%             691 ± 3%     ~     (p=0.224 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/64          2.17k ± 3%           2.22k ± 3%   +1.94%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/256         11.1k ± 3%           11.3k ± 3%   +1.58%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/4096         204k ± 2%            193k ± 2%   -5.65%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/65536       5.19M ± 3%           5.09M ± 3%   -2.05%  (p=0.000 n=56+56)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/1048576      124M ±10%            123M ± 6%     ~     (p=0.626 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/16777216    3.30G ± 9%           3.25G ± 8%   -1.39%  (p=0.019 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/56          1.12k ± 3%           1.12k ± 3%     ~     (p=0.482 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/224         7.04k ± 4%           7.14k ± 3%   +1.36%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/3584         138k ± 2%            126k ± 2%   -8.89%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/57344       3.48M ± 4%           3.34M ± 4%   -3.93%  (p=0.000 n=56+56)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/917504      84.4M ± 7%           84.9M ± 6%     ~     (p=0.159 n=56+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/14680064    2.42G ± 9%           2.40G ±10%     ~     (p=0.300 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/1             168 ± 0%             168 ± 0%     ~     (p=0.555 n=56+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/2             208 ± 0%             208 ± 0%     ~     (p=0.722 n=52+53)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/3             248 ± 0%             248 ± 0%     ~     (p=0.248 n=53+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/4             288 ± 0%             288 ± 0%     ~     (p=0.185 n=54+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/8             457 ± 0%             457 ± 0%     ~     (p=0.665 n=53+53)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/16            867 ± 1%             867 ± 1%     ~     (p=0.174 n=47+52)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/32          1.61k ± 3%           1.62k ± 4%     ~     (p=0.402 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/64          4.96k ± 9%           4.89k ± 5%   -1.37%  (p=0.046 n=57+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/256         26.9k ± 8%           26.5k ± 8%   -1.51%  (p=0.004 n=56+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/4096         600k ± 3%            588k ± 2%   -2.07%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/65536       13.9M ± 3%           13.5M ± 2%   -2.99%  (p=0.000 n=55+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/1048576      407M ± 7%            393M ± 5%   -3.27%  (p=0.000 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/16777216    10.2G ± 8%            9.9G ± 5%   -3.50%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/56          2.81k ± 5%           2.81k ± 4%     ~     (p=0.809 n=56+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/224         17.9k ± 6%           17.6k ± 5%   -1.20%  (p=0.035 n=57+52)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/3584         374k ± 3%            367k ± 3%   -1.80%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/57344       8.64M ± 3%           8.53M ± 2%   -1.29%  (p=0.000 n=55+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/917504       247M ± 6%            244M ± 5%   -1.19%  (p=0.021 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/14680064    6.81G ± 8%           6.64G ± 6%   -2.46%  (p=0.000 n=57+57)
```

Benchmarks on x86
```
name                                                  old cpu/op   new cpu/op   delta
BM_MapInsertSeq<Map<int, int>>/1                      32.9ns ± 3%  32.6ns ± 3%   -0.84%  (p=0.027 n=54+51)
BM_MapInsertSeq<Map<int, int>>/2                      35.9ns ± 3%  35.7ns ± 4%     ~     (p=0.123 n=54+54)
BM_MapInsertSeq<Map<int, int>>/3                      39.7ns ± 3%  47.4ns ± 4%  +19.40%  (p=0.000 n=55+56)
BM_MapInsertSeq<Map<int, int>>/4                      52.7ns ± 3%  52.1ns ± 4%   -1.22%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/8                      78.1ns ± 3%  78.3ns ± 3%     ~     (p=0.141 n=50+57)
BM_MapInsertSeq<Map<int, int>>/16                      135ns ± 3%   135ns ± 4%     ~     (p=0.936 n=53+57)
BM_MapInsertSeq<Map<int, int>>/32                      249ns ± 3%   241ns ± 3%   -3.28%  (p=0.000 n=55+57)
BM_MapInsertSeq<Map<int, int>>/64                      631ns ± 3%   618ns ± 3%   -2.21%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/256                    2.62µs ± 3%  2.36µs ± 4%  -10.02%  (p=0.000 n=52+53)
BM_MapInsertSeq<Map<int, int>>/4096                   39.2µs ± 3%  37.9µs ± 4%   -3.40%  (p=0.000 n=57+56)
BM_MapInsertSeq<Map<int, int>>/65536                   972µs ± 3%   955µs ± 3%   -1.76%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/1048576                16.2ms ± 4%  16.3ms ± 5%     ~     (p=0.231 n=52+54)
BM_MapInsertSeq<Map<int, int>>/16777216                651ms ± 3%   648ms ± 2%   -0.42%  (p=0.048 n=57+56)
BM_MapInsertSeq<Map<int, int>>/56                      418ns ± 3%   401ns ± 3%   -4.10%  (p=0.000 n=54+57)
BM_MapInsertSeq<Map<int, int>>/224                    1.79µs ± 3%  1.61µs ± 3%  -10.20%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, int>>/3584                   26.0µs ± 3%  24.9µs ± 4%   -4.13%  (p=0.000 n=57+56)
BM_MapInsertSeq<Map<int, int>>/57344                   560µs ± 3%   549µs ± 3%   -2.11%  (p=0.000 n=56+57)
BM_MapInsertSeq<Map<int, int>>/917504                 10.4ms ± 3%  10.4ms ± 3%     ~     (p=0.805 n=56+56)
BM_MapInsertSeq<Map<int, int>>/14680064                422ms ± 2%   421ms ± 3%     ~     (p=0.269 n=57+56)
BM_MapInsertSeq<Map<int*, int*>>/1                    33.7ns ± 3%  33.7ns ± 3%     ~     (p=0.620 n=55+55)
BM_MapInsertSeq<Map<int*, int*>>/2                    36.7ns ± 3%  36.5ns ± 3%     ~     (p=0.160 n=55+56)
BM_MapInsertSeq<Map<int*, int*>>/3                    41.1ns ± 2%  41.0ns ± 4%     ~     (p=0.284 n=54+56)
BM_MapInsertSeq<Map<int*, int*>>/4                    45.0ns ± 3%  53.9ns ± 4%  +19.70%  (p=0.000 n=57+56)
BM_MapInsertSeq<Map<int*, int*>>/8                    77.1ns ± 3%  80.9ns ± 4%   +4.98%  (p=0.000 n=55+57)
BM_MapInsertSeq<Map<int*, int*>>/16                    130ns ± 3%   136ns ± 4%   +4.42%  (p=0.000 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/32                    244ns ± 3%   246ns ± 4%   +0.95%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/64                    620ns ± 3%   674ns ± 3%   +8.83%  (p=0.000 n=55+57)
BM_MapInsertSeq<Map<int*, int*>>/256                  2.93µs ± 3%  2.88µs ± 3%   -1.73%  (p=0.000 n=56+56)
BM_MapInsertSeq<Map<int*, int*>>/4096                 54.0µs ± 3%  50.8µs ± 4%   -6.01%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/65536                1.18ms ± 2%  1.17ms ± 4%     ~     (p=0.083 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/1048576              28.9ms ± 4%  29.1ms ± 5%   +0.91%  (p=0.007 n=55+56)
BM_MapInsertSeq<Map<int*, int*>>/16777216              914ms ± 2%   919ms ± 3%   +0.56%  (p=0.015 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/56                    404ns ± 3%   427ns ± 4%   +5.60%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/224                  1.88µs ± 3%  1.87µs ± 4%   -0.68%  (p=0.013 n=55+53)
BM_MapInsertSeq<Map<int*, int*>>/3584                 34.2µs ± 3%  32.9µs ± 4%   -4.02%  (p=0.000 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/57344                 768µs ± 3%   756µs ± 3%   -1.53%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int*, int*>>/917504               16.4ms ± 5%  16.5ms ± 7%     ~     (p=0.303 n=56+57)
BM_MapInsertSeq<Map<int*, int*>>/14680064              607ms ± 2%   613ms ± 3%   +0.92%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/1          34.1ns ± 3%  34.2ns ± 4%     ~     (p=0.288 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/2          37.4ns ± 3%  37.5ns ± 3%     ~     (p=0.316 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/3          41.8ns ± 4%  49.1ns ± 3%  +17.45%  (p=0.000 n=57+56)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/4          54.6ns ± 3%  53.9ns ± 5%   -1.35%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/8          81.4ns ± 3%  81.4ns ± 4%     ~     (p=0.956 n=56+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/16          139ns ± 3%   139ns ± 3%     ~     (p=0.754 n=57+56)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/32          256ns ± 3%   250ns ± 4%   -2.32%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/64          705ns ± 4%   687ns ± 3%   -2.56%  (p=0.000 n=53+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/256        2.95µs ± 5%  3.05µs ± 3%   +3.42%  (p=0.000 n=52+55)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/4096       49.6µs ± 3%  50.8µs ± 4%   +2.44%  (p=0.000 n=55+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/65536      1.39ms ± 3%  1.40ms ± 3%   +0.65%  (p=0.004 n=57+56)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/1048576    37.7ms ± 4%  38.1ms ± 4%   +1.07%  (p=0.001 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/16777216    1.20s ± 3%   1.20s ± 3%   +0.50%  (p=0.040 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/56          432ns ± 3%   414ns ± 3%   -3.99%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/224        1.92µs ± 4%  1.89µs ± 4%   -1.48%  (p=0.000 n=52+55)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/3584       31.5µs ± 4%  32.1µs ± 4%   +1.89%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/57344       757µs ± 3%   748µs ± 3%   -1.28%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/917504     21.9ms ± 4%  22.1ms ± 5%     ~     (p=0.096 n=57+57)
BM_MapInsertSeq<Map<int, llvm::StringRef>>/14680064    735ms ± 3%   737ms ± 3%     ~     (p=0.208 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/1          41.5ns ± 3%  41.4ns ± 4%     ~     (p=0.790 n=54+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/2          50.6ns ± 4%  50.6ns ± 5%     ~     (p=0.684 n=53+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/3          59.7ns ± 4%  59.4ns ± 4%     ~     (p=0.277 n=55+53)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/4          68.5ns ± 5%  68.2ns ± 5%     ~     (p=0.623 n=54+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/8           107ns ± 5%   107ns ± 9%     ~     (p=0.359 n=54+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/16          200ns ± 6%   200ns ± 6%     ~     (p=0.772 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/32          373ns ± 8%   371ns ± 7%     ~     (p=0.541 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/64         1.11µs ± 9%  1.09µs ± 8%   -2.09%  (p=0.003 n=56+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/256        5.61µs ± 5%  5.48µs ± 7%   -2.42%  (p=0.000 n=54+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/4096        153µs ± 4%   147µs ± 6%   -3.80%  (p=0.000 n=54+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/65536      3.24ms ± 3%  3.10ms ± 3%   -4.19%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/1048576     100ms ± 2%    98ms ± 3%   -1.97%  (p=0.000 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/16777216    2.45s ± 2%   2.40s ± 3%   -2.09%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/56          637ns ± 8%   630ns ± 8%     ~     (p=0.101 n=56+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/224        3.77µs ± 6%  3.68µs ± 6%   -2.42%  (p=0.000 n=56+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/3584       92.1µs ± 7%  88.4µs ± 6%   -4.04%  (p=0.000 n=57+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/57344      1.99ms ± 4%  1.92ms ± 3%   -3.47%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/917504     62.1ms ± 4%  60.9ms ± 3%   -1.93%  (p=0.000 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/14680064    1.53s ± 3%   1.50s ± 3%   -1.85%  (p=0.000 n=57+57)
```

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
2024-12-31 05:44:37 +00:00
Vitaly Goldshteyn 384e1cbb92 Update Read*To* to improve operation dependency graph. (#4746)
Benchmarks for StringRef key seem slightly positive.

```
name                                                               old CYCLES/op        new CYCLES/op        delta
BM_MapContainsHit<Map<llvm::StringRef, int>>/1/256                   24.2 ± 0%            23.9 ± 0%  -1.14%        (p=0.000 n=54+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/2/256                   24.2 ± 0%            23.9 ± 0%  -1.15%        (p=0.000 n=53+54)
BM_MapContainsHit<Map<llvm::StringRef, int>>/3/256                   24.2 ± 0%            23.9 ± 0%  -1.15%        (p=0.000 n=53+54)
BM_MapContainsHit<Map<llvm::StringRef, int>>/4/256                   24.2 ± 0%            23.9 ± 0%  -1.14%        (p=0.000 n=56+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/8/256                   25.4 ± 3%            26.3 ± 4%  +3.61%        (p=0.000 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/16/256                  29.1 ± 2%            29.0 ± 2%  -0.28%        (p=0.030 n=56+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/32/256                  29.2 ± 2%            29.0 ± 1%  -0.59%        (p=0.000 n=57+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/64/256                  30.1 ± 2%            30.0 ± 2%  -0.43%        (p=0.045 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/256/256                 30.5 ± 1%            30.3 ± 1%  -0.56%        (p=0.000 n=56+56)
BM_MapContainsHit<Map<llvm::StringRef, int>>/256/64                  29.2 ± 1%            29.2 ± 2%    ~           (p=0.513 n=55+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/256/128                 29.6 ± 1%            29.5 ± 1%  -0.34%        (p=0.002 n=55+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/4096/256                32.0 ± 2%            31.9 ± 2%    ~           (p=0.082 n=55+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/4096/1024               37.8 ± 2%            37.8 ± 1%    ~           (p=0.751 n=57+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/4096/2048               45.3 ± 2%            45.5 ± 2%  +0.46%        (p=0.001 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/65536/256               34.3 ± 2%            34.2 ± 2%  -0.46%        (p=0.000 n=57+56)
BM_MapContainsHit<Map<llvm::StringRef, int>>/65536/16384             72.4 ± 3%            72.3 ± 2%    ~           (p=0.458 n=54+50)
BM_MapContainsHit<Map<llvm::StringRef, int>>/65536/32768             77.7 ± 3%            77.6 ± 3%    ~           (p=0.774 n=56+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/1048576/256             34.9 ± 1%            34.8 ± 2%    ~           (p=0.051 n=56+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/1048576/262144           115 ± 5%             115 ± 5%    ~           (p=0.660 n=57+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/1048576/524288           145 ± 4%             145 ± 5%    ~           (p=0.917 n=57+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/16777216/256            36.5 ± 2%            36.5 ± 2%    ~           (p=0.250 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/16777216/4194304         288 ± 3%             287 ± 4%    ~           (p=0.058 n=56+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/16777216/8388608         303 ± 2%             302 ± 3%  -0.47%        (p=0.044 n=53+54)
BM_MapContainsHit<Map<llvm::StringRef, int>>/56/256                  29.1 ± 3%            29.0 ± 3%    ~           (p=0.147 n=56+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/224/256                 30.7 ± 2%            30.6 ± 2%    ~           (p=0.140 n=56+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/3584/256                31.4 ± 1%            31.3 ± 1%  -0.42%        (p=0.003 n=53+54)
BM_MapContainsHit<Map<llvm::StringRef, int>>/3584/896                35.8 ± 2%            36.0 ± 2%  +0.58%        (p=0.000 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/3584/1792               43.5 ± 1%            43.6 ± 2%  +0.21%        (p=0.032 n=51+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/57344/256               34.3 ± 2%            34.1 ± 1%  -0.43%        (p=0.003 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/57344/14336             67.1 ± 2%            66.8 ± 2%    ~           (p=0.057 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/57344/28672             72.8 ± 3%            72.5 ± 3%  -0.45%        (p=0.032 n=57+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/917504/256              34.7 ± 2%            34.6 ± 2%    ~           (p=0.065 n=56+57)
BM_MapContainsHit<Map<llvm::StringRef, int>>/917504/229376            104 ± 4%             104 ± 5%    ~           (p=0.853 n=55+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/917504/458752            114 ± 6%             114 ± 5%    ~           (p=0.643 n=56+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/14680064/256            36.4 ± 2%            36.2 ± 2%  -0.58%        (p=0.001 n=56+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/14680064/3670016         271 ± 2%             271 ± 4%    ~           (p=0.632 n=55+55)
BM_MapContainsHit<Map<llvm::StringRef, int>>/14680064/7340032         285 ± 3%             285 ± 3%    ~           (p=0.658 n=57+55)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/1                      19.3 ± 1%            19.3 ± 2%    ~           (p=0.201 n=55+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/2                      19.4 ± 1%            19.3 ± 1%    ~           (p=0.191 n=56+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/3                      19.4 ± 1%            19.4 ± 2%    ~           (p=0.422 n=55+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/4                      19.4 ± 1%            19.4 ± 1%    ~           (p=0.179 n=56+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/8                      19.5 ± 2%            19.5 ± 1%    ~           (p=0.148 n=54+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/16                     19.7 ± 2%            19.6 ± 2%    ~           (p=0.204 n=54+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/32                     20.0 ± 3%            20.0 ± 3%    ~           (p=0.917 n=56+54)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/64                     19.8 ± 3%            19.8 ± 3%    ~           (p=0.245 n=57+54)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/256                    20.1 ± 3%            20.1 ± 3%    ~           (p=0.307 n=57+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/4096                   20.1 ± 3%            20.2 ± 2%    ~           (p=0.070 n=57+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/65536                  20.5 ± 3%            20.5 ± 3%    ~           (p=0.174 n=56+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/1048576                20.9 ± 2%            20.8 ± 3%    ~           (p=0.476 n=53+55)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/16777216               22.2 ± 4%            22.2 ± 3%    ~           (p=0.807 n=57+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/56                     24.9 ±28%            23.9 ±16%    ~           (p=0.058 n=57+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/224                    27.1 ±19%            26.6 ±19%    ~           (p=0.122 n=57+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/3584                   28.9 ±10%            28.7 ±10%    ~           (p=0.405 n=56+57)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/57344                  30.5 ± 7%            31.2 ± 7%  +2.32%        (p=0.000 n=57+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/917504                 31.8 ± 7%            31.7 ± 7%    ~           (p=0.713 n=57+56)
BM_MapContainsMiss<Map<llvm::StringRef, int>>/14680064               33.4 ± 9%            33.5 ± 7%    ~           (p=0.921 n=56+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/1/256                     49.3 ± 0%            48.2 ± 0%  -2.17%        (p=0.000 n=55+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/2/256                     49.3 ± 0%            48.2 ± 0%  -2.17%        (p=0.000 n=56+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/3/256                     49.3 ± 0%            48.2 ± 0%  -2.17%        (p=0.000 n=54+55)
BM_MapLookupHit<Map<llvm::StringRef, int>>/4/256                     49.3 ± 0%            48.2 ± 0%  -2.17%        (p=0.000 n=54+53)
BM_MapLookupHit<Map<llvm::StringRef, int>>/8/256                     49.0 ± 0%            48.0 ± 0%  -2.02%        (p=0.000 n=51+51)
BM_MapLookupHit<Map<llvm::StringRef, int>>/16/256                    51.8 ± 1%            51.3 ± 1%  -0.89%        (p=0.000 n=50+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/32/256                    51.8 ± 1%            51.3 ± 1%  -1.07%        (p=0.000 n=56+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/64/256                    52.4 ± 1%            51.8 ± 1%  -1.12%        (p=0.000 n=57+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/256/256                   54.6 ± 1%            54.1 ± 1%  -0.94%        (p=0.000 n=53+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/256/64                    51.9 ± 1%            51.4 ± 1%  -0.95%        (p=0.000 n=55+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/256/128                   52.5 ± 1%            52.0 ± 1%  -1.07%        (p=0.000 n=57+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/4096/256                  62.0 ± 3%            61.6 ± 3%  -0.62%        (p=0.002 n=55+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/4096/1024                 74.6 ± 1%            73.5 ± 1%  -1.38%        (p=0.000 n=56+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/4096/2048                 80.9 ± 1%            79.8 ± 1%  -1.34%        (p=0.000 n=57+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/65536/256                 72.0 ± 2%            71.4 ± 2%  -0.77%        (p=0.000 n=56+55)
BM_MapLookupHit<Map<llvm::StringRef, int>>/65536/16384                145 ± 4%             145 ± 3%    ~           (p=0.662 n=57+55)
BM_MapLookupHit<Map<llvm::StringRef, int>>/65536/32768                155 ± 4%             156 ± 4%    ~           (p=0.541 n=57+54)
BM_MapLookupHit<Map<llvm::StringRef, int>>/1048576/256               73.1 ± 2%            72.5 ± 2%  -0.73%        (p=0.000 n=56+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/1048576/262144             281 ± 7%             283 ± 5%    ~           (p=0.284 n=57+49)
BM_MapLookupHit<Map<llvm::StringRef, int>>/1048576/524288             342 ± 5%             342 ± 5%    ~           (p=0.684 n=57+53)
BM_MapLookupHit<Map<llvm::StringRef, int>>/16777216/256              77.5 ± 2%            76.9 ± 2%  -0.74%        (p=0.000 n=55+54)
BM_MapLookupHit<Map<llvm::StringRef, int>>/16777216/4194304           750 ± 3%             749 ± 3%    ~           (p=0.458 n=57+53)
BM_MapLookupHit<Map<llvm::StringRef, int>>/16777216/8388608           802 ± 2%             801 ± 3%    ~           (p=0.518 n=57+55)
BM_MapLookupHit<Map<llvm::StringRef, int>>/56/256                    51.9 ± 1%            51.3 ± 1%  -1.10%        (p=0.000 n=57+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/224/256                   54.0 ± 1%            53.5 ± 1%  -1.01%        (p=0.000 n=56+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/3584/256                  58.8 ± 2%            58.1 ± 2%  -1.28%        (p=0.000 n=56+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/3584/896                  69.7 ± 2%            68.7 ± 1%  -1.35%        (p=0.000 n=57+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/3584/1792                 77.1 ± 1%            76.0 ± 1%  -1.45%        (p=0.000 n=55+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/57344/256                 71.3 ± 2%            70.7 ± 3%  -0.85%        (p=0.000 n=55+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/57344/14336                128 ± 3%             128 ± 3%    ~           (p=0.556 n=57+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/57344/28672                140 ± 4%             140 ± 3%    ~           (p=0.735 n=57+51)
BM_MapLookupHit<Map<llvm::StringRef, int>>/917504/256                72.8 ± 2%            72.3 ± 2%  -0.76%        (p=0.000 n=57+57)
BM_MapLookupHit<Map<llvm::StringRef, int>>/917504/229376              242 ± 7%             243 ± 6%    ~           (p=0.303 n=57+55)
BM_MapLookupHit<Map<llvm::StringRef, int>>/917504/458752              264 ± 7%             264 ± 6%    ~           (p=0.823 n=57+55)
BM_MapLookupHit<Map<llvm::StringRef, int>>/14680064/256              76.4 ± 2%            75.8 ± 3%  -0.78%        (p=0.000 n=57+56)
BM_MapLookupHit<Map<llvm::StringRef, int>>/14680064/3670016           696 ± 3%             698 ± 3%    ~           (p=0.189 n=56+53)
BM_MapLookupHit<Map<llvm::StringRef, int>>/14680064/7340032           749 ± 3%             750 ± 3%    ~           (p=0.266 n=55+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/1/256                     34.9 ± 0%            35.0 ± 0%  +0.36%        (p=0.000 n=56+50)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/2/256                     34.9 ± 0%            35.0 ± 0%  +0.35%        (p=0.000 n=55+53)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/3/256                     34.9 ± 0%            35.0 ± 0%  +0.35%        (p=0.000 n=55+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/4/256                     34.9 ± 0%            35.0 ± 0%  +0.36%        (p=0.000 n=56+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/8/256                     37.5 ± 3%            37.6 ± 2%    ~           (p=0.081 n=57+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/16/256                    39.4 ± 1%            39.5 ± 2%    ~           (p=0.054 n=55+57)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/32/256                    40.0 ± 3%            39.9 ± 4%    ~           (p=0.449 n=56+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/64/256                    40.0 ± 1%            40.1 ± 2%    ~           (p=0.796 n=54+54)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/256/256                   41.1 ± 2%            41.2 ± 2%    ~           (p=0.061 n=53+50)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/256/64                    39.6 ± 2%            39.6 ± 2%    ~           (p=0.695 n=55+52)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/256/128                   40.2 ± 2%            40.1 ± 2%    ~           (p=0.507 n=53+49)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/4096/256                  43.4 ± 2%            43.5 ± 2%    ~           (p=0.300 n=53+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/4096/1024                 50.9 ± 2%            51.8 ± 2%  +1.79%        (p=0.000 n=56+57)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/4096/2048                 58.2 ± 1%            58.3 ± 1%    ~           (p=0.072 n=57+57)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/65536/256                 46.1 ± 1%            46.1 ± 2%    ~           (p=0.197 n=54+53)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/65536/16384               88.1 ± 5%            88.9 ± 4%  +0.90%        (p=0.011 n=57+57)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/65536/32768               92.4 ± 3%            93.6 ± 3%  +1.35%        (p=0.000 n=57+57)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/1048576/256               46.6 ± 2%            46.7 ± 2%    ~           (p=0.687 n=51+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/1048576/262144             144 ± 7%             145 ± 6%    ~           (p=0.130 n=57+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/1048576/524288             181 ± 4%             182 ± 4%    ~           (p=0.057 n=56+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/16777216/256              48.9 ± 2%            48.7 ± 2%  -0.30%        (p=0.042 n=56+53)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/16777216/4194304           351 ± 2%             350 ± 3%    ~           (p=0.287 n=57+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/16777216/8388608           368 ± 3%             367 ± 3%    ~           (p=0.710 n=57+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/56/256                    39.7 ± 3%            39.6 ± 3%    ~           (p=0.572 n=57+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/224/256                   41.7 ± 2%            41.6 ± 3%    ~           (p=0.233 n=55+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/3584/256                  42.6 ± 2%            42.5 ± 2%    ~           (p=0.309 n=54+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/3584/896                  49.1 ± 1%            49.8 ± 1%  +1.51%        (p=0.000 n=57+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/3584/1792                 57.0 ± 1%            57.1 ± 2%  +0.30%        (p=0.022 n=56+57)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/57344/256                 46.1 ± 2%            46.0 ± 1%  -0.28%        (p=0.013 n=55+53)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/57344/14336               82.0 ± 2%            82.6 ± 2%  +0.71%        (p=0.000 n=57+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/57344/28672               88.7 ± 2%            89.8 ± 2%  +1.22%        (p=0.000 n=57+53)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/917504/256                46.5 ± 1%            46.5 ± 2%    ~           (p=0.961 n=53+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/917504/229376              126 ± 5%             128 ± 5%  +1.64%        (p=0.000 n=57+54)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/917504/458752              140 ± 5%             141 ± 6%    ~           (p=0.162 n=57+55)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/14680064/256              48.5 ± 2%            48.3 ± 2%    ~           (p=0.094 n=55+54)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/14680064/3670016           328 ± 4%             328 ± 3%    ~           (p=0.925 n=57+56)
BM_MapUpdateHit<Map<llvm::StringRef, int>>/14680064/7340032           345 ± 3%             345 ± 3%    ~           (p=0.489 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/1/256                76.0 ± 0%            75.9 ± 0%  -0.03%        (p=0.006 n=54+47)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/2/256                71.3 ± 1%            72.1 ± 5%    ~           (p=0.750 n=52+54)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/3/256                70.9 ± 2%            70.7 ± 2%    ~           (p=0.095 n=54+52)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/4/256                70.4 ± 2%            70.6 ± 3%    ~           (p=0.458 n=47+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/8/256                75.0 ± 1%            74.2 ± 1%  -1.16%        (p=0.000 n=52+54)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/16/256               80.5 ± 3%            79.0 ± 3%  -1.88%        (p=0.000 n=51+53)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/32/256               83.2 ± 4%            82.3 ± 5%  -1.01%        (p=0.009 n=56+57)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/64/256               80.6 ± 3%            79.4 ± 4%  -1.48%        (p=0.000 n=52+54)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/256/256              83.6 ± 3%            82.6 ± 5%  -1.23%        (p=0.000 n=54+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/256/64               79.1 ± 6%            78.8 ± 8%    ~           (p=0.359 n=55+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/256/128              81.1 ± 6%            80.3 ± 9%  -1.04%        (p=0.010 n=55+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/4096/256             85.5 ± 5%            84.1 ± 4%  -1.61%        (p=0.000 n=54+57)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/4096/1024            95.7 ± 3%            95.2 ± 2%  -0.47%        (p=0.033 n=56+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/4096/2048             101 ± 2%             101 ± 1%  -0.68%        (p=0.000 n=56+54)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/65536/256            90.5 ± 4%            88.1 ± 4%  -2.57%        (p=0.000 n=56+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/65536/16384           134 ± 3%             133 ± 2%  -0.71%        (p=0.002 n=57+57)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/65536/32768           142 ± 3%             141 ± 2%  -0.90%        (p=0.000 n=57+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/1048576/256          91.2 ± 3%            89.3 ± 4%  -2.08%        (p=0.000 n=56+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/1048576/262144        209 ± 5%             208 ± 5%    ~           (p=0.170 n=57+54)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/1048576/524288        243 ± 5%             240 ± 5%  -1.05%        (p=0.020 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/16777216/256         94.3 ± 3%            92.5 ± 5%  -1.91%        (p=0.000 n=55+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/16777216/4194304      542 ± 3%             537 ± 4%  -1.02%        (p=0.000 n=57+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/16777216/8388608      566 ± 3%             561 ± 4%  -1.01%        (p=0.000 n=57+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/56/256               83.7 ±10%            81.3 ± 8%  -2.84%        (p=0.000 n=55+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/224/256              88.7 ± 8%            86.6 ± 9%  -2.40%        (p=0.001 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/3584/256             94.0 ± 5%            91.3 ± 4%  -2.83%        (p=0.000 n=56+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/3584/896              118 ± 4%             118 ± 5%    ~           (p=0.930 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/3584/1792             143 ± 4%             141 ± 4%  -1.10%        (p=0.002 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/57344/256             102 ± 4%             100 ± 4%  -2.31%        (p=0.000 n=56+57)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/57344/14336           191 ± 2%             190 ± 1%  -0.32%        (p=0.024 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/57344/28672           197 ± 2%             197 ± 1%    ~           (p=0.059 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/917504/256            103 ± 4%             101 ± 4%  -1.99%        (p=0.000 n=57+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/917504/229376         280 ± 3%             279 ± 3%    ~           (p=0.145 n=57+52)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/917504/458752         298 ± 4%             296 ± 3%    ~           (p=0.116 n=57+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/14680064/256          107 ± 4%             104 ± 4%  -2.11%        (p=0.000 n=55+56)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/14680064/3670016      613 ± 3%             612 ± 2%    ~           (p=0.224 n=57+55)
BM_MapEraseUpdateHit<Map<llvm::StringRef, int>>/14680064/7340032      637 ± 2%             635 ± 1%    ~           (p=0.075 n=56+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/1                          132 ± 0%             132 ± 0%  -0.26%        (p=0.000 n=47+41)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/2                          160 ± 0%             161 ± 4%  +0.57%        (p=0.001 n=45+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/3                          188 ± 2%             189 ± 3%    ~           (p=0.327 n=54+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/4                          217 ± 3%             218 ± 5%    ~           (p=0.240 n=54+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/8                          342 ± 5%             341 ± 4%    ~           (p=0.282 n=53+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/16                         640 ± 3%             648 ± 8%  +1.26%        (p=0.023 n=49+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/32                       1.20k ± 8%           1.20k ± 8%    ~           (p=0.423 n=53+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/64                       3.57k ± 8%           3.55k ± 6%    ~           (p=0.557 n=57+54)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/256                      18.6k ± 5%           18.6k ± 6%    ~           (p=0.799 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/4096                      492k ± 4%            491k ± 3%    ~           (p=0.378 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/65536                    10.5M ± 2%           10.4M ± 1%    ~           (p=0.143 n=57+48)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/1048576                   323M ± 2%            322M ± 3%    ~           (p=0.098 n=56+56)
BM_MapInsertSeq<Map<ll::StringRef, int>>/16777216                 7.07G ± 3%           7.05G ± 4%    ~           (p=0.195 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/56                       2.04k ± 8%           2.03k ± 7%    ~           (p=0.124 n=52+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/224                      12.0k ± 5%           12.0k ± 4%    ~           (p=0.467 n=57+55)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/3584                      294k ± 5%            292k ± 4%    ~           (p=0.188 n=56+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/57344                    6.40M ± 2%           6.39M ± 1%    ~           (p=0.381 n=57+56)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/917504                    199M ± 3%            199M ± 3%    ~           (p=0.977 n=57+57)
BM_MapInsertSeq<Map<llvm::StringRef, int>>/14680064                 4.56G ± 3%           4.55G ± 3%    ~           (p=0.129 n=55+56)
```
2024-12-31 04:32:52 +00:00
ezbr 9d09061301 Avoid misaligned loads from StaticRandomData in the size [4, 8] hashing case. (#4743)
Avoid misaligned loads from StaticRandomData in the size [4, 8] hashing
case. We can use aligned loads in this case for lower latency. We
introduce the SampleAlignedRandomData function for this purpose.
2024-12-31 04:32:13 +00:00
Richard Smith 4bbc189d55 Don't produce a follow-on error message if we try to perform an impl lookup during error recovery. (#4749) 2024-12-31 03:30:35 +00:00
ezbr afdf846636 Align StaticRandomData to cacheline size. (#4741)
Align StaticRandomData to cacheline size to ensure the whole array is on
the same cacheline.
2024-12-31 02:34:30 +00:00
Richard Smith d41668350b Suppress testing SemIR in int builtin tests. (#4748)
Add `EXTRA-ARGS:` support to file_test, to add arguments without
overriding the default arguments. Use `EXTRA-ARGS: --no-dump-sem-ir` to
turn off SemIR dumping and thus SemIR testing in the int builtin tests,
which validate correct behavior through diagnostics instead.

This doesn't get us any closer to supporting more targeted SemIR dumping
/ testing, but this seems to be a generally useful feature anyway. Most
existing
tests using `ARGS` have been switched over to using `EXTRA-ARGS`.

Requested in review of #4716.
v0.0.0-0.nightly.2024.12.31
2024-12-31 00:35:39 +00:00
josh11bandJosh L 89df77707b Drop references to deleted explorer fuzzer (#4745)
Follow up to delete that happened in #4731 .

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
v0.0.0-0.nightly.2024.12.30 v0.0.0-0.nightly.2024.12.29 v0.0.0-0.nightly.2024.12.28
2024-12-28 02:09:40 +00:00
Richard Smith 7d8d59cb7e Make snegate / unegate overflow handling consistent with other builtins. (#4744)
Make `int.snegate` ignore the signedness of its operand and
unconditionally check for signed overflow like all the other `int.s*`
builtins do. Fix the prelude implementation of unary `-` for `Core.UInt`
to use `int.unegate` instead of `int.snegate`.

Fix the test for unsigned negate to actually test negating unsigned
integers, and add some tests that unary `-` also works.
v0.0.0-0.nightly.2024.12.27
2024-12-26 22:07:47 +00:00
Dana Jansens 724fc7623e Fix the forty_two.carbon example in getting started (#4736)
The Core.Print function has moved into the "io" library, so it needs to
be imported into scope.

Part of issue #4734
v0.0.0-0.nightly.2024.12.26
2024-12-26 00:37:42 +00:00
Dana Jansens 9290ee2bcf Use unsigned arithmetic builtins for UInt(N) operations (#4740)
We were mistakenly using the signed builtins, which produce the same
lowering for add/multiply right now, but don't for division and modulus.

When manually flipping SignedOverflowIsUB on, the signed version of add
gains the nsw (no signed wrap) flag, while the unsigned version
(correctly after this change) does not:
```
// CHECK:STDOUT: define i32 @_Cadd_i32.Main(i32 %a, i32 %b) !dbg !4 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT:   %int.sadd = add nsw i32 %a, %b, !dbg !7
// CHECK:STDOUT:   ret i32 %int.sadd, !dbg !8
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: define i32 @_Cadd_u32.Main(i32 %a, i32 %b) !dbg !9 {
// CHECK:STDOUT: entry:
// CHECK:STDOUT:   %int.uadd = add i32 %a, %b, !dbg !10
// CHECK:STDOUT:   ret i32 %int.uadd, !dbg !11
// CHECK:STDOUT: }
```
2024-12-26 00:36:33 +00:00
josh11bandJosh L 1a5107efa4 Clarify the logic for invalid impl redeclarations (#4738)
Follow up to #4179, specifically re:
https://github.com/carbon-language/carbon-lang/pull/4719#discussion_r1894364691
.

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
v0.0.0-0.nightly.2024.12.25 v0.0.0-0.nightly.2024.12.24
2024-12-23 23:05:12 +00:00
Dana Jansens f8e60a8ec1 Fix path to carbon binary in nightly builder (#4737)
The path moved from ./bazel-bin/toolchain/install/run_carbon to
./bazel-bin/toolchain/carbon in 13502b7c89.

Part of issue https://github.com/carbon-language/carbon-lang/issues/4734
2024-12-23 22:54:30 +00:00
Richard Smith 28602a87c2 Fix handling of repeated tuple indexing. (#4733)
Per [the
design](https://docs.carbon-lang.dev/docs/design/lexical_conventions/),
`x.1.2` should lex as `(x.1).2`, not as `x.(1.2)`.
2024-12-21 06:57:14 +00:00
Jon Ross-Perkins 266fd6aa75 Remove explorer's proto fuzzer and proto dependencies (#4731)
As part of migrating to the latest bazel configurations in #4729, I'm
running into proto toolchain issues. For example:
"Error: <target @@protobuf+//:cc_toolchain> (rule
'proto_lang_toolchain') doesn't contain declared provider
'ProtoLangToolchainInfo'"

Although we may eventually want more use of proto, right now the only
use is for the explorer fuzzer. The explorer codebase is essentially
frozen, so continuing to run it isn't gaining us much (in fact, we've
already disabled autofuzzing for it).

So, rather than trying to fix the proto setup, this change:

1. Deletes `explorer/fuzzing`
2. Removes proto portions of `testing/fuzzing`, which were only in-use
by the explorer
3. Removes some ancillary proto support, which would otherwise break
from the bazel changes and would be difficult to validate as "still
working"

This change is partly isolated in order to make it easier to revive bits
of (3).
2024-12-20 23:55:06 +00:00
josh11bandJosh L 01ca9f05dd has_definition_started accessor for entities (#4730)
Note that I left some calls to `is_defined()` where I thought they were
interchangeable.

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
2024-12-20 22:29:50 +00:00
Jon Ross-Perkins 9b72b0eb1a Enable strict action env (#4728)
Doing this due to questions about rebuilds. But it now has me looking at
incompatible flags in general.

I believe we should have the specific action_env settings due to the use
in toolchain setup.
2024-12-20 22:23:37 +00:00
josh11bandJosh L 5169a1862e Require a definition in the same file as an impl declaration (#4719)
This PR detects the failures that #4709 fixes.

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
2024-12-20 17:00:53 +00:00
josh11bandJosh L 661ba36119 Remove stale comment (#4727)
Comment became out of date with #4698 . Seems better to delete instead
of update this comment.

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
2024-12-20 16:58:39 +00:00
Dana Jansensandjonmeow 6cb660f5ad Avoid recursion in InstNamer::CollectNamesInBlock (#4706)
Use a deque to maintain the set of instructions to be walked over. so
that the loop can append more instructions (with their related scope)
during iteration without requiring recursion.

---------

Co-authored-by: jonmeow <jperkins@google.com>
2024-12-20 16:12:06 +00:00
Chandler Carruth aca862ceff Fix a clang-tidy issue (#4723) 2024-12-20 07:18:59 +00:00
josh11bandJosh L c130fe8d51 Fix VSCode language extension configuration instructions (#4725)
The instructions did not match the example. The VSCode settings suggests
the example is the correct one.

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
2024-12-20 07:16:35 +00:00
Chandler CarruthandDanila Kutenin 3ae968a74c Teach the SIMD metadata group match to defer masking (#4595)
When using a byte-encoding for matched group metadata we need to mask
down to a single bit in each matching byte to make the iteration of a
range of match indices work. In most cases, this mask can be folded into
the overall match computation, but for Arm Neon, there is avoidable
overhead from this. Instead, we can defer the mask until starting to
iterate. Doing more than one iteration is relative rare so this doesn't
accumulate much waste and makes common paths a bit faster.

For the M1 this makes the SIMD match path about 2-4% faster. This isn't
enough to catch the portable match code path on the M1 though.

For some Neoverse cores the difference here is more significant (>10%
improvement) and it makes the SIMD and scalar code paths have comparable
latency. Still not clear which is better as the latency is comparable
and beyond latency the factors are very hard to analyze -- port pressure
on different parts of the CPU, etc.

Leaving the selected code path as portable since that's so much better
on the M1, and I'm hoping to avoid different code paths for different
Arm CPUs for a while.

---------

Co-authored-by: Danila Kutenin <danilak@google.com>
2024-12-20 04:40:58 +00:00
Jon Ross-Perkins e85125c3d7 Extension version bump and npm update for a release of #4527 (#4722) 2024-12-20 00:59:49 +00:00
Chandler CarruthandJon Ross-Perkins 13502b7c89 Replace #4505 with a different set of workarounds (#4527)
This restores the symlinks for the installation, but teaches the busybox
info search to look for a relative path to the busybox binary itself
before walking through symlinks. This let's it find the tree structure
when directly invoking `prefix_root/bin/carbon` or similar, either
inside of a Bazel rule or from the command line, and mirrors how we
expect the installed tree to look. This works even when Bazel resolves
the symlink target fully, and potentially to something nonsensical like
a CAS file.

In order to make a convenient Bazel target that can be used with `bazel
run //toolchain`, this adds an override to explicitly set the desired
argv[0] to use when selecting a mode for the busybox and a busybox
binary. Currently, the workaround uses an environment variable because
that required the least amount of plumbing, and seems a useful override
mechanism generally, but I'm open to other approaches.

This should allow a few things to work a bit more nicely:
- It should handle sibling symlinks like `clang++` to `clang` or
  `ld.lld` to `lld`, where that symlink in turn points at the busybox.
  We want to use *initial* `argv[0]` value to select the mode there.
- It avoids bouncing through Python (or other subprocesses) when
  invoking the `carbon` binary in Bazel rules, which will be nice for
  building the example code and benchmarking.

It does come at a cost of removing one feature: the initial symlink
can't be some unrelated alias like `my_carbon_symlink` -- we expect the
*first* argv[0] name to have the meaningful filename for selecting
a busybox mode.

It also trades the complexity of the Python script for some complexity
in the busybox search in order to look for a relative `carbon-busybox`
binary. On the whole, I think that tradeoff is worthwhile, but it isn't
free.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2024-12-20 00:33:29 +00:00
josh11bandJosh L 85ea848879 Fix syntactic match of impl decl to definition (#4709)
Co-authored-by: Josh L <josh11b@users.noreply.github.com>
2024-12-20 00:31:38 +00:00
Richard Smith 6fe8e0b5aa Provide generic impls for Core.Int and Core.UInt operations. (#4693)
Instead of providing operations only for `i32`, provide them for all
`iN` and `uN` types.

For now, this excludes the `*Assign`, `Inc` and `Dec` interfaces,
because the implementations for those are defined as Carbon functions
rather than builtins, and we can't yet lower definitions for specific
functions, so converting those to be generic breaks the build for our
examples.
2024-12-19 22:02:18 +00:00
Richard Smith de41a4b1b3 Fix a protected data member in a test. (#4717) 2024-12-19 22:01:18 +00:00
Geoff RomerandRichard Smith a112cbde5c Model type expressions as regions (#4698)
This is a precondition for enabling the new pattern-matching subsystem
to support binding patterns that have `if` expressions in the type
position.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2024-12-19 21:41:06 +00:00
David Blaikie 95c9634c60 Enable libc++ and LLVM pretty printers for gdb (#4715) 2024-12-19 18:53:21 +00:00
Richard Smith a536dbd8d9 Solution for advent of code day 3. (#4713) 2024-12-19 18:23:50 +00:00
Richard Smith 0fa699641a Solution for advent of code day 2. (#4708) 2024-12-19 17:18:19 +00:00
Richard Smith b54a27e9e7 Fix incorrect lowering of mixed constant / non-constant aggregate initialization. (#4704)
We defer lowering initialization with constant values, because the use
of the constant can itself be part of a larger constant that we don't
want to emit. However, when the initialization is for an element of a
non-constant aggregate, we do need to initialize the constant portion.
v0.0.0-0.nightly.2024.12.19
2024-12-19 01:13:29 +00:00
Jon Ross-Perkins ee4746c41c Add documentation for running GDB and LLDB (#4710)
After lots of fidgeting, LLDB seems to work. Not sure how reliable this
will be though -- fission seems a little hit and miss.
2024-12-19 00:32:25 +00:00
Jon Ross-Perkins cb4686bf21 Enable misc-non-private-member-variables-in-classes and adjust style to match (#4702)
Pursuant to discussion regarding #4699, turn on
`misc-non-private-member-variables-in-classes` using the
`IgnoreClassesWithAllMemberVariablesBeingPublic` flag (the check treats
structs as classes, so we need this for structs with all-public
members). Updates the style guide notes to match, which should be pretty
minor due to the scoping of test fixtures.

Also fixes some underscore uses in test files on the way. Basically this
is keeping the style for [class data member
naming](https://google.github.io/styleguide/cppguide.html#Variable_Names)
even while making them public.
2024-12-19 00:31:41 +00:00
Jon Ross-Perkins f67a4a5bcb Do a pass on vscode development instructions (#4703) 2024-12-19 00:31:24 +00:00
Jon Ross-Perkins ecda309c12 Change Dump functions to static where appropriate. (#4712)
Verified under LLDB these still appear callable; I'm expecting GDB to be
the same. My concern about debugger calls to static functions was just
wrong.
2024-12-18 23:58:01 +00:00
Jon Ross-Perkins a85160087b Undo formatting changes for clang-tidy-16 compatibility. (#4707) 2024-12-18 17:47:38 +00:00
Jon Ross-Perkins a651ce1961 Fix default for Carbon Path (#4705)
The extension.ts tries to provide a default, but it's not working the
way I expect. So in addition, provide it in properties, which seems to
work better.
2024-12-18 17:43:47 +00:00
Richard Smith c1590f886a Add equality comparison support for bool. (#4701) v0.0.0-0.nightly.2024.12.18 2024-12-18 00:47:03 +00:00
David Blaikie 4d0a6db49b Abort checking when encountering an invalid parse node (#4700)
Short term solution/block for #4689
2024-12-18 00:19:12 +00:00
Nirmal Patel b69f97d1f3 Fix Devcontainer build errors (#4647)
Devcontainer Dockerfile has been updated to use Ubuntu 24.04 as the
base. Now devcontainer builds without errors. Tested with Podman on
Linux and Docker Desktop on Windows.

To avoid re-downloading and re-compiling whenever the container is
deleted, a named volume is mounted at /home/ubuntu/.cache.

Closes #4065
2024-12-17 23:38:17 +00:00
Jon Ross-PerkinsandGeoff Romer 2eb1c7c372 Document StepStack (#4687)
Also add underscores to member names, and make `PushSpecificId` private
since it's not used outside `PushEntityName`

---------

Co-authored-by: Geoff Romer <gromer@google.com>
2024-12-17 22:55:43 +00:00
Jon Ross-PerkinsandRichard Smith 3f9a06aee3 Look at flipping clang-tidy's misc-* to enable-by-default (#4699)
I was wondering, instead of treating `misc` differently and enabling
specific checks, maybe we can flip that since we actually seem okay with
most of the checks?

The main check I'm enabling, with significant edits here, is
`misc-no-recursion`. But maybe this is helpful to enable, even with the
necessary NOLINTs, since we want to avoid recursion in the toolchain?
This PR shows some example fixes in subst.cpp (which are more stylistic,
since the code shouldn't actually have recursed due to its structure; I
think we could remove the warning on TryResolveInst the same way). Some
also just don't seem worth fixing, like those in tests files (I didn't
see a way to exclude files in .clang-tidy, so instead I'm using
NOLINTBEGIN). But I think we might actually want to fix inst_namer, and
there's enough in convert that I didn't look closely.

Also, I made some protected -> private style fixes based on
`misc-non-private-member-variables-in-classes` (this is also how I
noticed `class Real` versus `struct Real`). With node_stack, it looks
like the `protected` wasn't even used. [Per
style](https://google.github.io/styleguide/cppguide.html#Access_Control),
data members should be private outside tests. But since we can't
trivially exclude `protected` members in tests, I'm turning it off -- I
don't view it as offering enough benefit on the whole.

migrate_cpp issues are preexisting (I believe we just aren't monitoring
it), but changes there make `bazel build --config=clang-tidy -k //...`
work cleanly.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2024-12-17 21:20:37 +00:00
9c8773da1b Basic name poisoning support (#4654)
https://github.com/carbon-language/carbon-lang/issues/4622
When using an unqualified name, disallow declaring that name in all
scopes that would make it ambiguous in retrospect.
Doesn't include support for poisoning in `impl library` (see new test
for that with TODO).
Implemented by introduce `InstId::PoisonedName` and entries with it to
`NameScope`.

---------

Co-authored-by: Dana Jansens <danakj@orodu.net>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
2024-12-17 21:08:26 +00:00
6b3307c520 Support StructValue in StringifyTypeExpr (#4696)
Co-authored-by: Josh L <josh11b@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2024-12-17 19:19:52 +00:00
Geoff Romer 557c9b022a Remove CHECK from GetCurrentReturnSlot (#4688)
`GetCurrentReturnSlot` is sometimes called when there is no return slot
while checking incorrect Carbon code. This change also updates
`fail_returned_var_no_return_type.carbon` to cover one such case.
2024-12-17 19:15:27 +00:00
Boaz Brickner c99c9c41cf Do not load prelude files to the test file system in no-prelude tests (#4697)
These tests do not import prelude so the files do not need to exist, and
only make the tests more complex, as they include extra unnecessary
inputs.
2024-12-17 16:37:31 +00:00
Richard Smith 62f7345bb7 Import support for Call and BoundMethod. (#4695) 2024-12-17 08:26:18 +00:00