[llvm] b96b933 - Use more LLVM_ENABLE_ABI_BREAKING_CHECKS in Error.h
    Aaron Puchert via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Apr 11 12:16:59 PDT 2020
    
    
  
Author: Aaron Puchert
Date: 2020-04-11T21:14:18+02:00
New Revision: b96b9335aea5fc9092cb4ec7df9152ff9b9db3dc
URL: https://github.com/llvm/llvm-project/commit/b96b9335aea5fc9092cb4ec7df9152ff9b9db3dc
DIFF: https://github.com/llvm/llvm-project/commit/b96b9335aea5fc9092cb4ec7df9152ff9b9db3dc.diff
LOG: Use more LLVM_ENABLE_ABI_BREAKING_CHECKS in Error.h
Summary:
If we don't read the flag, we don't need to set it. Then we also don't
need to filter it out to get the pointer.
This should have a (small) positive impact on code size and performance.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D76259
Added: 
    
Modified: 
    llvm/include/llvm/Support/Error.h
Removed: 
    
################################################################################
diff  --git a/llvm/include/llvm/Support/Error.h b/llvm/include/llvm/Support/Error.h
index f1e3059368d5..b29a247ff8ce 100644
--- a/llvm/include/llvm/Support/Error.h
+++ b/llvm/include/llvm/Support/Error.h
@@ -269,9 +269,13 @@ class LLVM_NODISCARD Error {
   }
 
   ErrorInfoBase *getPtr() const {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
     return reinterpret_cast<ErrorInfoBase*>(
              reinterpret_cast<uintptr_t>(Payload) &
              ~static_cast<uintptr_t>(0x1));
+#else
+    return Payload;
+#endif
   }
 
   void setPtr(ErrorInfoBase *EI) {
@@ -294,10 +298,12 @@ class LLVM_NODISCARD Error {
   }
 
   void setChecked(bool V) {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
     Payload = reinterpret_cast<ErrorInfoBase*>(
                 (reinterpret_cast<uintptr_t>(Payload) &
                   ~static_cast<uintptr_t>(0x1)) |
                   (V ? 0 : 1));
+#endif
   }
 
   std::unique_ptr<ErrorInfoBase> takePayload() {
        
    
    
More information about the llvm-commits
mailing list