[PATCH] D107354: [MachineMemOperand] learn about ptr_provenance

Jeroen Dobbelaere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 29 05:59:32 PDT 2022


jeroen.dobbelaere updated this revision to Diff 440968.
jeroen.dobbelaere added a comment.

Rebased to ffe262a198a9f9030991df6d3ddd812e74fa3523 <https://reviews.llvm.org/rGffe262a198a9f9030991df6d3ddd812e74fa3523>


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
@@ -40,6 +40,12 @@
   /// This is the IR pointer value for the access, or it is null if unknown.
   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;
 
@@ -48,8 +54,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;
   }
 
@@ -59,15 +66,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();
@@ -215,6 +222,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.440968.patch
Type: text/x-patch
Size: 3088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/f79fa50e/attachment.bin>


More information about the llvm-commits mailing list