[Mlir-commits] [mlir] [OpenMP][MLIR] Fix llvm::sort comparator. (PR #91947)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon May 13 04:56:47 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-llvm

Author: Oleg Shyshkov (olegshyshkov)

<details>
<summary>Changes</summary>

llvm::sort requires the comparator to return `false` for equal elements, otherwise it triggers `Your comparator is not a valid strict-weak ordering` assert.

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


1 Files Affected:

- (modified) mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp (+4-4) 


``````````diff
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index 0c34126667324..282e640d3aaad 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -2175,10 +2175,10 @@ getFirstOrLastMappedMemberPtr(mlir::omp::MapInfoOp mapInfo, bool first) {
             return !first;
         }
 
-        // iterated the entire list and couldn't make a decision, all elements
-        // were likely the same, return true for now similar to reaching the end
-        // of both and finding invalid indices.
-        return true;
+        // Iterated the entire list and couldn't make a decision, all elements
+        // were likely the same. Return false, since the sort comparator should
+        // return false for equal elements.
+        return false;
       });
 
     return llvm::cast<mlir::omp::MapInfoOp>(

``````````

</details>


https://github.com/llvm/llvm-project/pull/91947


More information about the Mlir-commits mailing list