[llvm-commits] [llvm] r43694 - in /llvm/trunk: include/llvm/Transforms/IPO.h lib/Transforms/IPO/LoopExtractor.cpp tools/bugpoint/ExtractFunction.cpp

Gordon Henriksen gordonhenriksen at mac.com
Sun Nov 4 17:54:08 PST 2007


Author: gordon
Date: Sun Nov  4 19:54:05 2007
New Revision: 43694

URL: http://llvm.org/viewvc/llvm-project?rev=43694&view=rev
Log:
Deleting redundant copy of block extractor pass. See also PR1775.

Modified:
    llvm/trunk/include/llvm/Transforms/IPO.h
    llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp

Modified: llvm/trunk/include/llvm/Transforms/IPO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO.h?rev=43694&r1=43693&r2=43694&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Transforms/IPO.h (original)
+++ llvm/trunk/include/llvm/Transforms/IPO.h Sun Nov  4 19:54:05 2007
@@ -153,7 +153,7 @@
 /// createBlockExtractorPass - This pass extracts all blocks (except those
 /// specified in the argument list) from the functions in the module.
 ///
-ModulePass *createBlockExtractorPass(std::vector<BasicBlock*> &BTNE);
+ModulePass *createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE);
 
 /// createOptimizeWellKnownCallsPass - This pass optimizes specific calls to
 /// specific well-known (library) functions.

Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp?rev=43694&r1=43693&r2=43694&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp Sun Nov  4 19:54:05 2007
@@ -151,7 +151,7 @@
     std::vector<BasicBlock*> BlocksToNotExtract;
   public:
     static char ID; // Pass identification, replacement for typeid
-    explicit BlockExtractorPass(std::vector<BasicBlock*> &B) 
+    explicit BlockExtractorPass(const std::vector<BasicBlock*> &B) 
       : ModulePass((intptr_t)&ID), BlocksToNotExtract(B) {}
     BlockExtractorPass() : ModulePass((intptr_t)&ID) {}
 
@@ -166,7 +166,8 @@
 // createBlockExtractorPass - This pass extracts all blocks (except those
 // specified in the argument list) from the functions in the module.
 //
-ModulePass *llvm::createBlockExtractorPass(std::vector<BasicBlock*> &BTNE) {
+ModulePass *llvm::createBlockExtractorPass(const std::vector<BasicBlock*> &BTNE)
+{
   return new BlockExtractorPass(BTNE);
 }
 

Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=43694&r1=43693&r2=43694&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Sun Nov  4 19:54:05 2007
@@ -297,52 +297,6 @@
 // Basic Block Extraction Code
 //===----------------------------------------------------------------------===//
 
-namespace {
-  std::vector<BasicBlock*> BlocksToNotExtract;
-
-  /// BlockExtractorPass - This pass is used by bugpoint to extract all blocks
-  /// from the module into their own functions except for those specified by the
-  /// BlocksToNotExtract list.
-  class BlockExtractorPass : public ModulePass {
-    bool runOnModule(Module &M);
-  public:
-    static char ID; // Pass ID, replacement for typeid
-    BlockExtractorPass() : ModulePass((intptr_t)&ID) {}
-  };
-  char BlockExtractorPass::ID = 0;
-  RegisterPass<BlockExtractorPass>
-  XX("extract-bbs", "Extract Basic Blocks From Module (for bugpoint use)");
-}
-
-bool BlockExtractorPass::runOnModule(Module &M) {
-  std::set<BasicBlock*> TranslatedBlocksToNotExtract;
-  for (unsigned i = 0, e = BlocksToNotExtract.size(); i != e; ++i) {
-    BasicBlock *BB = BlocksToNotExtract[i];
-    Function *F = BB->getParent();
-
-    // Map the corresponding function in this module.
-    Function *MF = M.getFunction(F->getName());
-
-    // Figure out which index the basic block is in its function.
-    Function::iterator BBI = MF->begin();
-    std::advance(BBI, std::distance(F->begin(), Function::iterator(BB)));
-    TranslatedBlocksToNotExtract.insert(BBI);
-  }
-
-  // Now that we know which blocks to not extract, figure out which ones we WANT
-  // to extract.
-  std::vector<BasicBlock*> BlocksToExtract;
-  for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F)
-    for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
-      if (!TranslatedBlocksToNotExtract.count(BB))
-        BlocksToExtract.push_back(BB);
-
-  for (unsigned i = 0, e = BlocksToExtract.size(); i != e; ++i)
-    ExtractBasicBlock(BlocksToExtract[i]);
-
-  return !BlocksToExtract.empty();
-}
-
 /// ExtractMappedBlocksFromModule - Extract all but the specified basic blocks
 /// into their own functions.  The only detail is that M is actually a module
 /// cloned from the one the BBs are in, so some mapping needs to be performed.
@@ -351,13 +305,10 @@
 Module *BugDriver::ExtractMappedBlocksFromModule(const
                                                  std::vector<BasicBlock*> &BBs,
                                                  Module *M) {
-  // Set the global list so that pass will be able to access it.
-  BlocksToNotExtract = BBs;
-
   std::vector<const PassInfo*> PI;
-  PI.push_back(getPI(new BlockExtractorPass()));
+  // FIXME: BBs is actually ignored. See http://llvm.org/PR1775
+  PI.push_back(getPI(createBlockExtractorPass(BBs)));
   Module *Ret = runPassesOn(M, PI);
-  BlocksToNotExtract.clear();
   if (Ret == 0) {
     std::cout << "*** Basic Block extraction failed, please report a bug!\n";
     M = swapProgramIn(M);





More information about the llvm-commits mailing list