From 9968808357f06c1391d8b94abfbd0c1b9348eb57 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 27 Jul 2016 08:02:46 +0000 Subject: [PATCH] Refactor - CodeExtractor : Move check for valid block to static utility This lets you actually check to see if a block is valid before trying to extract. Patch by River Riddle! Differential Revision: https://reviews.llvm.org/D22699 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276846 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/CodeExtractor.h | 6 ++++++ lib/Transforms/Utils/CodeExtractor.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/llvm/Transforms/Utils/CodeExtractor.h b/include/llvm/Transforms/Utils/CodeExtractor.h index 30dafd045f2..970b3a1b7c5 100644 --- a/include/llvm/Transforms/Utils/CodeExtractor.h +++ b/include/llvm/Transforms/Utils/CodeExtractor.h @@ -54,6 +54,12 @@ template class ArrayRef; 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 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 diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 9f2181f87ce..772403e2a68 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -49,7 +49,7 @@ AggregateArgsOpt("aggregate-extracted-args", cl::Hidden, 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 @@ static SetVector buildExtractionBlockSet(IteratorT BBBegin, if (!Result.insert(*BBBegin)) llvm_unreachable("Repeated basic blocks in extraction input"); - if (!isBlockValidForExtraction(**BBBegin)) { + if (!CodeExtractor::isBlockValidForExtraction(**BBBegin)) { Result.clear(); return Result; } -- 2.11.0