Index: include/llvm/CodeGen/PseudoSourceValue.h =================================================================== --- include/llvm/CodeGen/PseudoSourceValue.h +++ include/llvm/CodeGen/PseudoSourceValue.h @@ -47,6 +47,7 @@ private: PSVKind Kind; + unsigned AddressSpace; friend raw_ostream &llvm::operator<<(raw_ostream &OS, const PseudoSourceValue* PSV); @@ -57,7 +58,7 @@ virtual void printCustom(raw_ostream &O) const; public: - explicit PseudoSourceValue(PSVKind Kind); + explicit PseudoSourceValue(PSVKind Kind, unsigned AdressSpace = 0); virtual ~PseudoSourceValue(); @@ -68,6 +69,8 @@ bool isConstantPool() const { return Kind == ConstantPool; } bool isJumpTable() const { return Kind == JumpTable; } + unsigned getAddressSpace() const { return AddressSpace; } + /// Test whether the memory pointed to by this PseudoSourceValue has a /// constant value. virtual bool isConstant(const MachineFrameInfo *) const; Index: lib/CodeGen/MachineInstr.cpp =================================================================== --- lib/CodeGen/MachineInstr.cpp +++ lib/CodeGen/MachineInstr.cpp @@ -467,7 +467,11 @@ /// getAddrSpace - Return the LLVM IR address space number that this pointer /// points into. unsigned MachinePointerInfo::getAddrSpace() const { - if (V.isNull() || V.is()) return 0; + if (V.isNull()) return 0; + + if (V.is()) + return V.get()->getAddressSpace(); + return cast(V.get()->getType())->getAddressSpace(); } Index: lib/CodeGen/PseudoSourceValue.cpp =================================================================== --- lib/CodeGen/PseudoSourceValue.cpp +++ lib/CodeGen/PseudoSourceValue.cpp @@ -24,7 +24,8 @@ "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack", "GlobalValueCallEntry", "ExternalSymbolCallEntry"}; -PseudoSourceValue::PseudoSourceValue(PSVKind Kind) : Kind(Kind) {} +PseudoSourceValue::PseudoSourceValue(PSVKind Kind, unsigned AddressSpace) + : Kind(Kind), AddressSpace(AddressSpace) {} PseudoSourceValue::~PseudoSourceValue() {}