[llvm] cb5d6a5 - [llvm][ADT] Fix Arm 32 bit compilation warning in lazy atomic pointer

David Spickett via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 08:25:30 PDT 2024


Author: David Spickett
Date: 2024-05-02T15:22:01Z
New Revision: cb5d6a5639ab17933f127456cee9167fb0ed6439

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

LOG: [llvm][ADT] Fix Arm 32 bit compilation warning in lazy atomic pointer

LazyAtomicPointer.h:36:49: warning: implicit conversion from 'unsigned long long'
to 'uintptr_t' (aka 'unsigned int') changes value from 18446744073709551615 to 4294967295 [-Wconstant-conversion]
  static constexpr uintptr_t getBusy() { return -1ULL; }

On 32 bit Arm ULL is an unsigned long long which is 8 bytes, but
uintptr_t is 4 bytes. Instead of using a value, use the macro
UINTPTR_MAX that will be the correctly sized value.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/LazyAtomicPointer.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/LazyAtomicPointer.h b/llvm/include/llvm/ADT/LazyAtomicPointer.h
index 890584746220d8..c4fd38963449c7 100644
--- a/llvm/include/llvm/ADT/LazyAtomicPointer.h
+++ b/llvm/include/llvm/ADT/LazyAtomicPointer.h
@@ -33,7 +33,7 @@ namespace llvm {
 /// std::atomic<T>::notify_all() in \a loadOrGenerate().
 template <class T> class LazyAtomicPointer {
   static constexpr uintptr_t getNull() { return 0; }
-  static constexpr uintptr_t getBusy() { return -1ULL; }
+  static constexpr uintptr_t getBusy() { return UINTPTR_MAX; }
 
   static T *makePointer(uintptr_t Value) {
     assert(Value != getBusy());


        


More information about the llvm-commits mailing list