diff --git a/Src/ILGPU/Backends/OpenCL/CLCodeGenerator.cs b/Src/ILGPU/Backends/OpenCL/CLCodeGenerator.cs index 3d758ec6af..5f0ebe604e 100644 --- a/Src/ILGPU/Backends/OpenCL/CLCodeGenerator.cs +++ b/Src/ILGPU/Backends/OpenCL/CLCodeGenerator.cs @@ -199,7 +199,7 @@ protected static string GetParameterName(Parameter parameter) => private int labelCounter; private readonly Dictionary blockLookup = - new Dictionary(); + new Dictionary(new BasicBlock.Comparer()); private readonly string labelPrefix; private StringBuilder prefixBuilder = new StringBuilder(); @@ -439,7 +439,8 @@ protected void GenerateCodeInternal() blockLookup.Add(block, DeclareLabel()); // Find all phi nodes, allocate target registers and setup internal mapping - var phiMapping = new Dictionary>(); + var phiMapping = new Dictionary>( + new BasicBlock.Comparer()); var dominators = Method.Blocks.CreateDominators(); var phiBindings = PhiBindings.Create( blocks, diff --git a/Src/ILGPU/Backends/PTX/PTXCodeGenerator.cs b/Src/ILGPU/Backends/PTX/PTXCodeGenerator.cs index 1c304b348c..afc75f9b7d 100644 --- a/Src/ILGPU/Backends/PTX/PTXCodeGenerator.cs +++ b/Src/ILGPU/Backends/PTX/PTXCodeGenerator.cs @@ -286,7 +286,8 @@ protected static string GetParameterName(Parameter parameter) => #region Instance private int labelCounter; - private readonly Dictionary blockLookup = new(); + private readonly Dictionary blockLookup = new( + new BasicBlock.Comparer()); private readonly Dictionary<(Encoding, string), string> stringConstants = new(); private readonly PhiBindings phiBindings; diff --git a/Src/ILGPU/Backends/Velocity/VelocityCodeGenerator.cs b/Src/ILGPU/Backends/Velocity/VelocityCodeGenerator.cs index 382d419baf..7afd486857 100644 --- a/Src/ILGPU/Backends/Velocity/VelocityCodeGenerator.cs +++ b/Src/ILGPU/Backends/Velocity/VelocityCodeGenerator.cs @@ -96,7 +96,8 @@ public readonly record struct GeneratorArgs( /// /// Maps blocks to labels. /// - private readonly Dictionary blockLookup = new(); + private readonly Dictionary blockLookup = + new(new BasicBlock.Comparer()); /// /// The masks analysis holding information about the masks being required. diff --git a/Src/ILGPU/Frontend/Block.CFGBuilder.cs b/Src/ILGPU/Frontend/Block.CFGBuilder.cs index a293f40c47..bba6f94655 100644 --- a/Src/ILGPU/Frontend/Block.CFGBuilder.cs +++ b/Src/ILGPU/Frontend/Block.CFGBuilder.cs @@ -71,7 +71,7 @@ public readonly void Apply(ILInstruction instruction, int offset) => private readonly Dictionary blockMapping = new Dictionary(); private readonly Dictionary basicBlockMapping = - new Dictionary(); + new Dictionary(new BasicBlock.Comparer()); private readonly Dictionary> successorMapping = new Dictionary>(); diff --git a/Src/ILGPU/IR/Analyses/Loops.cs b/Src/ILGPU/IR/Analyses/Loops.cs index 6aca12db09..c1484c9227 100644 --- a/Src/ILGPU/IR/Analyses/Loops.cs +++ b/Src/ILGPU/IR/Analyses/Loops.cs @@ -757,8 +757,8 @@ private void RegisterLoop( // Initialize all lists and sets var headers = InlineList.Create(2); var breakers = InlineList.Create(2); - var entryBlocks = new HashSet(); - var exitBlocks = new HashSet(); + var entryBlocks = new HashSet(new BasicBlock.Comparer()); + var exitBlocks = new HashSet(new BasicBlock.Comparer()); // Gather all loop entries and exists foreach (var member in members) diff --git a/Src/ILGPU/IR/BasicBlockCollection.cs b/Src/ILGPU/IR/BasicBlockCollection.cs index b0737f0a47..d4fccf22ef 100644 --- a/Src/ILGPU/IR/BasicBlockCollection.cs +++ b/Src/ILGPU/IR/BasicBlockCollection.cs @@ -339,7 +339,7 @@ public readonly HashSet ToSet() => public readonly HashSet ToSet(TPredicate predicate) where TPredicate : InlineList.IPredicate { - var result = new HashSet(); + var result = new HashSet(new BasicBlock.Comparer()); foreach (var block in this) { if (predicate.Apply(block)) diff --git a/Src/ILGPU/IR/BasicBlockMapping.cs b/Src/ILGPU/IR/BasicBlockMapping.cs index d34e5ce0f5..f78fe86bb1 100644 --- a/Src/ILGPU/IR/BasicBlockMapping.cs +++ b/Src/ILGPU/IR/BasicBlockMapping.cs @@ -746,7 +746,7 @@ partial struct BasicBlockSet /// [MemberNotNull(nameof(blockSet))] - partial void InitBlockSet() => blockSet = new HashSet(); + partial void InitBlockSet() => blockSet = new(new BasicBlock.Comparer()); #endregion @@ -785,7 +785,8 @@ partial struct BasicBlockMap /// [MemberNotNull(nameof(blockMap))] - partial void InitBlockMap() => blockMap = new Dictionary(); + partial void InitBlockMap() => blockMap = + new Dictionary(new BasicBlock.Comparer()); #endregion diff --git a/Src/ILGPU/IR/Verifier.cs b/Src/ILGPU/IR/Verifier.cs index 7cf7d2bf5a..6b1bdc662e 100644 --- a/Src/ILGPU/IR/Verifier.cs +++ b/Src/ILGPU/IR/Verifier.cs @@ -184,11 +184,11 @@ private sealed class ControlFlowVerifier : VerifierBase private readonly List blocksInRpo = new List(); private readonly HashSet containedBlocks = - new HashSet(); + new(new BasicBlock.Comparer()); private readonly Dictionary> predecessors = - new Dictionary>(); + new(new BasicBlock.Comparer()); private readonly Dictionary> successors = - new Dictionary>(); + new(new BasicBlock.Comparer()); /// /// Constructs a new control-flow verifier. @@ -210,9 +210,9 @@ public ControlFlowVerifier(Method method, VerificationResult result) private void CreateLinkSets(BasicBlock block) { if (!predecessors.ContainsKey(block)) - predecessors.Add(block, new HashSet()); + predecessors.Add(block, new(new BasicBlock.Comparer())); if (!successors.ContainsKey(block)) - successors.Add(block, new HashSet()); + successors.Add(block, new(new BasicBlock.Comparer())); } /// @@ -325,7 +325,7 @@ private sealed class ValueVerifier : VerifierBase private readonly HashSet values = new HashSet(); private readonly Dictionary> mapping = - new Dictionary>(); + new Dictionary>(new BasicBlock.Comparer()); /// /// Constructs a new value verifier. @@ -465,7 +465,7 @@ private void VerifyPhis() => phiValue.BasicBlock.Predecessors.Length); // Verify nodes and sources - var visited = new HashSet(); + var visited = new HashSet(new BasicBlock.Comparer()); for (int i = 0, e = phiValue.Nodes.Length; i < e; ++i) { Value value = phiValue.Nodes[i];