[llvm] [msan] Eliminate non-deterministic behavior in the pass (PR #89831)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 14:17:08 PDT 2024


================
@@ -1464,19 +1465,20 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
   }
 
   void materializeChecks() {
-    llvm::stable_sort(InstrumentationList,
-                      [](const ShadowOriginAndInsertPoint &L,
-                         const ShadowOriginAndInsertPoint &R) {
-                        return L.OrigIns < R.OrigIns;
-                      });
+#ifndef NDEBUG
+    SmallPtrSet<Instruction *, 16> Done;
+#endif
 
     for (auto I = InstrumentationList.begin();
          I != InstrumentationList.end();) {
-      auto J =
-          std::find_if(I + 1, InstrumentationList.end(),
-                       [L = I->OrigIns](const ShadowOriginAndInsertPoint &R) {
-                         return L != R.OrigIns;
-                       });
+      auto OrigIns = I->OrigIns;
+      // Checks are grouped by the original instruction. We call all
+      // `insertShadowCheck` for an instruction atonce.
----------------
fmayer wrote:

nit "atonce"

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


More information about the llvm-commits mailing list