@@ -292,7 +292,7 @@ for ``IfExprAST``:
292292
293293 // Convert condition to a bool by comparing equal to 0.0.
294294 CondV = Builder.CreateFCmpONE(
295- CondV, ConstantFP::get(getGlobalContext() , APFloat(0.0)), "ifcond");
295+ CondV, ConstantFP::get(LLVMContext , APFloat(0.0)), "ifcond");
296296
297297This code is straightforward and similar to what we saw before. We emit
298298the expression for the condition, then compare that value to zero to get
@@ -305,9 +305,9 @@ a truth value as a 1-bit (bool) value.
305305 // Create blocks for the then and else cases. Insert the 'then' block at the
306306 // end of the function.
307307 BasicBlock *ThenBB =
308- BasicBlock::Create(getGlobalContext() , "then", TheFunction);
309- BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext() , "else");
310- BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext() , "ifcont");
308+ BasicBlock::Create(LLVMContext , "then", TheFunction);
309+ BasicBlock *ElseBB = BasicBlock::Create(LLVMContext , "else");
310+ BasicBlock *MergeBB = BasicBlock::Create(LLVMContext , "ifcont");
311311
312312 Builder.CreateCondBr(CondV, ThenBB, ElseBB);
313313
@@ -400,7 +400,7 @@ code:
400400 TheFunction->getBasicBlockList().push_back(MergeBB);
401401 Builder.SetInsertPoint(MergeBB);
402402 PHINode *PN =
403- Builder.CreatePHI(Type::getDoubleTy(getGlobalContext() ), 2, "iftmp");
403+ Builder.CreatePHI(Type::getDoubleTy(LLVMContext ), 2, "iftmp");
404404
405405 PN->addIncoming(ThenV, ThenBB);
406406 PN->addIncoming(ElseV, ElseBB);
@@ -625,7 +625,7 @@ expression).
625625 Function *TheFunction = Builder.GetInsertBlock()->getParent();
626626 BasicBlock *PreheaderBB = Builder.GetInsertBlock();
627627 BasicBlock *LoopBB =
628- BasicBlock::Create(getGlobalContext() , "loop", TheFunction);
628+ BasicBlock::Create(LLVMContext , "loop", TheFunction);
629629
630630 // Insert an explicit fall through from the current block to the LoopBB.
631631 Builder.CreateBr(LoopBB);
@@ -642,7 +642,7 @@ the two blocks.
642642 Builder.SetInsertPoint(LoopBB);
643643
644644 // Start the PHI node with an entry for Start.
645- PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext() ),
645+ PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(LLVMContext ),
646646 2, VarName.c_str());
647647 Variable->addIncoming(StartVal, PreheaderBB);
648648
@@ -693,7 +693,7 @@ table.
693693 return nullptr;
694694 } else {
695695 // If not specified, use 1.0.
696- StepVal = ConstantFP::get(getGlobalContext() , APFloat(1.0));
696+ StepVal = ConstantFP::get(LLVMContext , APFloat(1.0));
697697 }
698698
699699 Value *NextVar = Builder.CreateFAdd(Variable, StepVal, "nextvar");
@@ -712,7 +712,7 @@ iteration of the loop.
712712
713713 // Convert condition to a bool by comparing equal to 0.0.
714714 EndCond = Builder.CreateFCmpONE(
715- EndCond, ConstantFP::get(getGlobalContext() , APFloat(0.0)), "loopcond");
715+ EndCond, ConstantFP::get(LLVMContext , APFloat(0.0)), "loopcond");
716716
717717Finally, we evaluate the exit value of the loop, to determine whether
718718the loop should exit. This mirrors the condition evaluation for the
@@ -723,7 +723,7 @@ if/then/else statement.
723723 // Create the "after loop" block and insert it.
724724 BasicBlock *LoopEndBB = Builder.GetInsertBlock();
725725 BasicBlock *AfterBB =
726- BasicBlock::Create(getGlobalContext() , "afterloop", TheFunction);
726+ BasicBlock::Create(LLVMContext , "afterloop", TheFunction);
727727
728728 // Insert the conditional branch into the end of LoopEndBB.
729729 Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
@@ -751,7 +751,7 @@ insertion position to it.
751751 NamedValues.erase(VarName);
752752
753753 // for expr always returns 0.0.
754- return Constant::getNullValue(Type::getDoubleTy(getGlobalContext() ));
754+ return Constant::getNullValue(Type::getDoubleTy(LLVMContext ));
755755 }
756756
757757The final code handles various cleanups: now that we have the "NextVar"
0 commit comments