Skip to content

[AMDGPU] Fix non-determinism in DenseSet #66617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Conversation

dstutt
Copy link
Collaborator

@dstutt dstutt commented Sep 18, 2023

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

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

llvmbot commented Sep 18, 2023

@llvm/pr-subscribers-backend-amdgpu

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/66617.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp (+2-2)
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);
           }

Copy link
Contributor

@jayfoad jayfoad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine thanks. I suggest changing the title to something like "Fix non-deterministic iteration order in SIFixSGPRCopies" since you're not fixinf anything in DenseSet itself.

@dstutt dstutt merged commit ce031fc into llvm:main Sep 18, 2023
@dstutt dstutt deleted the llvm-schain-nondet branch September 18, 2023 09:09
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this pull request Sep 19, 2023
…vm#66617)

Use of DenseSet was causing some non-deteminism in SIFixSGPRSopies. Changing
to SetVector fixes the problem.
zahiraam pushed a commit to tahonermann/llvm-project that referenced this pull request Oct 24, 2023
…vm#66617)

Use of DenseSet was causing some non-deteminism in SIFixSGPRSopies. Changing
to SetVector fixes the problem.
zahiraam pushed a commit to tahonermann/llvm-project that referenced this pull request Oct 24, 2023
…vm#66617)

Use of DenseSet was causing some non-deteminism in SIFixSGPRSopies. Changing
to SetVector fixes the problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants