[llvm] [mlir] [Dwarf] Support `__ptrauth` qualifier in metadata nodes (PR #83862)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 13:42:45 PST 2024


================
@@ -972,6 +972,35 @@ class DIStringType : public DIType {
 ///
 /// TODO: Split out members (inheritance, fields, methods, etc.).
 class DIDerivedType : public DIType {
+public:
+  /// Pointer authentication (__ptrauth) metadata.
+  struct PtrAuthData {
+    unsigned RawData;
+
+    PtrAuthData(unsigned FromRawData) : RawData(FromRawData) {}
+    PtrAuthData(unsigned Key, bool IsDiscr, unsigned Discriminator,
+                bool IsaPointer, bool AuthenticatesNullValues) {
+      assert(Key < 16);
+      assert(Discriminator <= 0xffff);
+      RawData = (Key << 0) | (IsDiscr ? (1 << 4) : 0) | (Discriminator << 5) |
+                (IsaPointer ? (1 << 21) : 0) |
+                (AuthenticatesNullValues ? (1 << 22) : 0);
+    }
+    bool operator==(struct PtrAuthData Other) const {
+      return RawData == Other.RawData;
+    }
+    bool operator!=(struct PtrAuthData Other) const {
+      return !(*this == Other);
+    }
+
----------------
dwblaikie wrote:

Prefer non-member operator overloads (they can be friends and defined inline if that's useful/more convenient than defining them outside the class definition) to allow equal conversions on LHS and RHS.

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


More information about the llvm-commits mailing list