[PATCH] D112950: [OpenMP] Fix some non-determinism causing test failures in reverse iterator builds

Usman Nadeem via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 1 12:28:03 PDT 2021


mnadeem created this revision.
mnadeem added a project: OpenMP.
Herald added subscribers: ormris, mgrang, guansong, hiraditya, yaxunl.
mnadeem requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.

The tests custom_state_machines_remarks.ll and spmdization_remarks.ll fail with
reverse iterator builds due to non-determinism in the iteration order. This patch tries to fix it.

Change `KernelSet` from `SmallPtrSet` to `SmallSetVector` so that the order of
iteration of kernels in OpenMPOpt::registerAAs() is the same as the order of insertion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112950

Files:
  llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp


Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -167,7 +167,7 @@
 struct OMPInformationCache : public InformationCache {
   OMPInformationCache(Module &M, AnalysisGetter &AG,
                       BumpPtrAllocator &Allocator, SetVector<Function *> &CGSCC,
-                      SmallPtrSetImpl<Kernel> &Kernels)
+                      KernelSet &Kernels)
       : InformationCache(M, AG, Allocator, &CGSCC), OMPBuilder(M),
         Kernels(Kernels) {
 
@@ -482,7 +482,7 @@
   }
 
   /// Collection of known kernels (\see Kernel) in the module.
-  SmallPtrSetImpl<Kernel> &Kernels;
+  KernelSet &Kernels;
 
   /// Collection of known OpenMP runtime functions..
   DenseSet<const Function *> RTLFunctions;
Index: llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
+++ llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
@@ -21,7 +21,7 @@
 using Kernel = Function *;
 
 /// Set of kernels in the module
-using KernelSet = SmallPtrSet<Kernel, 4>;
+using KernelSet = SmallSetVector<Kernel, 4>;
 
 /// Helper to determine if \p M contains OpenMP.
 bool containsOpenMP(Module &M);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112950.383854.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211101/70f35055/attachment.bin>


More information about the llvm-commits mailing list