[llvm] [AMDGPU] Fix non-determinism in DenseSet (PR #66617)

David Stuttard via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 01:01:14 PDT 2023


https://github.com/dstutt created https://github.com/llvm/llvm-project/pull/66617

Use of DenseSet was causing some non-deteminism in compiles. Changing over to
using SetVector fixes the problem.


>From d69f9d8dccccdc146b0bf678a69db641a1fbb674 Mon Sep 17 00:00:00 2001
From: David Stuttard <david.stuttard at amd.com>
Date: Wed, 13 Sep 2023 14:17:16 +0100
Subject: [PATCH] [AMDGPU] Fix non-determinism in DenseSet

Use of DenseSet was causing some non-deteminism in compiles. Changing over to
using SetVector fixes the problem.
---
 llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
index 32da233fe4d8896..2216acf128bfa56 100644
--- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
@@ -88,7 +88,7 @@ class V2SCopyInfo {
   // VGPR to SGPR copy being processed
   MachineInstr *Copy;
   // All SALU instructions reachable from this copy in SSA graph
-  DenseSet<MachineInstr *> SChain;
+  SetVector<MachineInstr *> SChain;
   // Number of SGPR to VGPR copies that are used to put the SALU computation
   // results back to VALU.
   unsigned NumSVCopies;
@@ -1009,7 +1009,7 @@ void SIFixSGPRCopies::lowerVGPR2SGPRCopies(MachineFunction &MF) {
           V2SCopyInfo &SI = SibInfoIt->getSecond();
           LLVM_DEBUG(dbgs() << "Sibling:\n"; SI.dump());
           if (!SI.NeedToBeConvertedToVALU) {
-            set_subtract(SI.SChain, C.SChain);
+            SI.SChain.set_subtract(C.SChain);
             if (needToBeConvertedToVALU(&SI))
               LoweringWorklist.push_back(SI.ID);
           }



More information about the llvm-commits mailing list