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 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,16 @@ 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 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) { if (V) { if (const auto *ValPtr = V.dyn_cast()) AddrSpace = ValPtr->getType()->getPointerAddressSpace(); @@ -216,6 +224,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; } Index: llvm/lib/CodeGen/MachineOperand.cpp =================================================================== --- llvm/lib/CodeGen/MachineOperand.cpp +++ llvm/lib/CodeGen/MachineOperand.cpp @@ -1180,6 +1180,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())