[PATCH] D29165: NVPTX: Trivial cleanups of NVPTXInferAddressSpaces
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 25 20:32:56 PST 2017
arsenm created this revision.
Herald added subscribers: wdng, jholewinski.
- Move DEBUG_TYPE below includes
- Change unknown address space constant to be consistent with other passes
- Grammar fixes in debug output
https://reviews.llvm.org/D29165
Files:
lib/Target/NVPTX/NVPTXInferAddressSpaces.cpp
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<const Value *, unsigned>;
@@ -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<TargetTransformInfoWrapperPass>().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<Value *> 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<unsigned> 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<Use *, 4> 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<LoadInst>(U->getUser()) ||
(isa<StoreInst>(U->getUser()) && U->getOperandNo() == 1)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29165.85856.patch
Type: text/x-patch
Size: 3500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170126/602693d2/attachment.bin>
More information about the llvm-commits
mailing list