[PATCH] D76259: Use more LLVM_ENABLE_ABI_BREAKING_CHECKS in Error.h

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 16 16:24:32 PDT 2020


aaronpuchert created this revision.
aaronpuchert added reviewers: lhames, mehdi_amini.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76259

Files:
  llvm/include/llvm/Support/Error.h


Index: llvm/include/llvm/Support/Error.h
===================================================================
--- llvm/include/llvm/Support/Error.h
+++ llvm/include/llvm/Support/Error.h
@@ -269,9 +269,13 @@
   }
 
   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 @@
   }
 
   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() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76259.250646.patch
Type: text/x-patch
Size: 858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200316/d54b78a8/attachment.bin>


More information about the llvm-commits mailing list