[LoopVectorize] Factor out duplicated code into Report::emitAnalysis
The logic in emitAnalysis is duplicated across multiple functions. This splits it into a function. Another use will be added by the patchset. NFC. This is part of the patchset that splits out the memory dependence logic from LoopVectorizationLegality into a new class LoopAccessAnalysis. LoopAccessAnalysis will be used by the new Loop Distribution pass. llvm-svn: 227748
This commit is contained in:
		
							parent
							
								
									6854b9203a
								
							
						
					
					
						commit
						ac71cecdc6
					
				| 
						 | 
					@ -239,6 +239,11 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  std::string &str() { return Out.str(); }
 | 
					  std::string &str() { return Out.str(); }
 | 
				
			||||||
  operator Twine() { return Out.str(); }
 | 
					  operator Twine() { return Out.str(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// \brief Emit an analysis note with the debug location from the instruction
 | 
				
			||||||
 | 
					  /// in \p Message if available.  Otherwise use the location of \p TheLoop.
 | 
				
			||||||
 | 
					  static void emitAnalysis(Report &Message, const Function *TheFunction,
 | 
				
			||||||
 | 
					                           const Loop *TheLoop);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// InnerLoopVectorizer vectorizes loops which contain only one basic
 | 
					/// InnerLoopVectorizer vectorizes loops which contain only one basic
 | 
				
			||||||
| 
						 | 
					@ -551,6 +556,15 @@ static void propagateMetadata(Instruction *To, const Instruction *From) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Report::emitAnalysis(Report &Message, const Function *TheFunction,
 | 
				
			||||||
 | 
					                          const Loop *TheLoop) {
 | 
				
			||||||
 | 
					  DebugLoc DL = TheLoop->getStartLoc();
 | 
				
			||||||
 | 
					  if (Instruction *I = Message.getInstr())
 | 
				
			||||||
 | 
					    DL = I->getDebugLoc();
 | 
				
			||||||
 | 
					  emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
 | 
				
			||||||
 | 
					                                 *TheFunction, DL, Message.str());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// \brief Propagate known metadata from one instruction to a vector of others.
 | 
					/// \brief Propagate known metadata from one instruction to a vector of others.
 | 
				
			||||||
static void propagateMetadata(SmallVectorImpl<Value *> &To, const Instruction *From) {
 | 
					static void propagateMetadata(SmallVectorImpl<Value *> &To, const Instruction *From) {
 | 
				
			||||||
  for (Value *V : To)
 | 
					  for (Value *V : To)
 | 
				
			||||||
| 
						 | 
					@ -889,11 +903,7 @@ private:
 | 
				
			||||||
  /// Report an analysis message to assist the user in diagnosing loops that are
 | 
					  /// Report an analysis message to assist the user in diagnosing loops that are
 | 
				
			||||||
  /// not vectorized.
 | 
					  /// not vectorized.
 | 
				
			||||||
  void emitAnalysis(Report &Message) {
 | 
					  void emitAnalysis(Report &Message) {
 | 
				
			||||||
    DebugLoc DL = TheLoop->getStartLoc();
 | 
					    Report::emitAnalysis(Message, TheFunction, TheLoop);
 | 
				
			||||||
    if (Instruction *I = Message.getInstr())
 | 
					 | 
				
			||||||
      DL = I->getDebugLoc();
 | 
					 | 
				
			||||||
    emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
 | 
					 | 
				
			||||||
                                   *TheFunction, DL, Message.str());
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// The loop that we evaluate.
 | 
					  /// The loop that we evaluate.
 | 
				
			||||||
| 
						 | 
					@ -1029,11 +1039,7 @@ private:
 | 
				
			||||||
  /// Report an analysis message to assist the user in diagnosing loops that are
 | 
					  /// Report an analysis message to assist the user in diagnosing loops that are
 | 
				
			||||||
  /// not vectorized.
 | 
					  /// not vectorized.
 | 
				
			||||||
  void emitAnalysis(Report &Message) {
 | 
					  void emitAnalysis(Report &Message) {
 | 
				
			||||||
    DebugLoc DL = TheLoop->getStartLoc();
 | 
					    Report::emitAnalysis(Message, TheFunction, TheLoop);
 | 
				
			||||||
    if (Instruction *I = Message.getInstr())
 | 
					 | 
				
			||||||
      DL = I->getDebugLoc();
 | 
					 | 
				
			||||||
    emitOptimizationRemarkAnalysis(TheFunction->getContext(), DEBUG_TYPE,
 | 
					 | 
				
			||||||
                                   *TheFunction, DL, Message.str());
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Values used only by @llvm.assume calls.
 | 
					  /// Values used only by @llvm.assume calls.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue