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

Oleg Shyshkov llvmlistbot at llvm.org
Mon May 13 05:07:55 PDT 2024


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

>From 15d8c1647850f479230858fa9208c66137e10006 Mon Sep 17 00:00:00 2001
From: Oleg Shyshkov <shyshkov.oleg at gmail.com>
Date: Mon, 13 May 2024 11:51:48 +0000
Subject: [PATCH] [OpenMP][MLIR] Fix llvm::sort comparator.

llvm::sort requres the comparator to return `false` for equal elements, otherwise it triggers `Your comparator is not a valid strict-weak ordering` assert.
---
 .../LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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>(



More information about the Mlir-commits mailing list