Index: lib/Transforms/Vectorize/LoadStoreVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -43,10 +43,10 @@ // TODO: Remove this static const unsigned TargetBaseAlign = 4; -class Vectorizer { - typedef SmallVector ValueList; - typedef MapVector ValueListMap; +typedef SmallVector ValueList; +typedef MapVector ValueListMap; +class Vectorizer { Function &F; AliasAnalysis &AA; DominatorTree &DT; @@ -54,8 +54,6 @@ TargetTransformInfo &TTI; const DataLayout &DL; IRBuilder<> Builder; - ValueListMap StoreRefs; - ValueListMap LoadRefs; public: Vectorizer(Function &F, AliasAnalysis &AA, DominatorTree &DT, @@ -115,7 +113,7 @@ BasicBlock::iterator To); /// Collects load and store instructions to vectorize. - void collectInstructions(BasicBlock *BB); + std::pair collectInstructions(BasicBlock *BB); /// Processes the collected instructions, the \p Map. The elements of \p Map /// should be all loads or all stores. @@ -198,7 +196,8 @@ // Scan the blocks in the function in post order. for (BasicBlock *BB : post_order(&F)) { - collectInstructions(BB); + ValueListMap LoadRefs, StoreRefs; + std::tie(LoadRefs, StoreRefs) = collectInstructions(BB); Changed |= vectorizeChains(LoadRefs); Changed |= vectorizeChains(StoreRefs); } @@ -493,9 +492,10 @@ return Chain.size(); } -void Vectorizer::collectInstructions(BasicBlock *BB) { - LoadRefs.clear(); - StoreRefs.clear(); +std::pair +Vectorizer::collectInstructions(BasicBlock *BB) { + ValueListMap LoadRefs; + ValueListMap StoreRefs; for (Instruction &I : *BB) { if (!I.mayReadOrWriteMemory()) @@ -569,6 +569,8 @@ StoreRefs[ObjPtr].push_back(SI); } } + + return {LoadRefs, StoreRefs}; } bool Vectorizer::vectorizeChains(ValueListMap &Map) {