[PATCH] D22699: Refactor - CodeExtractor : Move check for valid block to static utility and add assumption checks.

River Riddle via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 10:21:59 PDT 2016


rriddle updated the summary for this revision.
rriddle updated this revision to Diff 65371.
rriddle added a comment.

Moving assumptions to later patch


https://reviews.llvm.org/D22699

Files:
  /Users/rriddle/Desktop/llvm/llvm/include/llvm/Transforms/Utils/CodeExtractor.h
  /Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp

Index: /Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp
===================================================================
--- /Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ /Users/rriddle/Desktop/llvm/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -49,7 +49,7 @@
                  cl::desc("Aggregate arguments to code-extracted functions"));
 
 /// \brief Test whether a block is valid for extraction.
-static bool isBlockValidForExtraction(const BasicBlock &BB) {
+bool CodeExtractor::isBlockValidForExtraction(const BasicBlock &BB) {
   // Landing pads must be in the function where they were inserted for cleanup.
   if (BB.isEHPad())
     return false;
@@ -81,7 +81,7 @@
     if (!Result.insert(*BBBegin))
       llvm_unreachable("Repeated basic blocks in extraction input");
 
-    if (!isBlockValidForExtraction(**BBBegin)) {
+    if (!CodeExtractor::isBlockValidForExtraction(**BBBegin)) {
       Result.clear();
       return Result;
     }
@@ -339,7 +339,7 @@
   // If the old function is no-throw, so is the new one.
   if (oldFunction->doesNotThrow())
     newFunction->setDoesNotThrow();
-  
+
   newFunction->getBasicBlockList().push_back(newRootNode);
 
   // Create an iterator to name all of the arguments we inserted.
@@ -413,7 +413,7 @@
   // Emit a call to the new function, passing in: *pointer to struct (if
   // aggregating parameters), or plan inputs and allocated memory for outputs
   std::vector<Value*> params, StructValues, ReloadOutputs, Reloads;
-  
+
   LLVMContext &Context = newFunction->getContext();
 
   // Add inputs as params, or to be filled into the struct
@@ -630,7 +630,7 @@
     } else {
       // Otherwise we must have code extracted an unwind or something, just
       // return whatever we want.
-      ReturnInst::Create(Context, 
+      ReturnInst::Create(Context,
                          Constant::getNullValue(OldFnRetTy), TheSwitch);
     }
 
@@ -692,13 +692,13 @@
   Function *oldFunction = header->getParent();
 
   // This takes place of the original loop
-  BasicBlock *codeReplacer = BasicBlock::Create(header->getContext(), 
+  BasicBlock *codeReplacer = BasicBlock::Create(header->getContext(),
                                                 "codeRepl", oldFunction,
                                                 header);
 
   // The new function needs a root node because other nodes can branch to the
   // head of the region, but the entry node of a function cannot have preds.
-  BasicBlock *newFuncRoot = BasicBlock::Create(header->getContext(), 
+  BasicBlock *newFuncRoot = BasicBlock::Create(header->getContext(),
                                                "newFuncRoot");
   newFuncRoot->getInstList().push_back(BranchInst::Create(header));
 
@@ -760,7 +760,7 @@
   //  cerr << "OLD FUNCTION: " << *oldFunction;
   //  verifyFunction(*oldFunction);
 
-  DEBUG(if (verifyFunction(*newFunction)) 
+  DEBUG(if (verifyFunction(*newFunction))
         report_fatal_error("verifyFunction failed!"));
   return newFunction;
 }
\ No newline at end of file
Index: /Users/rriddle/Desktop/llvm/llvm/include/llvm/Transforms/Utils/CodeExtractor.h
===================================================================
--- /Users/rriddle/Desktop/llvm/llvm/include/llvm/Transforms/Utils/CodeExtractor.h
+++ /Users/rriddle/Desktop/llvm/llvm/include/llvm/Transforms/Utils/CodeExtractor.h
@@ -54,6 +54,12 @@
     Type *RetTy;
 
   public:
+
+    /// \brief Check to see if a block is valid for extraction.
+    ///
+    /// Blocks containing EHPads, allocas, invokes, or vastarts are not valid.
+    static bool CodeExtractor::isBlockValidForExtraction(const BasicBlock &BB);
+
     /// \brief Create a code extractor for a single basic block.
     ///
     /// In this formation, we don't require a dominator tree. The given basic
@@ -123,4 +129,4 @@
   };
 }
 
-#endif
+#endif
\ No newline at end of file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22699.65371.patch
Type: text/x-patch
Size: 3922 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160725/212f37b4/attachment.bin>


More information about the llvm-commits mailing list