Index: lib/Target/NVPTX/NVPTXInferAddressSpaces.cpp =================================================================== --- lib/Target/NVPTX/NVPTXInferAddressSpaces.cpp +++ lib/Target/NVPTX/NVPTXInferAddressSpaces.cpp @@ -89,8 +89,6 @@ // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "nvptx-infer-addrspace" - #include "NVPTX.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Optional.h" @@ -105,10 +103,12 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/ValueMapper.h" +#define DEBUG_TYPE "nvptx-infer-addrspace" + using namespace llvm; namespace { -const unsigned ADDRESS_SPACE_UNINITIALIZED = (unsigned)-1; +static const unsigned UnknownAddressSpace = ~0u; using ValueToAddrSpaceMapTy = DenseMap; @@ -425,9 +425,9 @@ if (AS1 == GenericAddrSpace || AS2 == GenericAddrSpace) return GenericAddrSpace; - if (AS1 == ADDRESS_SPACE_UNINITIALIZED) + if (AS1 == UnknownAddressSpace) return AS2; - if (AS2 == ADDRESS_SPACE_UNINITIALIZED) + if (AS2 == UnknownAddressSpace) return AS1; // The join of two different specific address spaces is generic. @@ -440,7 +440,7 @@ const TargetTransformInfo &TTI = getAnalysis().getTTI(F); GenericAddrSpace = TTI.getUndesirableAddressSpace(); - if (GenericAddrSpace == ADDRESS_SPACE_UNINITIALIZED) + if (GenericAddrSpace == UnknownAddressSpace) return false; // Collects all generic address expressions in postorder. @@ -462,21 +462,20 @@ SetVector Worklist(Postorder.begin(), Postorder.end()); // Initially, all expressions are in the uninitialized address space. for (Value *V : Postorder) - (*InferredAddrSpace)[V] = ADDRESS_SPACE_UNINITIALIZED; + (*InferredAddrSpace)[V] = UnknownAddressSpace; while (!Worklist.empty()) { Value* V = Worklist.pop_back_val(); // Tries to update the address space of the stack top according to the // address spaces of its operands. - DEBUG(dbgs() << "Updating the address space of\n" - << " " << *V << "\n"); + DEBUG(dbgs() << "Updating the address space of\n " << *V << '\n'); Optional NewAS = updateAddressSpace(*V, *InferredAddrSpace); if (!NewAS.hasValue()) continue; // If any updates are made, grabs its users to the worklist because // their address spaces can also be possibly updated. - DEBUG(dbgs() << " to " << NewAS.getValue() << "\n"); + DEBUG(dbgs() << " to " << NewAS.getValue() << '\n'); (*InferredAddrSpace)[V] = NewAS.getValue(); for (Value *User : V->users()) { @@ -507,7 +506,7 @@ // The new inferred address space equals the join of the address spaces // of all its pointer operands. - unsigned NewAS = ADDRESS_SPACE_UNINITIALIZED; + unsigned NewAS = UnknownAddressSpace; for (Value *PtrOperand : getPointerOperands(V)) { unsigned OperandAS; if (InferredAddrSpace.count(PtrOperand)) @@ -565,8 +564,10 @@ SmallVector Uses; for (Use &U : V->uses()) Uses.push_back(&U); - DEBUG(dbgs() << "Replacing the uses of " << *V << "\n to\n " << *NewV - << "\n"); + + DEBUG(dbgs() << "Replacing the uses of " << *V + << "\n with\n " << *NewV << '\n'); + for (Use *U : Uses) { if (isa(U->getUser()) || (isa(U->getUser()) && U->getOperandNo() == 1)) {