[compiler-rt] a8938f3 - scudo: Simplify AtomicOptions::setFillContentsMode. NFCI.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 10:52:56 PDT 2020


Author: Peter Collingbourne
Date: 2020-10-02T10:52:41-07:00
New Revision: a8938f3da319f4cc17b80ebab582a6c77efa6705

URL: https://github.com/llvm/llvm-project/commit/a8938f3da319f4cc17b80ebab582a6c77efa6705
DIFF: https://github.com/llvm/llvm-project/commit/a8938f3da319f4cc17b80ebab582a6c77efa6705.diff

LOG: scudo: Simplify AtomicOptions::setFillContentsMode. NFCI.

Differential Revision: https://reviews.llvm.org/D88747

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/options.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/options.h b/compiler-rt/lib/scudo/standalone/options.h
index 4f387a37f482..3051e8af4f7a 100644
--- a/compiler-rt/lib/scudo/standalone/options.h
+++ b/compiler-rt/lib/scudo/standalone/options.h
@@ -54,16 +54,14 @@ struct AtomicOptions {
   }
 
   void setFillContentsMode(FillContentsMode FillContents) {
-    while (1) {
-      u32 Opts = atomic_load(&Val, memory_order_relaxed);
-      u32 NewOpts = Opts;
+    u32 Opts = atomic_load(&Val, memory_order_relaxed), NewOpts;
+    do {
+      NewOpts = Opts;
       NewOpts &= ~(3U << static_cast<u32>(OptionBit::FillContents0of2));
       NewOpts |= static_cast<u32>(FillContents)
                  << static_cast<u32>(OptionBit::FillContents0of2);
-      if (atomic_compare_exchange_strong(&Val, &Opts, NewOpts,
-                                         memory_order_relaxed))
-        break;
-    }
+    } while (!atomic_compare_exchange_strong(&Val, &Opts, NewOpts,
+                                             memory_order_relaxed));
   }
 };
 


        


More information about the llvm-commits mailing list