[PATCH] D107354: [MachineMemOperand] learn about ptr_provenance

Jeroen Dobbelaere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 15 07:04:39 PDT 2022


jeroen.dobbelaere updated this revision to Diff 423099.
jeroen.dobbelaere added a comment.
Herald added a project: All.

Rebase to 49cb4fef02e635bf304906232214166c7531d753 <https://reviews.llvm.org/rG49cb4fef02e635bf304906232214166c7531d753>


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

https://reviews.llvm.org/D107354

Files:
  llvm/include/llvm/CodeGen/MachineMemOperand.h
  llvm/lib/CodeGen/MachineOperand.cpp


Index: llvm/lib/CodeGen/MachineOperand.cpp
===================================================================
--- llvm/lib/CodeGen/MachineOperand.cpp
+++ llvm/lib/CodeGen/MachineOperand.cpp
@@ -1185,6 +1185,10 @@
        << "unknown-address";
   }
   MachineOperand::printOperandOffset(OS, getOffset());
+  if (getPtrProvenance()) {
+    OS << ", ptr_provenance ";
+    MIRFormatter::printIRValue(OS, *getPtrProvenance(), MST);
+  }
   if (getSize() > 0 && getAlign() != getSize())
     OS << ", align " << getAlign().value();
   if (getAlign() != getBaseAlign())
Index: llvm/include/llvm/CodeGen/MachineMemOperand.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineMemOperand.h
+++ llvm/include/llvm/CodeGen/MachineMemOperand.h
@@ -41,6 +41,12 @@
   /// space.
   PointerUnion<const Value *, const PseudoSourceValue *> V;
 
+  /// The provenance of the pointer. When ConstantPointerNull, the provenance
+  /// can be any object.
+  /// FIXME: nullptr here means : use V as provenance. This will change in
+  /// future.
+  const Value *PtrProvenance = nullptr;
+
   /// Offset - This is an offset from the base Value*.
   int64_t Offset;
 
@@ -49,8 +55,9 @@
   uint8_t StackID;
 
   explicit MachinePointerInfo(const Value *v, int64_t offset = 0,
-                              uint8_t ID = 0)
-      : V(v), Offset(offset), StackID(ID) {
+                              uint8_t ID = 0,
+                              const Value *ptrProvenance = nullptr)
+      : V(v), PtrProvenance(ptrProvenance), Offset(offset), StackID(ID) {
     AddrSpace = v ? v->getType()->getPointerAddressSpace() : 0;
   }
 
@@ -60,15 +67,15 @@
     AddrSpace = v ? v->getAddressSpace() : 0;
   }
 
-  explicit MachinePointerInfo(unsigned AddressSpace = 0, int64_t offset = 0)
-      : V((const Value *)nullptr), Offset(offset), AddrSpace(AddressSpace),
-        StackID(0) {}
+  explicit MachinePointerInfo(unsigned AddressSpace = 0, int64_t offset = 0,
+                              const Value *ptrProvenance = nullptr)
+      : V((const Value *)nullptr), PtrProvenance(ptrProvenance), Offset(offset),
+        AddrSpace(AddressSpace), StackID(0) {}
 
   explicit MachinePointerInfo(
-    PointerUnion<const Value *, const PseudoSourceValue *> v,
-    int64_t offset = 0,
-    uint8_t ID = 0)
-    : V(v), Offset(offset), StackID(ID) {
+      PointerUnion<const Value *, const PseudoSourceValue *> v,
+      int64_t offset = 0, uint8_t ID = 0, const Value *ptrProvenance = nullptr)
+      : V(v), PtrProvenance(ptrProvenance), Offset(offset), StackID(ID) {
     if (V) {
       if (const auto *ValPtr = V.dyn_cast<const Value*>())
         AddrSpace = ValPtr->getType()->getPointerAddressSpace();
@@ -216,6 +223,8 @@
 
   const void *getOpaqueValue() const { return PtrInfo.V.getOpaqueValue(); }
 
+  const Value *getPtrProvenance() const { return PtrInfo.PtrProvenance; }
+
   /// Return the raw flags of the source value, \see Flags.
   Flags getFlags() const { return FlagVals; }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107354.423099.patch
Type: text/x-patch
Size: 3024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220415/286fdee4/attachment.bin>


More information about the llvm-commits mailing list