From: Bill Wendling Date: Tue, 20 Sep 2011 18:42:07 +0000 (+0000) Subject: Use ArrayRef instead of 'const std::vector' to pass around the list of basic blocks... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=51bae90289c1ae6766a67295c10f6c4339a8cca0 Use ArrayRef instead of 'const std::vector' to pass around the list of basic blocks to extract. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140168 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 8dacac08a18..6539977ef08 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -55,9 +55,9 @@ namespace { CodeExtractor(DominatorTree* dt = 0, bool AggArgs = false) : DT(dt), AggregateArgs(AggArgs||AggregateArgsOpt), NumExitBlocks(~0U) {} - Function *ExtractCodeRegion(const std::vector &code); + Function *ExtractCodeRegion(ArrayRef code); - bool isEligible(const std::vector &code); + bool isEligible(ArrayRef code); private: /// definedInRegion - Return true if the specified value is defined in the @@ -654,7 +654,7 @@ void CodeExtractor::moveCodeToFunction(Function *newFunction) { /// computed result back into memory. /// Function *CodeExtractor:: -ExtractCodeRegion(const std::vector &code) { +ExtractCodeRegion(ArrayRef code) { if (!isEligible(code)) return 0; @@ -754,9 +754,13 @@ ExtractCodeRegion(const std::vector &code) { return newFunction; } -bool CodeExtractor::isEligible(const std::vector &code) { +bool CodeExtractor::isEligible(ArrayRef code) { + // Deny a single basic block that's a landing pad block. + if (code.size() == 1 && code[0]->isLandingPad()) + return false; + // Deny code region if it contains allocas or vastarts. - for (std::vector::const_iterator BB = code.begin(), e=code.end(); + for (ArrayRef::iterator BB = code.begin(), e=code.end(); BB != e; ++BB) for (BasicBlock::const_iterator I = (*BB)->begin(), Ie = (*BB)->end(); I != Ie; ++I) @@ -788,7 +792,5 @@ Function* llvm::ExtractLoop(DominatorTree &DT, Loop *L, bool AggregateArgs) { /// ExtractBasicBlock - Slurp a basic block into a brand new function. /// Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) { - std::vector Blocks; - Blocks.push_back(BB); - return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks); + return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(BB); }