forked from OSchip/llvm-project
Centralize basic block creation in CodeGenFunction::createBasicBlock.
- No functionality change. llvm-svn: 59017
This commit is contained in:
parent
ac2af2fdb2
commit
75283ff38a
|
@ -115,8 +115,8 @@ CodeGenFunction::GenerateStaticCXXBlockVarDecl(const VarDecl &D)
|
|||
llvm::Value *nullValue = llvm::Constant::getNullValue(llvm::Type::Int8Ty);
|
||||
llvm::Value *ICmp = Builder.CreateICmpEQ(V, nullValue , "tobool");
|
||||
|
||||
llvm::BasicBlock *InitBlock = llvm::BasicBlock::Create("init");
|
||||
llvm::BasicBlock *EndBlock = llvm::BasicBlock::Create("initend");
|
||||
llvm::BasicBlock *InitBlock = createBasicBlock("init");
|
||||
llvm::BasicBlock *EndBlock = createBasicBlock("initend");
|
||||
|
||||
// If the guard variable is 0, jump to the initializer code.
|
||||
Builder.CreateCondBr(ICmp, InitBlock, EndBlock);
|
||||
|
|
|
@ -229,9 +229,9 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
|
|||
}
|
||||
|
||||
void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) {
|
||||
llvm::BasicBlock *LHSBlock = llvm::BasicBlock::Create("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = llvm::BasicBlock::Create("cond.:");
|
||||
llvm::BasicBlock *ContBlock = llvm::BasicBlock::Create("cond.cont");
|
||||
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.:");
|
||||
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.cont");
|
||||
|
||||
llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
|
||||
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
|
||||
|
|
|
@ -466,9 +466,9 @@ ComplexPairTy ComplexExprEmitter::VisitBinComma(const BinaryOperator *E) {
|
|||
|
||||
ComplexPairTy ComplexExprEmitter::
|
||||
VisitConditionalOperator(const ConditionalOperator *E) {
|
||||
llvm::BasicBlock *LHSBlock = llvm::BasicBlock::Create("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = llvm::BasicBlock::Create("cond.:");
|
||||
llvm::BasicBlock *ContBlock = llvm::BasicBlock::Create("cond.cont");
|
||||
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.:");
|
||||
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.cont");
|
||||
|
||||
llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
|
||||
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
|
||||
|
|
|
@ -1055,8 +1055,8 @@ Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) {
|
|||
Value *ScalarExprEmitter::VisitBinLOr(const BinaryOperator *E) {
|
||||
Value *LHSCond = CGF.EvaluateExprAsBool(E->getLHS());
|
||||
|
||||
llvm::BasicBlock *ContBlock = llvm::BasicBlock::Create("lor_cont");
|
||||
llvm::BasicBlock *RHSBlock = llvm::BasicBlock::Create("lor_rhs");
|
||||
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor_cont");
|
||||
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("lor_rhs");
|
||||
|
||||
llvm::BasicBlock *OrigBlock = Builder.GetInsertBlock();
|
||||
Builder.CreateCondBr(LHSCond, ContBlock, RHSBlock);
|
||||
|
@ -1090,9 +1090,9 @@ Value *ScalarExprEmitter::VisitBinComma(const BinaryOperator *E) {
|
|||
|
||||
Value *ScalarExprEmitter::
|
||||
VisitConditionalOperator(const ConditionalOperator *E) {
|
||||
llvm::BasicBlock *LHSBlock = llvm::BasicBlock::Create("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = llvm::BasicBlock::Create("cond.:");
|
||||
llvm::BasicBlock *ContBlock = llvm::BasicBlock::Create("cond.cont");
|
||||
llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.?");
|
||||
llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.:");
|
||||
llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.cont");
|
||||
|
||||
// Evaluate the conditional, then convert it to bool. We do this explicitly
|
||||
// because we need the unconverted value if this is a GNU ?: expression with
|
||||
|
|
|
@ -389,9 +389,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
|
|||
llvm::Value *LimitPtr = CreateTempAlloca(UnsignedLongLTy, "limit.ptr");
|
||||
Builder.CreateStore(CountRV.getScalarVal(), LimitPtr);
|
||||
|
||||
llvm::BasicBlock *NoElements = llvm::BasicBlock::Create("noelements");
|
||||
llvm::BasicBlock *SetStartMutations =
|
||||
llvm::BasicBlock::Create("setstartmutations");
|
||||
llvm::BasicBlock *NoElements = createBasicBlock("noelements");
|
||||
llvm::BasicBlock *SetStartMutations = createBasicBlock("setstartmutations");
|
||||
|
||||
llvm::Value *Limit = Builder.CreateLoad(LimitPtr);
|
||||
llvm::Value *Zero = llvm::Constant::getNullValue(UnsignedLongLTy);
|
||||
|
@ -414,13 +413,13 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
|
|||
|
||||
Builder.CreateStore(StateMutations, StartMutationsPtr);
|
||||
|
||||
llvm::BasicBlock *LoopStart = llvm::BasicBlock::Create("loopstart");
|
||||
llvm::BasicBlock *LoopStart = createBasicBlock("loopstart");
|
||||
EmitBlock(LoopStart);
|
||||
|
||||
llvm::Value *CounterPtr = CreateTempAlloca(UnsignedLongLTy, "counter.ptr");
|
||||
Builder.CreateStore(Zero, CounterPtr);
|
||||
|
||||
llvm::BasicBlock *LoopBody = llvm::BasicBlock::Create("loopbody");
|
||||
llvm::BasicBlock *LoopBody = createBasicBlock("loopbody");
|
||||
EmitBlock(LoopBody);
|
||||
|
||||
StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr, "mutationsptr");
|
||||
|
@ -433,8 +432,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
|
|||
"tobool");
|
||||
|
||||
|
||||
llvm::BasicBlock *WasMutated = llvm::BasicBlock::Create("wasmutated");
|
||||
llvm::BasicBlock *WasNotMutated = llvm::BasicBlock::Create("wasnotmutated");
|
||||
llvm::BasicBlock *WasMutated = createBasicBlock("wasmutated");
|
||||
llvm::BasicBlock *WasNotMutated = createBasicBlock("wasnotmutated");
|
||||
|
||||
Builder.CreateCondBr(MutationsEqual, WasNotMutated, WasMutated);
|
||||
|
||||
|
@ -477,8 +476,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
|
|||
llvm::ConstantInt::get(UnsignedLongLTy, 1));
|
||||
Builder.CreateStore(Counter, CounterPtr);
|
||||
|
||||
llvm::BasicBlock *LoopEnd = llvm::BasicBlock::Create("loopend");
|
||||
llvm::BasicBlock *AfterBody = llvm::BasicBlock::Create("afterbody");
|
||||
llvm::BasicBlock *LoopEnd = createBasicBlock("loopend");
|
||||
llvm::BasicBlock *AfterBody = createBasicBlock("afterbody");
|
||||
|
||||
BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody));
|
||||
|
||||
|
@ -488,7 +487,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
|
|||
|
||||
EmitBlock(AfterBody);
|
||||
|
||||
llvm::BasicBlock *FetchMore = llvm::BasicBlock::Create("fetchmore");
|
||||
llvm::BasicBlock *FetchMore = createBasicBlock("fetchmore");
|
||||
|
||||
llvm::Value *IsLess = Builder.CreateICmpULT(Counter, Limit, "isless");
|
||||
Builder.CreateCondBr(IsLess, LoopBody, FetchMore);
|
||||
|
|
|
@ -1523,16 +1523,16 @@ destination.
|
|||
void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
|
||||
const ObjCAtTryStmt &S) {
|
||||
// Create various blocks we refer to for handling @finally.
|
||||
llvm::BasicBlock *FinallyBlock = llvm::BasicBlock::Create("finally");
|
||||
llvm::BasicBlock *FinallyNoExit = llvm::BasicBlock::Create("finally.noexit");
|
||||
llvm::BasicBlock *FinallyRethrow = llvm::BasicBlock::Create("finally.throw");
|
||||
llvm::BasicBlock *FinallyEnd = llvm::BasicBlock::Create("finally.end");
|
||||
llvm::BasicBlock *FinallyBlock = CGF.createBasicBlock("finally");
|
||||
llvm::BasicBlock *FinallyNoExit = CGF.createBasicBlock("finally.noexit");
|
||||
llvm::BasicBlock *FinallyRethrow = CGF.createBasicBlock("finally.throw");
|
||||
llvm::BasicBlock *FinallyEnd = CGF.createBasicBlock("finally.end");
|
||||
llvm::Value *DestCode =
|
||||
CGF.CreateTempAlloca(llvm::Type::Int32Ty, "finally.dst");
|
||||
|
||||
// Generate jump code. Done here so we can directly add things to
|
||||
// the switch instruction.
|
||||
llvm::BasicBlock *FinallyJump = llvm::BasicBlock::Create("finally.jump");
|
||||
llvm::BasicBlock *FinallyJump = CGF.createBasicBlock("finally.jump");
|
||||
llvm::SwitchInst *FinallySwitch =
|
||||
llvm::SwitchInst::Create(new llvm::LoadInst(DestCode, "", FinallyJump),
|
||||
FinallyEnd, 10, FinallyJump);
|
||||
|
@ -1557,8 +1557,8 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
|
|||
llvm::Value *SetJmpResult = CGF.Builder.CreateCall(ObjCTypes.SetJmpFn,
|
||||
JmpBufPtr, "result");
|
||||
|
||||
llvm::BasicBlock *TryBlock = llvm::BasicBlock::Create("try");
|
||||
llvm::BasicBlock *TryHandler = llvm::BasicBlock::Create("try.handler");
|
||||
llvm::BasicBlock *TryBlock = CGF.createBasicBlock("try");
|
||||
llvm::BasicBlock *TryHandler = CGF.createBasicBlock("try.handler");
|
||||
CGF.Builder.CreateCondBr(CGF.Builder.CreateIsNotNull(SetJmpResult, "threw"),
|
||||
TryHandler, TryBlock);
|
||||
|
||||
|
@ -1585,8 +1585,8 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
|
|||
JmpBufPtr, "result");
|
||||
llvm::Value *Threw = CGF.Builder.CreateIsNotNull(SetJmpResult, "threw");
|
||||
|
||||
llvm::BasicBlock *CatchBlock = llvm::BasicBlock::Create("catch");
|
||||
llvm::BasicBlock *CatchHandler = llvm::BasicBlock::Create("catch.handler");
|
||||
llvm::BasicBlock *CatchBlock = CGF.createBasicBlock("catch");
|
||||
llvm::BasicBlock *CatchHandler = CGF.createBasicBlock("catch.handler");
|
||||
CGF.Builder.CreateCondBr(Threw, CatchHandler, CatchBlock);
|
||||
|
||||
CGF.EmitBlock(CatchBlock);
|
||||
|
@ -1596,7 +1596,7 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
|
|||
// so.
|
||||
bool AllMatched = false;
|
||||
for (; CatchStmt; CatchStmt = CatchStmt->getNextCatchStmt()) {
|
||||
llvm::BasicBlock *NextCatchBlock = llvm::BasicBlock::Create("catch");
|
||||
llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch");
|
||||
|
||||
const DeclStmt *CatchParam =
|
||||
cast_or_null<DeclStmt>(CatchStmt->getCatchParamStmt());
|
||||
|
@ -1640,7 +1640,7 @@ void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
|
|||
llvm::Value *Match = CGF.Builder.CreateCall2(ObjCTypes.ExceptionMatchFn,
|
||||
Class, Caught, "match");
|
||||
|
||||
llvm::BasicBlock *MatchedBlock = llvm::BasicBlock::Create("matched");
|
||||
llvm::BasicBlock *MatchedBlock = CGF.createBasicBlock("matched");
|
||||
|
||||
CGF.Builder.CreateCondBr(CGF.Builder.CreateIsNotNull(Match, "matched"),
|
||||
MatchedBlock, NextCatchBlock);
|
||||
|
@ -1717,7 +1717,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
|
|||
|
||||
CGF.Builder.CreateCall(ObjCTypes.ExceptionThrowFn, ExceptionAsObject);
|
||||
CGF.Builder.CreateUnreachable();
|
||||
CGF.EmitBlock(llvm::BasicBlock::Create("bb"));
|
||||
CGF.EmitBlock(CGF.createBasicBlock("bb"));
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitJumpThroughFinally(ObjCEHEntry *E,
|
||||
|
|
|
@ -189,7 +189,7 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
|
|||
|
||||
// Emit a block after the branch so that dead code after a goto has some place
|
||||
// to go.
|
||||
Builder.SetInsertPoint(llvm::BasicBlock::Create("", CurFn));
|
||||
Builder.SetInsertPoint(createBasicBlock("", CurFn));
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
|
||||
|
@ -210,7 +210,7 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
|
|||
|
||||
// Emit a block after the branch so that dead code after a goto has some place
|
||||
// to go.
|
||||
Builder.SetInsertPoint(llvm::BasicBlock::Create("", CurFn));
|
||||
Builder.SetInsertPoint(createBasicBlock("", CurFn));
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
|
||||
|
@ -221,12 +221,12 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
|
|||
// unequal to 0. The condition must be a scalar type.
|
||||
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
|
||||
|
||||
llvm::BasicBlock *ContBlock = llvm::BasicBlock::Create("ifend");
|
||||
llvm::BasicBlock *ThenBlock = llvm::BasicBlock::Create("ifthen");
|
||||
llvm::BasicBlock *ContBlock = createBasicBlock("ifend");
|
||||
llvm::BasicBlock *ThenBlock = createBasicBlock("ifthen");
|
||||
llvm::BasicBlock *ElseBlock = ContBlock;
|
||||
|
||||
if (S.getElse())
|
||||
ElseBlock = llvm::BasicBlock::Create("ifelse");
|
||||
ElseBlock = createBasicBlock("ifelse");
|
||||
|
||||
// Insert the conditional branch.
|
||||
Builder.CreateCondBr(BoolCondVal, ThenBlock, ElseBlock);
|
||||
|
@ -262,7 +262,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
|
|||
void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
|
||||
// Emit the header for the loop, insert it, which will create an uncond br to
|
||||
// it.
|
||||
llvm::BasicBlock *LoopHeader = llvm::BasicBlock::Create("whilecond");
|
||||
llvm::BasicBlock *LoopHeader = createBasicBlock("whilecond");
|
||||
EmitBlock(LoopHeader);
|
||||
|
||||
// Evaluate the conditional in the while header. C99 6.8.5.1: The evaluation
|
||||
|
@ -279,8 +279,8 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
|
|||
|
||||
// Create an exit block for when the condition fails, create a block for the
|
||||
// body of the loop.
|
||||
llvm::BasicBlock *ExitBlock = llvm::BasicBlock::Create("whileexit");
|
||||
llvm::BasicBlock *LoopBody = llvm::BasicBlock::Create("whilebody");
|
||||
llvm::BasicBlock *ExitBlock = createBasicBlock("whileexit");
|
||||
llvm::BasicBlock *LoopBody = createBasicBlock("whilebody");
|
||||
|
||||
// As long as the condition is true, go to the loop body.
|
||||
if (EmitBoolCondBranch)
|
||||
|
@ -313,11 +313,11 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S) {
|
|||
void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
|
||||
// Emit the body for the loop, insert it, which will create an uncond br to
|
||||
// it.
|
||||
llvm::BasicBlock *LoopBody = llvm::BasicBlock::Create("dobody");
|
||||
llvm::BasicBlock *AfterDo = llvm::BasicBlock::Create("afterdo");
|
||||
llvm::BasicBlock *LoopBody = createBasicBlock("dobody");
|
||||
llvm::BasicBlock *AfterDo = createBasicBlock("afterdo");
|
||||
EmitBlock(LoopBody);
|
||||
|
||||
llvm::BasicBlock *DoCond = llvm::BasicBlock::Create("docond");
|
||||
llvm::BasicBlock *DoCond = createBasicBlock("docond");
|
||||
|
||||
// Store the blocks to use for break and continue.
|
||||
BreakContinueStack.push_back(BreakContinue(AfterDo, DoCond));
|
||||
|
@ -371,8 +371,8 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
|||
EmitStmt(S.getInit());
|
||||
|
||||
// Start the loop with a block that tests the condition.
|
||||
llvm::BasicBlock *CondBlock = llvm::BasicBlock::Create("forcond");
|
||||
llvm::BasicBlock *AfterFor = llvm::BasicBlock::Create("afterfor");
|
||||
llvm::BasicBlock *CondBlock = createBasicBlock("forcond");
|
||||
llvm::BasicBlock *AfterFor = createBasicBlock("afterfor");
|
||||
|
||||
EmitBlock(CondBlock);
|
||||
|
||||
|
@ -384,7 +384,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
|||
llvm::Value *BoolCondVal = EvaluateExprAsBool(S.getCond());
|
||||
|
||||
// As long as the condition is true, iterate the loop.
|
||||
llvm::BasicBlock *ForBody = llvm::BasicBlock::Create("forbody");
|
||||
llvm::BasicBlock *ForBody = createBasicBlock("forbody");
|
||||
Builder.CreateCondBr(BoolCondVal, ForBody, AfterFor);
|
||||
EmitBlock(ForBody);
|
||||
} else {
|
||||
|
@ -396,7 +396,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
|
|||
// condition as the continue block.
|
||||
llvm::BasicBlock *ContinueBlock;
|
||||
if (S.getInc())
|
||||
ContinueBlock = llvm::BasicBlock::Create("forinc");
|
||||
ContinueBlock = createBasicBlock("forinc");
|
||||
else
|
||||
ContinueBlock = CondBlock;
|
||||
|
||||
|
@ -433,7 +433,7 @@ void CodeGenFunction::EmitReturnOfRValue(RValue RV, QualType Ty) {
|
|||
|
||||
// Emit a block after the branch so that dead code after a return has some
|
||||
// place to go.
|
||||
EmitBlock(llvm::BasicBlock::Create());
|
||||
EmitBlock(createBasicBlock());
|
||||
}
|
||||
|
||||
/// EmitReturnStmt - Note that due to GCC extensions, this can have an operand
|
||||
|
@ -463,7 +463,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
|
|||
if (!ObjCEHStack.empty()) {
|
||||
for (ObjCEHStackType::reverse_iterator i = ObjCEHStack.rbegin(),
|
||||
e = ObjCEHStack.rend(); i != e; ++i) {
|
||||
llvm::BasicBlock *ReturnPad = llvm::BasicBlock::Create("return.pad");
|
||||
llvm::BasicBlock *ReturnPad = createBasicBlock("return.pad");
|
||||
EmitJumpThroughFinally(*i, ReturnPad);
|
||||
EmitBlock(ReturnPad);
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
|
|||
|
||||
// Emit a block after the branch so that dead code after a return has some
|
||||
// place to go.
|
||||
EmitBlock(llvm::BasicBlock::Create());
|
||||
EmitBlock(createBasicBlock());
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
|
||||
|
@ -487,7 +487,7 @@ void CodeGenFunction::EmitBreakStmt() {
|
|||
|
||||
llvm::BasicBlock *Block = BreakContinueStack.back().BreakBlock;
|
||||
Builder.CreateBr(Block);
|
||||
EmitBlock(llvm::BasicBlock::Create());
|
||||
EmitBlock(createBasicBlock());
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitContinueStmt() {
|
||||
|
@ -495,7 +495,7 @@ void CodeGenFunction::EmitContinueStmt() {
|
|||
|
||||
llvm::BasicBlock *Block = BreakContinueStack.back().ContinueBlock;
|
||||
Builder.CreateBr(Block);
|
||||
EmitBlock(llvm::BasicBlock::Create());
|
||||
EmitBlock(createBasicBlock());
|
||||
}
|
||||
|
||||
/// EmitCaseStmtRange - If case statement range is not too big then
|
||||
|
@ -537,7 +537,7 @@ void CodeGenFunction::EmitCaseStmtRange(const CaseStmt &S) {
|
|||
// in the default basic block). The switch's default will be changed
|
||||
// to the top of this chain after switch emission is complete.
|
||||
llvm::BasicBlock *FalseDest = CaseRangeBlock;
|
||||
CaseRangeBlock = llvm::BasicBlock::Create("sw.caserange");
|
||||
CaseRangeBlock = createBasicBlock("sw.caserange");
|
||||
|
||||
CurFn->getBasicBlockList().push_back(CaseRangeBlock);
|
||||
Builder.SetInsertPoint(CaseRangeBlock);
|
||||
|
@ -563,14 +563,14 @@ void CodeGenFunction::EmitCaseStmt(const CaseStmt &S) {
|
|||
StartBlock("sw.bb");
|
||||
llvm::BasicBlock *CaseDest = Builder.GetInsertBlock();
|
||||
llvm::APSInt CaseVal = S.getLHS()->getIntegerConstantExprValue(getContext());
|
||||
SwitchInsn->addCase(llvm::ConstantInt::get(CaseVal),
|
||||
CaseDest);
|
||||
SwitchInsn->addCase(llvm::ConstantInt::get(CaseVal), CaseDest);
|
||||
EmitStmt(S.getSubStmt());
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
|
||||
llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
|
||||
assert(DefaultBlock->empty() && "EmitDefaultStmt: Default block already defined?");
|
||||
assert(DefaultBlock->empty() &&
|
||||
"EmitDefaultStmt: Default block already defined?");
|
||||
EmitBlock(DefaultBlock);
|
||||
EmitStmt(S.getSubStmt());
|
||||
}
|
||||
|
@ -586,8 +586,8 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
|
|||
// statement. We also need to create a default block now so that
|
||||
// explicit case ranges tests can have a place to jump to on
|
||||
// failure.
|
||||
llvm::BasicBlock *NextBlock = llvm::BasicBlock::Create("sw.epilog");
|
||||
llvm::BasicBlock *DefaultBlock = llvm::BasicBlock::Create("sw.default");
|
||||
llvm::BasicBlock *NextBlock = createBasicBlock("sw.epilog");
|
||||
llvm::BasicBlock *DefaultBlock = createBasicBlock("sw.default");
|
||||
SwitchInsn = Builder.CreateSwitch(CondV, DefaultBlock);
|
||||
CaseRangeBlock = DefaultBlock;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ llvm::BasicBlock *CodeGenFunction::getBasicBlockForLabel(const LabelStmt *S) {
|
|||
if (BB) return BB;
|
||||
|
||||
// Create, but don't insert, the new block.
|
||||
return BB = llvm::BasicBlock::Create(S->getName());
|
||||
return BB = createBasicBlock(S->getName());
|
||||
}
|
||||
|
||||
llvm::Constant *
|
||||
|
@ -98,7 +98,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
|
|||
CurFn = Fn;
|
||||
assert(CurFn->isDeclaration() && "Function already has body?");
|
||||
|
||||
llvm::BasicBlock *EntryBB = llvm::BasicBlock::Create("entry", CurFn);
|
||||
llvm::BasicBlock *EntryBB = createBasicBlock("entry", CurFn);
|
||||
|
||||
// Create a marker to make it easy to insert allocas into the entryblock
|
||||
// later. Don't create this with the builder, because we don't want it
|
||||
|
@ -107,7 +107,7 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
|
|||
AllocaInsertPt = new llvm::BitCastInst(Undef, llvm::Type::Int32Ty, "allocapt",
|
||||
EntryBB);
|
||||
|
||||
ReturnBlock = llvm::BasicBlock::Create("return");
|
||||
ReturnBlock = createBasicBlock("return");
|
||||
ReturnValue = 0;
|
||||
if (!RetTy->isVoidType())
|
||||
ReturnValue = CreateTempAlloca(ConvertType(RetTy), "retval");
|
||||
|
@ -168,7 +168,7 @@ bool CodeGenFunction::isDummyBlock(const llvm::BasicBlock *BB) {
|
|||
void CodeGenFunction::StartBlock(const char *N) {
|
||||
llvm::BasicBlock *BB = Builder.GetInsertBlock();
|
||||
if (!isDummyBlock(BB))
|
||||
EmitBlock(llvm::BasicBlock::Create(N));
|
||||
EmitBlock(createBasicBlock(N));
|
||||
else
|
||||
BB->setName(N);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ void CodeGenFunction::EmitIndirectSwitches() {
|
|||
} else {
|
||||
// No possible targets for indirect goto, just emit an infinite
|
||||
// loop.
|
||||
Default = llvm::BasicBlock::Create("indirectgoto.loop", CurFn);
|
||||
Default = createBasicBlock("indirectgoto.loop", CurFn);
|
||||
llvm::BranchInst::Create(Default, Default);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,12 +212,18 @@ public:
|
|||
/// hasAggregateLLVMType - Return true if the specified AST type will map into
|
||||
/// an aggregate LLVM type or is void.
|
||||
static bool hasAggregateLLVMType(QualType T);
|
||||
|
||||
|
||||
/// createBasicBlock - Create an LLVM basic block.
|
||||
llvm::BasicBlock *createBasicBlock(const char *Name="",
|
||||
llvm::Function *Parent=0,
|
||||
llvm::BasicBlock *InsertBefore=0) {
|
||||
return llvm::BasicBlock::Create(Name, Parent, InsertBefore);
|
||||
}
|
||||
|
||||
/// getBasicBlockForLabel - Return the LLVM basicblock that the specified
|
||||
/// label maps to.
|
||||
llvm::BasicBlock *getBasicBlockForLabel(const LabelStmt *S);
|
||||
|
||||
|
||||
void EmitBlock(llvm::BasicBlock *BB);
|
||||
|
||||
/// ErrorUnsupported - Print out an error that codegen doesn't support the
|
||||
|
|
Loading…
Reference in New Issue