Simplify things a bit more. Fix prototype to use SmallVectorImpl and

change a few SmallVectors to vanilla C arrays.

llvm-svn: 105289
This commit is contained in:
Jim Grosbach 2010-06-01 21:06:46 +00:00
parent 49a372cebc
commit b69c68742a
1 changed files with 17 additions and 17 deletions

View File

@ -96,7 +96,7 @@ namespace {
void createAbortMessage(Module *M); void createAbortMessage(Module *M);
void writeAbortMessage(Instruction *IB); void writeAbortMessage(Instruction *IB);
bool insertCheapEHSupport(Function &F); bool insertCheapEHSupport(Function &F);
void splitLiveRangesLiveAcrossInvokes(SmallVector<InvokeInst*,16> &Invokes); void splitLiveRangesLiveAcrossInvokes(SmallVectorImpl<InvokeInst*>&Invokes);
void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
AllocaInst *InvokeNum, AllocaInst *StackPtr, AllocaInst *InvokeNum, AllocaInst *StackPtr,
SwitchInst *CatchSwitch); SwitchInst *CatchSwitch);
@ -197,8 +197,9 @@ void LowerInvoke::createAbortMessage(Module *M) {
GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true, GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true,
GlobalValue::InternalLinkage, GlobalValue::InternalLinkage,
Msg, "abortmsg"); Msg, "abortmsg");
SmallVector<Constant*,2> GEPIdx(2, Constant *GEPIdx[2] = {
Constant::getNullValue(Type::getInt32Ty(M->getContext()))); ConstantInt::get(Type::getInt32Ty(M->getContext()), 2),
Constant::getNullValue(Type::getInt32Ty(M->getContext())) };
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2);
} else { } else {
// The abort message for cheap EH support tells the user that EH is not // The abort message for cheap EH support tells the user that EH is not
@ -212,8 +213,9 @@ void LowerInvoke::createAbortMessage(Module *M) {
GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true, GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true,
GlobalValue::InternalLinkage, GlobalValue::InternalLinkage,
Msg, "abortmsg"); Msg, "abortmsg");
SmallVector<Constant*,2> GEPIdx(2, Constant::getNullValue( Constant *GEPIdx[2] = {
Type::getInt32Ty(M->getContext()))); ConstantInt::get(Type::getInt32Ty(M->getContext()), 2),
Constant::getNullValue(Type::getInt32Ty(M->getContext())) };
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2);
} }
} }
@ -350,7 +352,7 @@ static void MarkBlocksLiveIn(BasicBlock *BB, std::set<BasicBlock*> &LiveBBs) {
// across the unwind edge. This process also splits all critical edges // across the unwind edge. This process also splits all critical edges
// coming out of invoke's. // coming out of invoke's.
void LowerInvoke:: void LowerInvoke::
splitLiveRangesLiveAcrossInvokes(SmallVector<InvokeInst*,16> &Invokes) { splitLiveRangesLiveAcrossInvokes(SmallVectorImpl<InvokeInst*> &Invokes) {
// First step, split all critical edges from invoke instructions. // First step, split all critical edges from invoke instructions.
for (unsigned i = 0, e = Invokes.size(); i != e; ++i) { for (unsigned i = 0, e = Invokes.size(); i != e; ++i) {
InvokeInst *II = Invokes[i]; InvokeInst *II = Invokes[i];
@ -520,12 +522,11 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
new AllocaInst(JBLinkTy, 0, Align, new AllocaInst(JBLinkTy, 0, Align,
"jblink", F.begin()->begin()); "jblink", F.begin()->begin());
SmallVector<Value*,2> Idx; Value *Idx[] = { Constant::getNullValue(Type::getInt32Ty(F.getContext())),
Idx.push_back(Constant::getNullValue(Type::getInt32Ty(F.getContext()))); ConstantInt::get(Type::getInt32Ty(F.getContext()), 1) };
Idx.push_back(ConstantInt::get(Type::getInt32Ty(F.getContext()), 1)); OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, &Idx[0], &Idx[2],
OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
"OldBuf", "OldBuf",
EntryBB->getTerminator()); EntryBB->getTerminator());
// Copy the JBListHead to the alloca. // Copy the JBListHead to the alloca.
Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true, Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true,
@ -570,7 +571,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
"setjmp.cont"); "setjmp.cont");
Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 0); Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 0);
Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(), Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, &Idx[0], &Idx[2],
"TheJmpBuf", "TheJmpBuf",
EntryBB->getTerminator()); EntryBB->getTerminator());
JmpBufPtr = new BitCastInst(JmpBufPtr, JmpBufPtr = new BitCastInst(JmpBufPtr,
@ -623,16 +624,15 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Create the block to do the longjmp. // Create the block to do the longjmp.
// Get a pointer to the jmpbuf and longjmp. // Get a pointer to the jmpbuf and longjmp.
SmallVector<Value*,2> Idx; Value *Idx[] = { Constant::getNullValue(Type::getInt32Ty(F.getContext())),
Idx.push_back(Constant::getNullValue(Type::getInt32Ty(F.getContext()))); ConstantInt::get(Type::getInt32Ty(F.getContext()), 0) };
Idx.push_back(ConstantInt::get(Type::getInt32Ty(F.getContext()), 0)); Idx[0] = GetElementPtrInst::Create(BufPtr, &Idx[0], &Idx[2], "JmpBuf",
Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
UnwindBlock); UnwindBlock);
Idx[0] = new BitCastInst(Idx[0], Idx[0] = new BitCastInst(Idx[0],
Type::getInt8PtrTy(F.getContext()), Type::getInt8PtrTy(F.getContext()),
"tmp", UnwindBlock); "tmp", UnwindBlock);
Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 1); Idx[1] = ConstantInt::get(Type::getInt32Ty(F.getContext()), 1);
CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock); CallInst::Create(LongJmpFn, &Idx[0], &Idx[2], "", UnwindBlock);
new UnreachableInst(F.getContext(), UnwindBlock); new UnreachableInst(F.getContext(), UnwindBlock);
// Set up the term block ("throw without a catch"). // Set up the term block ("throw without a catch").