From 5883594589fde14e412e0e743d886203b8a6b530 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Mon, 17 Aug 2009 21:40:03 +0000 Subject: [PATCH] cleanups per review. Mostly cosmetic, plus use SmallVector in place of std::vector. llvm-svn: 79287 --- lib/CodeGen/SjLjEHPrepare.cpp | 40 ++++++++++++++--------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/lib/CodeGen/SjLjEHPrepare.cpp b/lib/CodeGen/SjLjEHPrepare.cpp index 799557accf7..58b5213a0ea 100644 --- a/lib/CodeGen/SjLjEHPrepare.cpp +++ b/lib/CodeGen/SjLjEHPrepare.cpp @@ -25,12 +25,12 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetLowering.h" -#include using namespace llvm; STATISTIC(NumInvokes, "Number of invokes replaced"); @@ -71,7 +71,7 @@ namespace { void markInvokeCallSite(InvokeInst *II, unsigned InvokeNo, Value *CallSite, SwitchInst *CatchSwitch); - void splitLiveRangesLiveAcrossInvokes(std::vector &Invokes); + void splitLiveRangesLiveAcrossInvokes(SmallVector &Invokes); bool insertSjLjEHSupport(Function &F); }; } // end anonymous namespace @@ -165,12 +165,12 @@ static void MarkBlocksLiveIn(BasicBlock *BB, std::set &LiveBBs) { MarkBlocksLiveIn(*PI, LiveBBs); } -// live across unwind edges. Each value that is live across an unwind edge -// we spill into a stack location, guaranteeing that there is nothing live -// across the unwind edge. This process also splits all critical edges -// coming out of invoke's. +/// splitLiveRangesAcrossInvokes - Each value that is live across an unwind edge +/// we spill into a stack location, guaranteeing that there is nothing live +/// across the unwind edge. This process also splits all critical edges +/// coming out of invoke's. void SjLjEHPass:: -splitLiveRangesLiveAcrossInvokes(std::vector &Invokes) { +splitLiveRangesLiveAcrossInvokes(SmallVector &Invokes) { // First step, split all critical edges from invoke instructions. for (unsigned i = 0, e = Invokes.size(); i != e; ++i) { InvokeInst *II = Invokes[i]; @@ -223,7 +223,7 @@ splitLiveRangesLiveAcrossInvokes(std::vector &Invokes) { continue; // Avoid iterator invalidation by copying users to a temporary vector. - std::vector Users; + SmallVector Users; for (Value::use_iterator UI = Inst->use_begin(), E = Inst->use_end(); UI != E; ++UI) { Instruction *User = cast(*UI); @@ -231,11 +231,6 @@ splitLiveRangesLiveAcrossInvokes(std::vector &Invokes) { Users.push_back(User); } - // Scan all of the uses and see if the live range is live across an unwind - // edge. If we find a use live across an invoke edge, create an alloca - // and spill the value. - std::set InvokesWithStoreInserted; - // Find all of the blocks that this value is live in. std::set LiveBBs; LiveBBs.insert(Inst->getParent()); @@ -273,9 +268,9 @@ splitLiveRangesLiveAcrossInvokes(std::vector &Invokes) { } bool SjLjEHPass::insertSjLjEHSupport(Function &F) { - std::vector Returns; - std::vector Unwinds; - std::vector Invokes; + SmallVector Returns; + SmallVector Unwinds; + SmallVector Invokes; // Look through the terminators of the basic blocks to find invokes, returns // and unwinds @@ -346,11 +341,9 @@ bool SjLjEHPass::insertSjLjEHSupport(Function &F) { // SJLJ, we always use the same personality for the whole function, // not on a per-selector basis. // FIXME: That's a bit ugly. Better way? - std::vector EH_Selectors; - std::vector EH_Exceptions; - for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { - // for (unsigned i = 0, e = Invokes.size(); i != e; ++i) { -// BasicBlock *Pad = Invokes[0]->getUnwindDest(); + SmallVector EH_Selectors; + SmallVector EH_Exceptions; + for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { if (CallInst *CI = dyn_cast(I)) { if (CI->getCalledFunction() == Selector32Fn || @@ -381,9 +374,8 @@ bool SjLjEHPass::insertSjLjEHSupport(Function &F) { // the instruction hasn't already been removed. if (!I->getParent()) continue; Value *Val = new LoadInst(ExceptionAddr, "exception", true, I); - Val = CastInst::Create(Instruction::IntToPtr, Val, - PointerType::getUnqual(Type::getInt8Ty(F.getContext())), - "", I); + Type *Ty = PointerType::getUnqual(Type::getInt8Ty(F.getContext())); + Val = CastInst::Create(Instruction::IntToPtr, Val, Ty, "", I); I->replaceAllUsesWith(Val); I->eraseFromParent();