From 8c54b40adda04985a8aaaa5da80d73061a763990 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Wed, 14 Dec 2016 23:20:40 +0000 Subject: [PATCH] [NVPTX] Remove dead code. I've chosen to remove NVPTXInstrInfo::CanTailMerge but not NVPTXInstrInfo::isLoadInstr and isStoreInstr (which are also dead) because while the latter two are reasonably useful utilities, the former cannot be used safely: It relies on successful address space inference to identify writes to shared memory, but addrspace inference is a best-effort thing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289740 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/NVPTX/NVPTXInstrInfo.cpp | 13 ---- lib/Target/NVPTX/NVPTXInstrInfo.h | 1 - lib/Target/NVPTX/NVPTXUtilities.cpp | 106 ---------------------------- lib/Target/NVPTX/NVPTXUtilities.h | 9 --- lib/Target/NVPTX/NVVMReflect.cpp | 1 - 5 files changed, 130 deletions(-) diff --git a/lib/Target/NVPTX/NVPTXInstrInfo.cpp b/lib/Target/NVPTX/NVPTXInstrInfo.cpp index 60f8c47b7e4..7f89742a321 100644 --- a/lib/Target/NVPTX/NVPTXInstrInfo.cpp +++ b/lib/Target/NVPTX/NVPTXInstrInfo.cpp @@ -110,19 +110,6 @@ bool NVPTXInstrInfo::isStoreInstr(const MachineInstr &MI, return isStore; } -bool NVPTXInstrInfo::CanTailMerge(const MachineInstr *MI) const { - unsigned addrspace = 0; - if (MI->getOpcode() == NVPTX::INT_BARRIER0) - return false; - if (isLoadInstr(*MI, addrspace)) - if (addrspace == NVPTX::PTXLdStInstCode::SHARED) - return false; - if (isStoreInstr(*MI, addrspace)) - if (addrspace == NVPTX::PTXLdStInstCode::SHARED) - return false; - return true; -} - /// AnalyzeBranch - Analyze the branching code at the end of MBB, returning /// true if it cannot be understood (e.g. it's a switch dispatch or isn't /// implemented for a target). Upon success, this returns false and returns diff --git a/lib/Target/NVPTX/NVPTXInstrInfo.h b/lib/Target/NVPTX/NVPTXInstrInfo.h index 3d3ae3507d8..d284282e28c 100644 --- a/lib/Target/NVPTX/NVPTXInstrInfo.h +++ b/lib/Target/NVPTX/NVPTXInstrInfo.h @@ -57,7 +57,6 @@ public: bool isLoadInstr(const MachineInstr &MI, unsigned &AddrSpace) const; bool isStoreInstr(const MachineInstr &MI, unsigned &AddrSpace) const; - virtual bool CanTailMerge(const MachineInstr *MI) const; // Branch analysis. bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, diff --git a/lib/Target/NVPTX/NVPTXUtilities.cpp b/lib/Target/NVPTX/NVPTXUtilities.cpp index ba5c054b09c..e464f474b1d 100644 --- a/lib/Target/NVPTX/NVPTXUtilities.cpp +++ b/lib/Target/NVPTX/NVPTXUtilities.cpp @@ -314,110 +314,4 @@ bool getAlign(const CallInst &I, unsigned index, unsigned &align) { return false; } -// The following are some useful utilities for debugging - -BasicBlock *getParentBlock(Value *v) { - if (BasicBlock *B = dyn_cast(v)) - return B; - - if (Instruction *I = dyn_cast(v)) - return I->getParent(); - - return nullptr; -} - -Function *getParentFunction(Value *v) { - if (Function *F = dyn_cast(v)) - return F; - - if (Instruction *I = dyn_cast(v)) - return I->getParent()->getParent(); - - if (BasicBlock *B = dyn_cast(v)) - return B->getParent(); - - return nullptr; -} - -// Dump a block by name -void dumpBlock(Value *v, char *blockName) { - Function *F = getParentFunction(v); - if (!F) - return; - - for (Function::iterator it = F->begin(), ie = F->end(); it != ie; ++it) { - BasicBlock *B = &*it; - if (strcmp(B->getName().data(), blockName) == 0) { - B->dump(); - return; - } - } -} - -// Find an instruction by name -Instruction *getInst(Value *base, char *instName) { - Function *F = getParentFunction(base); - if (!F) - return nullptr; - - for (inst_iterator it = inst_begin(F), ie = inst_end(F); it != ie; ++it) { - Instruction *I = &*it; - if (strcmp(I->getName().data(), instName) == 0) { - return I; - } - } - - return nullptr; -} - -// Dump an instruction by name -void dumpInst(Value *base, char *instName) { - Instruction *I = getInst(base, instName); - if (I) - I->dump(); -} - -// Dump an instruction and all dependent instructions -void dumpInstRec(Value *v, std::set *visited) { - if (Instruction *I = dyn_cast(v)) { - - if (visited->find(I) != visited->end()) - return; - - visited->insert(I); - - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - dumpInstRec(I->getOperand(i), visited); - - I->dump(); - } -} - -// Dump an instruction and all dependent instructions -void dumpInstRec(Value *v) { - std::set visited; - - //BasicBlock *B = getParentBlock(v); - - dumpInstRec(v, &visited); -} - -// Dump the parent for Instruction, block or function -void dumpParent(Value *v) { - if (Instruction *I = dyn_cast(v)) { - I->getParent()->dump(); - return; - } - - if (BasicBlock *B = dyn_cast(v)) { - B->getParent()->dump(); - return; - } - - if (Function *F = dyn_cast(v)) { - F->getParent()->dump(); - return; - } -} - } // namespace llvm diff --git a/lib/Target/NVPTX/NVPTXUtilities.h b/lib/Target/NVPTX/NVPTXUtilities.h index 0b189cde920..dad4d415347 100644 --- a/lib/Target/NVPTX/NVPTXUtilities.h +++ b/lib/Target/NVPTX/NVPTXUtilities.h @@ -63,15 +63,6 @@ bool isKernelFunction(const Function &); bool getAlign(const Function &, unsigned index, unsigned &); bool getAlign(const CallInst &, unsigned index, unsigned &); -BasicBlock *getParentBlock(Value *v); -Function *getParentFunction(Value *v); -void dumpBlock(Value *v, char *blockName); -Instruction *getInst(Value *base, char *instName); -void dumpInst(Value *base, char *instName); -void dumpInstRec(Value *v, std::set *visited); -void dumpInstRec(Value *v); -void dumpParent(Value *v); - } #endif diff --git a/lib/Target/NVPTX/NVVMReflect.cpp b/lib/Target/NVPTX/NVVMReflect.cpp index e0c35e7039e..c639c4dc068 100644 --- a/lib/Target/NVPTX/NVVMReflect.cpp +++ b/lib/Target/NVPTX/NVVMReflect.cpp @@ -65,7 +65,6 @@ public: bool runOnFunction(Function &) override; private: - bool handleFunction(Function *ReflectFunction); void setVarMap(); }; } -- 2.50.0