[PATCH] D155789: [Support] Implement LLVM_ENABLE_REVERSE_ITERATION for StringMap
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 08:47:01 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9996e71f2d73: [Support] Implement LLVM_ENABLE_REVERSE_ITERATION for StringMap (authored by MaskRay).
Changed prior to commit:
https://reviews.llvm.org/D155789?vs=542334&id=542952#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155789/new/
https://reviews.llvm.org/D155789
Files:
llvm/lib/Support/StringMap.cpp
llvm/test/CMakeLists.txt
llvm/test/CodeGen/MIR/AMDGPU/virtreg-uses-unallocatable-class.mir
llvm/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s
llvm/test/TableGen/GlobalISelCombinerMatchTableEmitter/pattern-parsing.td
llvm/test/lit.site.cfg.py.in
llvm/utils/lit/lit/llvm/config.py
Index: llvm/utils/lit/lit/llvm/config.py
===================================================================
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -120,6 +120,9 @@
if have_zstd:
features.add("zstd")
+ if getattr(config, "reverse_iteration", None):
+ features.add("reverse_iteration")
+
# Check if we should run long running tests.
long_tests = lit_config.params.get("run_long_tests", None)
if lit.util.pythonize_bool(long_tests):
Index: llvm/test/lit.site.cfg.py.in
===================================================================
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -58,6 +58,7 @@
config.llvm_inliner_model_autogenerated = @LLVM_INLINER_MODEL_AUTOGENERATED@
config.llvm_raevict_model_autogenerated = @LLVM_RAEVICT_MODEL_AUTOGENERATED@
config.expensive_checks = @LLVM_ENABLE_EXPENSIVE_CHECKS@
+config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
config.dxil_tests = @LLVM_INCLUDE_DXIL_TESTS@
config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
Index: llvm/test/TableGen/GlobalISelCombinerMatchTableEmitter/pattern-parsing.td
===================================================================
--- llvm/test/TableGen/GlobalISelCombinerMatchTableEmitter/pattern-parsing.td
+++ llvm/test/TableGen/GlobalISelCombinerMatchTableEmitter/pattern-parsing.td
@@ -1,3 +1,4 @@
+// UNSUPPORTED: reverse_iteration
// RUN: llvm-tblgen -I %p/../../../include -gen-global-isel-combiner-matchtable \
// RUN: -gicombiner-stop-after-parse -combiners=MyCombiner %s | \
// RUN: FileCheck %s
Index: llvm/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s
===================================================================
--- llvm/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s
+++ llvm/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s
@@ -1,3 +1,4 @@
+# UNSUPPORTED: reverse_iteration
# RUN: rm -rf %t && mkdir -p %t
# RUN: llvm-mc -triple=armv7s-apple-ios7.0.0 -filetype=obj -o %t/foo.o %s
# RUN: llvm-rtdyld -triple=armv7s-apple-ios7.0.0 -verify -check=%s %t/foo.o
Index: llvm/test/CodeGen/MIR/AMDGPU/virtreg-uses-unallocatable-class.mir
===================================================================
--- llvm/test/CodeGen/MIR/AMDGPU/virtreg-uses-unallocatable-class.mir
+++ llvm/test/CodeGen/MIR/AMDGPU/virtreg-uses-unallocatable-class.mir
@@ -1,3 +1,4 @@
+# UNSUPPORTED: reverse_iteration
# RUN: not llc -mtriple=amdgcn-- -mcpu=gfx900 -run-pass=none -o - %s 2>&1 | FileCheck %s
# Check a diagnostic is emitted if non-allocatable classes are used
Index: llvm/test/CMakeLists.txt
===================================================================
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -22,6 +22,7 @@
LLVM_INLINER_MODEL_AUTOGENERATED
LLVM_RAEVICT_MODEL_AUTOGENERATED
LLVM_ENABLE_EXPENSIVE_CHECKS
+ LLVM_ENABLE_REVERSE_ITERATION
LLVM_INCLUDE_DXIL_TESTS
LLVM_TOOL_LLVM_DRIVER_BUILD
)
Index: llvm/lib/Support/StringMap.cpp
===================================================================
--- llvm/lib/Support/StringMap.cpp
+++ llvm/lib/Support/StringMap.cpp
@@ -12,6 +12,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/ReverseIteration.h"
#include "llvm/Support/xxhash.h"
using namespace llvm;
@@ -85,6 +86,8 @@
if (NumBuckets == 0)
init(16);
unsigned FullHashValue = xxHash64(Name);
+ if (shouldReverseIterate())
+ FullHashValue = ~FullHashValue;
unsigned BucketNo = FullHashValue & (NumBuckets - 1);
unsigned *HashTable = getHashTable(TheTable, NumBuckets);
@@ -140,6 +143,8 @@
if (NumBuckets == 0)
return -1; // Really empty table?
unsigned FullHashValue = xxHash64(Key);
+ if (shouldReverseIterate())
+ FullHashValue = ~FullHashValue;
unsigned BucketNo = FullHashValue & (NumBuckets - 1);
unsigned *HashTable = getHashTable(TheTable, NumBuckets);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155789.542952.patch
Type: text/x-patch
Size: 4009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230721/6591101f/attachment.bin>
More information about the llvm-commits
mailing list