[clang] d768b97 - [Support] change StringMap hash function from djbHash to xxHash

2023-02-07 Thread Erik Desjardins via cfe-commits

Author: Erik Desjardins
Date: 2023-02-07T22:55:41-05:00
New Revision: d768b97424f9e1a0aae45440a18b99f21c4027ce

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

LOG: [Support] change StringMap hash function from djbHash to xxHash

Depends on https://reviews.llvm.org/D142861.

Alternative to https://reviews.llvm.org/D137601.

xxHash is much faster than djbHash. This makes a simple Rust test case with a 
large constant string 10% faster to compile.

Previous attempts at changing this hash function (e.g. 
https://reviews.llvm.org/D97396) had to be reverted due to breaking tests that 
depended on iteration order.
No additional tests fail with this patch compared to `main` when running 
`check-all` with `-DLLVM_ENABLE_PROJECTS="all"` (on a Linux host), so I hope I 
found everything that needs to be changed.

Differential Revision: https://reviews.llvm.org/D142862

Added: 


Modified: 
clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
clang/unittests/Basic/SarifTest.cpp
compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
llvm/lib/Support/StringMap.cpp
llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
llvm/test/DebugInfo/X86/gnu-public-names.ll
llvm/test/tools/dsymutil/ARM/extern-alias.test
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
mlir/test/mlir-lsp-server/completion.test

Removed: 




diff  --git a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize 
b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
index 31be95c6b6b3c..afe1ece5eec08 100644
--- a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
+++ b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
@@ -12,5 +12,5 @@
 
 # CHECK: These are the combined files, with problem files preceded by #:
 
-# CHECK: {{.*}}Inputs/CompileError/HasError.h
 # CHECK: Inputs/CompileError/Level1A.h
+# CHECK: {{.*}}Inputs/CompileError/HasError.h

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 06ad4e7a63091..33bccf56babb7 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -332,7 +332,7 @@ TEST_F(SarifDocumentWriterTest, checkSerializingArtifacts) {
 TEST_F(SarifDocumentWriterTest, checkSerializingCodeflows) {
   // GIVEN:
   const std::string ExpectedOutput =
-  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts":[{"length":27,"location":{"index":1,"uri":"file:///test-header-1.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":30,"location":{"index":2,"uri":"file:///test-header-2.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":28,"location":{"index":3,"uri":"file:///test-header-3.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":41,"location":{"index":0,"uri":"file:///main.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"codeFlows":[{"threadFlows":[{"locations":[{"importance":"essential","location":{"message":{"text":"Message
 
#1"},"physicalLocation":{"artifactLocation":{"index":1,"uri":"file:///test-header-1.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"important","location":{"message":{"text":"Message
 
#2"},"physicalLocation":{"artifactLocation":{"index":2,"uri":"file:///test-header-2.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"unimportant","location":{"message":{"text":"Message
 
#3"},"physicalLocation":{"artifactLocation":{"index":3,"uri":"file:///test-header-3.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1]}]}],"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"index":0,"uri":"file:///main.cpp"},"region":{"endColumn":8,"endLine":2,"startColumn":5,"startLine":2}}}],"message":{"text":"Redefinition
 of 
'foo'"},"ruleId":"clang.unittest","ruleIndex":0}],"tool":{"driver":{"fullName":"sarif
 test 
runner","informationUri":"https://clang.llvm.org/docs/UsersManual.html","language":"en-US","name":"sarif
 
test","rules":[{"defaultConfiguration":{"enabled":true,"level":"warning","rank":-1},"fullDescription":{"text":"Example
 rule created during unit tests"},"id":"clang.unittest","name":"clang unit 
test"}],"version":"1.0.0"}}}],"version":"2.1.0"})";
+  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts"

[clang] 37eb9d1 - Revert "[Support] change StringMap hash function from djbHash to xxHash"

2023-02-08 Thread Erik Desjardins via cfe-commits

Author: Erik Desjardins
Date: 2023-02-08T10:41:51-05:00
New Revision: 37eb9d13f891f7656f811516e765b929b169afe0

URL: 
https://github.com/llvm/llvm-project/commit/37eb9d13f891f7656f811516e765b929b169afe0
DIFF: 
https://github.com/llvm/llvm-project/commit/37eb9d13f891f7656f811516e765b929b169afe0.diff

LOG: Revert "[Support] change StringMap hash function from djbHash to xxHash"

This reverts commit d768b97424f9e1a0aae45440a18b99f21c4027ce.

Causes sanitizer failure: 
https://lab.llvm.org/buildbot/#/builders/238/builds/1114

```
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Support/xxhash.cpp:107:12:
 runtime error: applying non-zero offset 8 to null pointer
#0 0xb28ec6c8 in llvm::xxHash64(llvm::StringRef) 
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Support/xxhash.cpp:107:12
#1 0xb28cbd38 in llvm::StringMapImpl::LookupBucketFor(llvm::StringRef) 
/b/sanitizer-aarch64-linux-bootstrap-ubsan/build/llvm-project/llvm/lib/Support/StringMap.cpp:87:28
```

Probably causes test failure in 
`warn-unsafe-buffer-usage-fixits-local-var-span.cpp`: 
https://lab.llvm.org/buildbot/#/builders/60/builds/10619

Probably causes reverse-iteration test failure in `test-output-format.ll`: 
https://lab.llvm.org/buildbot/#/builders/54/builds/3545

Added: 


Modified: 
clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
clang/unittests/Basic/SarifTest.cpp
compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
llvm/lib/Support/StringMap.cpp
llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
llvm/test/DebugInfo/X86/gnu-public-names.ll
llvm/test/tools/dsymutil/ARM/extern-alias.test
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
mlir/test/mlir-lsp-server/completion.test

Removed: 




diff  --git a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize 
b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
index afe1ece5eec08..31be95c6b6b3c 100644
--- a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
+++ b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
@@ -12,5 +12,5 @@
 
 # CHECK: These are the combined files, with problem files preceded by #:
 
-# CHECK: Inputs/CompileError/Level1A.h
 # CHECK: {{.*}}Inputs/CompileError/HasError.h
+# CHECK: Inputs/CompileError/Level1A.h

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 33bccf56babb7..06ad4e7a63091 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -332,7 +332,7 @@ TEST_F(SarifDocumentWriterTest, checkSerializingArtifacts) {
 TEST_F(SarifDocumentWriterTest, checkSerializingCodeflows) {
   // GIVEN:
   const std::string ExpectedOutput =
-  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts":[{"length":28,"location":{"index":3,"uri":"file:///test-header-3.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":41,"location":{"index":0,"uri":"file:///main.cpp"},"mimeType":"text/plain","roles":["resultFile"]},{"length":30,"location":{"index":2,"uri":"file:///test-header-2.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":27,"location":{"index":1,"uri":"file:///test-header-1.h"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"codeFlows":[{"threadFlows":[{"locations":[{"importance":"essential","location":{"message":{"text":"Message
 
#1"},"physicalLocation":{"artifactLocation":{"index":1,"uri":"file:///test-header-1.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"important","location":{"message":{"text":"Message
 
#2"},"physicalLocation":{"artifactLocation":{"index":2,"uri":"file:///test-header-2.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"unimportant","location":{"message":{"text":"Message
 
#3"},"physicalLocation":{"artifactLocation":{"index":3,"uri":"file:///test-header-3.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1]}]}],"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"index":0,"uri":"file:///main.cpp"},"region":{"endColumn":8,"endLine":2,"startColumn":5,"startLine":2}}}],"message":{"text":"Redefinition
 of 
'foo'"},"ruleId":"clang.unittest","ruleIndex":0}],"tool":{"driver":{"fullName":"sarif
 test 
runner","informationUri":"https://clang.llvm.org/docs/UsersManual.html","language":"en-US","name":"sarif
 
test","rules":[{"defaultConfiguration":{"enabled":true,"level":"warning","rank":-1},"ful

[clang-tools-extra] 87d02e0 - Recommit "[Support] change StringMap hash function from djbHash to xxHash"

2023-02-19 Thread Erik Desjardins via cfe-commits

Author: Erik Desjardins
Date: 2023-02-19T16:52:26-05:00
New Revision: 87d02e0dfd760de38d092ef69f8a9164f28f2221

URL: 
https://github.com/llvm/llvm-project/commit/87d02e0dfd760de38d092ef69f8a9164f28f2221
DIFF: 
https://github.com/llvm/llvm-project/commit/87d02e0dfd760de38d092ef69f8a9164f28f2221.diff

LOG: Recommit "[Support] change StringMap hash function from djbHash to xxHash"

This reverts commit 37eb9d13f891f7656f811516e765b929b169afe0.

Test failures have been fixed:

- ubsan failure fixed by 72eac42f21c0f45a27f3eaaff9364cbb5189b9e4
- warn-unsafe-buffer-usage-fixits-local-var-span.cpp fixed by
  03cc52dfd1dbb4a59b479da55e87838fb93d2067 (wasn't related)
- test-output-format.ll failure was spurious, build failed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3545 
(b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93)
  but passed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3546 
(5ae99be0377248c74346096dc475af254a3fc799)
  which is before my revert
  
https://github.com/llvm/llvm-project/compare/b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93...5ae99be0377248c74346096dc475af254a3fc799

Original commit message:

Depends on https://reviews.llvm.org/D142861.

Alternative to https://reviews.llvm.org/D137601.

xxHash is much faster than djbHash. This makes a simple Rust test case with 
a large constant string 10% faster to compile.

Previous attempts at changing this hash function (e.g. 
https://reviews.llvm.org/D97396) had to be reverted due to breaking tests that 
depended on iteration order.
No additional tests fail with this patch compared to `main` when running 
`check-all` with `-DLLVM_ENABLE_PROJECTS="all"` (on a Linux host), so I hope I 
found everything that needs to be changed.

Differential Revision: https://reviews.llvm.org/D142862

Added: 


Modified: 
clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
clang/unittests/Basic/SarifTest.cpp
compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
llvm/lib/Support/StringMap.cpp
llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
llvm/test/DebugInfo/X86/gnu-public-names.ll
llvm/test/tools/dsymutil/ARM/extern-alias.test
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
mlir/test/mlir-lsp-server/completion.test

Removed: 




diff  --git a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize 
b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
index 31be95c6b6b3c..afe1ece5eec08 100644
--- a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
+++ b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
@@ -12,5 +12,5 @@
 
 # CHECK: These are the combined files, with problem files preceded by #:
 
-# CHECK: {{.*}}Inputs/CompileError/HasError.h
 # CHECK: Inputs/CompileError/Level1A.h
+# CHECK: {{.*}}Inputs/CompileError/HasError.h

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 06ad4e7a63091..33bccf56babb7 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -332,7 +332,7 @@ TEST_F(SarifDocumentWriterTest, checkSerializingArtifacts) {
 TEST_F(SarifDocumentWriterTest, checkSerializingCodeflows) {
   // GIVEN:
   const std::string ExpectedOutput =
-  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts":[{"length":27,"location":{"index":1,"uri":"file:///test-header-1.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":30,"location":{"index":2,"uri":"file:///test-header-2.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":28,"location":{"index":3,"uri":"file:///test-header-3.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":41,"location":{"index":0,"uri":"file:///main.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"codeFlows":[{"threadFlows":[{"locations":[{"importance":"essential","location":{"message":{"text":"Message
 
#1"},"physicalLocation":{"artifactLocation":{"index":1,"uri":"file:///test-header-1.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"important","location":{"message":{"text":"Message
 
#2"},"physicalLocation":{"artifactLocation":{"index":2,"uri":"file:///test-header-2.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"unimportant","location":{"message":{"text":"Message
 
#3"},"physicalLocation":{"artifactLocation":{"index":3,"uri":"file:///test-header-3.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1]}]}],"lev

[clang] 87d02e0 - Recommit "[Support] change StringMap hash function from djbHash to xxHash"

2023-02-19 Thread Erik Desjardins via cfe-commits

Author: Erik Desjardins
Date: 2023-02-19T16:52:26-05:00
New Revision: 87d02e0dfd760de38d092ef69f8a9164f28f2221

URL: 
https://github.com/llvm/llvm-project/commit/87d02e0dfd760de38d092ef69f8a9164f28f2221
DIFF: 
https://github.com/llvm/llvm-project/commit/87d02e0dfd760de38d092ef69f8a9164f28f2221.diff

LOG: Recommit "[Support] change StringMap hash function from djbHash to xxHash"

This reverts commit 37eb9d13f891f7656f811516e765b929b169afe0.

Test failures have been fixed:

- ubsan failure fixed by 72eac42f21c0f45a27f3eaaff9364cbb5189b9e4
- warn-unsafe-buffer-usage-fixits-local-var-span.cpp fixed by
  03cc52dfd1dbb4a59b479da55e87838fb93d2067 (wasn't related)
- test-output-format.ll failure was spurious, build failed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3545 
(b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93)
  but passed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3546 
(5ae99be0377248c74346096dc475af254a3fc799)
  which is before my revert
  
https://github.com/llvm/llvm-project/compare/b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93...5ae99be0377248c74346096dc475af254a3fc799

Original commit message:

Depends on https://reviews.llvm.org/D142861.

Alternative to https://reviews.llvm.org/D137601.

xxHash is much faster than djbHash. This makes a simple Rust test case with 
a large constant string 10% faster to compile.

Previous attempts at changing this hash function (e.g. 
https://reviews.llvm.org/D97396) had to be reverted due to breaking tests that 
depended on iteration order.
No additional tests fail with this patch compared to `main` when running 
`check-all` with `-DLLVM_ENABLE_PROJECTS="all"` (on a Linux host), so I hope I 
found everything that needs to be changed.

Differential Revision: https://reviews.llvm.org/D142862

Added: 


Modified: 
clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
clang/unittests/Basic/SarifTest.cpp
compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
llvm/lib/Support/StringMap.cpp
llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
llvm/test/DebugInfo/X86/gnu-public-names.ll
llvm/test/tools/dsymutil/ARM/extern-alias.test
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
mlir/test/mlir-lsp-server/completion.test

Removed: 




diff  --git a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize 
b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
index 31be95c6b6b3c..afe1ece5eec08 100644
--- a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
+++ b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
@@ -12,5 +12,5 @@
 
 # CHECK: These are the combined files, with problem files preceded by #:
 
-# CHECK: {{.*}}Inputs/CompileError/HasError.h
 # CHECK: Inputs/CompileError/Level1A.h
+# CHECK: {{.*}}Inputs/CompileError/HasError.h

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 06ad4e7a63091..33bccf56babb7 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -332,7 +332,7 @@ TEST_F(SarifDocumentWriterTest, checkSerializingArtifacts) {
 TEST_F(SarifDocumentWriterTest, checkSerializingCodeflows) {
   // GIVEN:
   const std::string ExpectedOutput =
-  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts":[{"length":27,"location":{"index":1,"uri":"file:///test-header-1.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":30,"location":{"index":2,"uri":"file:///test-header-2.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":28,"location":{"index":3,"uri":"file:///test-header-3.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":41,"location":{"index":0,"uri":"file:///main.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"codeFlows":[{"threadFlows":[{"locations":[{"importance":"essential","location":{"message":{"text":"Message
 
#1"},"physicalLocation":{"artifactLocation":{"index":1,"uri":"file:///test-header-1.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"important","location":{"message":{"text":"Message
 
#2"},"physicalLocation":{"artifactLocation":{"index":2,"uri":"file:///test-header-2.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"unimportant","location":{"message":{"text":"Message
 
#3"},"physicalLocation":{"artifactLocation":{"index":3,"uri":"file:///test-header-3.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1]}]}],"lev