[llvm] [clang] [CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (PR #67454)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 16 11:46:23 PST 2023


================
@@ -80,6 +94,139 @@ class Address {
     return Alignment;
   }
 
+  /// Return address with different element type, but same pointer and
+  /// alignment.
+  RawAddress withElementType(llvm::Type *ElemTy) const {
+    return RawAddress(getPointer(), ElemTy, getAlignment(), isKnownNonNull());
+  }
+
+  KnownNonNull_t isKnownNonNull() const {
+    assert(isValid());
+    return (KnownNonNull_t)PointerAndKnownNonNull.getInt();
+  }
+};
+
+/// Like RawAddress, an abstract representation of an aligned address, but the
+/// pointer contained in this class is possibly signed.
+class Address {
+  friend class CGBuilderTy;
+
+  // The boolean flag indicates whether the pointer is known to be non-null.
+  llvm::PointerIntPair<llvm::Value *, 1, bool> Pointer;
+
+  /// The expected IR type of the pointer. When the address is a raw pointer,
+  /// this is currently redundant with the pointer's type, but for signed
+  /// pointers it is useful if the pointer has been offsetted or cast from the
+  /// original type. In the long run, when LLVM adopts opaque pointer types,
+  /// this should become the notional element type of the address.
----------------
efriedma-quic wrote:

This comment probably needs to be updated?

https://github.com/llvm/llvm-project/pull/67454


More information about the cfe-commits mailing list