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

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 9 18:34:25 PST 2023


ahatanak added inline comments.


================
Comment at: clang/lib/CodeGen/CGExpr.cpp:1723
+      Addr =
+          Addr.withPointer(Builder.CreateThreadLocalAddress(GV), KnownNonNull);
 
----------------
ahatanak wrote:
> `KnownNonNull` is being passed here because the address of a load must be non-null. Do we have to check that the function doesn't have `null_pointer_is_valid` here?
I don't think we should pass `KnownNonNull` unless we know for sure the address of the global variable is non-null, which isn't always true (for example, when it's extern weak).

We can set `KnownNonNull` below this line if we know `NullPointerIsValid` is false.


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