Author: aaronpuchert Date: Sat Sep 22 14:56:16 2018 New Revision: 342823 URL: http://llvm.org/viewvc/llvm-project?rev=342823&view=rev Log: Eliminate some unneeded signed/unsigned conversions
No functional change is intended, but generally this should be a bit more safe. Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h cfe/trunk/lib/Analysis/ThreadSafety.cpp cfe/trunk/lib/Analysis/ThreadSafetyTIL.cpp Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=342823&r1=342822&r2=342823&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original) +++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Sat Sep 22 14:56:16 2018 @@ -1643,10 +1643,10 @@ private: friend class SCFG; // assign unique ids to all instructions - int renumberInstrs(int id); + unsigned renumberInstrs(unsigned id); - int topologicalSort(SimpleArray<BasicBlock *> &Blocks, int ID); - int topologicalFinalSort(SimpleArray<BasicBlock *> &Blocks, int ID); + unsigned topologicalSort(SimpleArray<BasicBlock *> &Blocks, unsigned ID); + unsigned topologicalFinalSort(SimpleArray<BasicBlock *> &Blocks, unsigned ID); void computeDominator(); void computePostDominator(); @@ -1657,7 +1657,7 @@ private: SCFG *CFGPtr = nullptr; // Unique ID for this BB in the containing CFG. IDs are in topological order. - int BlockID : 31; + unsigned BlockID : 31; // Bit to determine if a block has been visited during a traversal. bool Visited : 1; Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=342823&r1=342822&r2=342823&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original) +++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Sat Sep 22 14:56:16 2018 @@ -730,7 +730,7 @@ void LocalVariableMap::traverseCFG(CFG * CtxIndices.resize(CFGraph->getNumBlockIDs()); for (const auto *CurrBlock : *SortedGraph) { - int CurrBlockID = CurrBlock->getBlockID(); + unsigned CurrBlockID = CurrBlock->getBlockID(); CFGBlockInfo *CurrBlockInfo = &BlockInfo[CurrBlockID]; VisitedBlocks.insert(CurrBlock); @@ -746,7 +746,7 @@ void LocalVariableMap::traverseCFG(CFG * continue; } - int PrevBlockID = (*PI)->getBlockID(); + unsigned PrevBlockID = (*PI)->getBlockID(); CFGBlockInfo *PrevBlockInfo = &BlockInfo[PrevBlockID]; if (CtxInit) { @@ -2302,7 +2302,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A } for (const auto *CurrBlock : *SortedGraph) { - int CurrBlockID = CurrBlock->getBlockID(); + unsigned CurrBlockID = CurrBlock->getBlockID(); CFGBlockInfo *CurrBlockInfo = &BlockInfo[CurrBlockID]; // Use the default initial lockset in case there are no predecessors. @@ -2329,7 +2329,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A if (*PI == nullptr || !VisitedBlocks.alreadySet(*PI)) continue; - int PrevBlockID = (*PI)->getBlockID(); + unsigned PrevBlockID = (*PI)->getBlockID(); CFGBlockInfo *PrevBlockInfo = &BlockInfo[PrevBlockID]; // Ignore edges from blocks that can't return. @@ -2370,7 +2370,7 @@ void ThreadSafetyAnalyzer::runAnalysis(A // Process continue and break blocks. Assume that the lockset for the // resulting block is unaffected by any discrepancies in them. for (const auto *PrevBlock : SpecialBlocks) { - int PrevBlockID = PrevBlock->getBlockID(); + unsigned PrevBlockID = PrevBlock->getBlockID(); CFGBlockInfo *PrevBlockInfo = &BlockInfo[PrevBlockID]; if (!LocksetInitialized) { Modified: cfe/trunk/lib/Analysis/ThreadSafetyTIL.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafetyTIL.cpp?rev=342823&r1=342822&r2=342823&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/ThreadSafetyTIL.cpp (original) +++ cfe/trunk/lib/Analysis/ThreadSafetyTIL.cpp Sat Sep 22 14:56:16 2018 @@ -150,7 +150,7 @@ void til::simplifyIncompleteArg(til::Phi } // Renumbers the arguments and instructions to have unique, sequential IDs. -int BasicBlock::renumberInstrs(int ID) { +unsigned BasicBlock::renumberInstrs(unsigned ID) { for (auto *Arg : Args) Arg->setID(this, ID++); for (auto *Instr : Instrs) @@ -163,7 +163,8 @@ int BasicBlock::renumberInstrs(int ID) { // Each block will be written into the Blocks array in order, and its BlockID // will be set to the index in the array. Sorting should start from the entry // block, and ID should be the total number of blocks. -int BasicBlock::topologicalSort(SimpleArray<BasicBlock *> &Blocks, int ID) { +unsigned BasicBlock::topologicalSort(SimpleArray<BasicBlock *> &Blocks, + unsigned ID) { if (Visited) return ID; Visited = true; for (auto *Block : successors()) @@ -186,7 +187,8 @@ int BasicBlock::topologicalSort(SimpleAr // critical edges, and (3) the entry block is reachable from the exit block // and no blocks are accessible via traversal of back-edges from the exit that // weren't accessible via forward edges from the entry. -int BasicBlock::topologicalFinalSort(SimpleArray<BasicBlock*>& Blocks, int ID) { +unsigned BasicBlock::topologicalFinalSort(SimpleArray<BasicBlock *> &Blocks, + unsigned ID) { // Visited is assumed to have been set by the topologicalSort. This pass // assumes !Visited means that we've visited this node before. if (!Visited) return ID; @@ -257,7 +259,7 @@ void BasicBlock::computePostDominator() // Renumber instructions in all blocks void SCFG::renumberInstrs() { - int InstrID = 0; + unsigned InstrID = 0; for (auto *Block : Blocks) InstrID = Block->renumberInstrs(InstrID); } @@ -288,11 +290,11 @@ static inline void computeNodeID(BasicBl // 3) Topologically sorting the blocks into the "Blocks" array. void SCFG::computeNormalForm() { // Topologically sort the blocks starting from the entry block. - int NumUnreachableBlocks = Entry->topologicalSort(Blocks, Blocks.size()); + unsigned NumUnreachableBlocks = Entry->topologicalSort(Blocks, Blocks.size()); if (NumUnreachableBlocks > 0) { // If there were unreachable blocks shift everything down, and delete them. - for (size_t I = NumUnreachableBlocks, E = Blocks.size(); I < E; ++I) { - size_t NI = I - NumUnreachableBlocks; + for (unsigned I = NumUnreachableBlocks, E = Blocks.size(); I < E; ++I) { + unsigned NI = I - NumUnreachableBlocks; Blocks[NI] = Blocks[I]; Blocks[NI]->BlockID = NI; // FIXME: clean up predecessor pointers to unreachable blocks? @@ -305,7 +307,7 @@ void SCFG::computeNormalForm() { Block->computeDominator(); // Once dominators have been computed, the final sort may be performed. - int NumBlocks = Exit->topologicalFinalSort(Blocks, 0); + unsigned NumBlocks = Exit->topologicalFinalSort(Blocks, 0); assert(static_cast<size_t>(NumBlocks) == Blocks.size()); (void) NumBlocks; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits