[llvm] f6dea2e - [IRSim] Strip out the findSimilarity call from the constructor

Andrew Litteken via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 11 16:41:40 PDT 2021


Author: Andrew Litteken
Date: 2021-06-11T18:41:28-05:00
New Revision: f6dea2e7328b62f21d53511dfa42ec72dc5235c3

URL: https://github.com/llvm/llvm-project/commit/f6dea2e7328b62f21d53511dfa42ec72dc5235c3
DIFF: https://github.com/llvm/llvm-project/commit/f6dea2e7328b62f21d53511dfa42ec72dc5235c3.diff

LOG: [IRSim] Strip out the findSimilarity call from the constructor

Both doInitialize and runOnModule were running the entire analysis
due to the actual work being done in the constructor. Strip it out here
and only get the similarity during runOnModule.

Author: lanza
Reviewers: AndrewLitteken, paquette, plofti

Differential Revision: https://reviews.llvm.org/D92524

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
    llvm/lib/Analysis/IRSimilarityIdentifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
index 9e97541e542b..b623b9ca58d8 100644
--- a/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
+++ b/llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
@@ -654,12 +654,6 @@ class IRSimilarityIdentifier {
   IRSimilarityIdentifier()
       : Mapper(&InstDataAllocator, &InstDataListAllocator) {}
 
-  /// \param M the module to find similarity in.
-  explicit IRSimilarityIdentifier(Module &M)
-      : Mapper(&InstDataAllocator, &InstDataListAllocator) {
-    findSimilarity(M);
-  }
-
 private:
   /// Map the instructions in the module to unsigned integers, using mapping
   /// already present in the Mapper if possible.

diff  --git a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
index dd0f62521aa9..a6298afb66f5 100644
--- a/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
+++ b/llvm/lib/Analysis/IRSimilarityIdentifier.cpp
@@ -891,7 +891,7 @@ IRSimilarityIdentifierWrapperPass::IRSimilarityIdentifierWrapperPass()
 }
 
 bool IRSimilarityIdentifierWrapperPass::doInitialization(Module &M) {
-  IRSI.reset(new IRSimilarityIdentifier(M));
+  IRSI.reset(new IRSimilarityIdentifier());
   return false;
 }
 
@@ -901,8 +901,7 @@ bool IRSimilarityIdentifierWrapperPass::doFinalization(Module &M) {
 }
 
 bool IRSimilarityIdentifierWrapperPass::runOnModule(Module &M) {
-  // All the real work is done in the constructor for the pass.
-  IRSI.reset(new IRSimilarityIdentifier(M));
+  IRSI->findSimilarity(M);
   return false;
 }
 
@@ -910,7 +909,9 @@ AnalysisKey IRSimilarityAnalysis::Key;
 IRSimilarityIdentifier IRSimilarityAnalysis::run(Module &M,
                                                ModuleAnalysisManager &) {
 
-  return IRSimilarityIdentifier(M);
+  auto IRSI = IRSimilarityIdentifier();
+  IRSI.findSimilarity(M);
+  return IRSI;
 }
 
 PreservedAnalyses


        


More information about the llvm-commits mailing list