[PATCH] D142584: [CodeGen] Add a boolean flag to `Address::getPointer` and `Lvalue::getPointer` that indicates whether the pointer is known not to be null

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 7 14:28:05 PST 2023


efriedma added a comment.

The approach here makes sense.



================
Comment at: clang/lib/CodeGen/Address.h:65
       : Pointer(Pointer), ElementType(ElementType) {
     if (Alignment.isZero())
       return;
----------------
Do you need to do something with IsKnownNonNull in the `Alignment.isZero()` case?


================
Comment at: clang/lib/CodeGen/Address.h:67
       return;
-    // Currently the max supported alignment is much less than 1 << 63 and is
+    // Currently the max supported alignment is much less than 1 << 32 and is
     // guaranteed to be a power of 2, so we can store the log of the alignment
----------------
This comment isn't right.  The max alignment is, as far as I can tell, 1<<32 exactly.  (But there's something weird going on with very large values... somehow `int a[1LL<<32] __attribute((aligned(1ULL<<32))) = {};` ignores the alignment.)


================
Comment at: clang/lib/CodeGen/CGBuilder.h:164
+    return Addr.withPointer(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
+                            Addr.isKnownNonNull());
   }
----------------
Do address-space casts preserve non-null?


================
Comment at: clang/lib/CodeGen/CGBuilder.h:277
+        Addr.getAlignment().alignmentOfArrayElement(EltSize),
+        Addr.isKnownNonNull());
   }
----------------
Do non-inbounds GEPs preserve nonnull?


================
Comment at: clang/lib/CodeGen/CGValue.h:181
 
-  llvm::Value *V;
+  llvm::PointerIntPair<llvm::Value *, 1, bool> V;
   llvm::Type *ElementType;
----------------
Do we not have spare bits in the bitfield?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142584/new/

https://reviews.llvm.org/D142584



More information about the cfe-commits mailing list