From 1d0be15f89cb5056e20e2d24faa8d6afb1573bca Mon Sep 17 00:00:00 2001
From: Owen Anderson
Date: Thu, 13 Aug 2009 21:58:54 +0000
Subject: [PATCH] Push LLVMContexts through the IntegerType APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
---
docs/tutorial/JITTutorial1.html | 2 +-
docs/tutorial/JITTutorial2.html | 10 +-
docs/tutorial/LangImpl3.html | 16 +-
docs/tutorial/LangImpl4.html | 8 +-
docs/tutorial/LangImpl5.html | 40 ++--
docs/tutorial/LangImpl6.html | 28 +--
docs/tutorial/LangImpl7.html | 26 +--
examples/BrainF/BrainF.cpp | 44 ++--
examples/BrainF/BrainFDriver.cpp | 10 +-
examples/Fibonacci/fibonacci.cpp | 17 +-
examples/HowToUseJIT/HowToUseJIT.cpp | 18 +-
examples/Kaleidoscope/toy.cpp | 29 ++-
examples/ModuleMaker/ModuleMaker.cpp | 10 +-
examples/ParallelJIT/ParallelJIT.cpp | 28 ++-
include/llvm/BasicBlock.h | 10 +-
include/llvm/Constants.h | 3 +-
include/llvm/DerivedTypes.h | 8 +-
include/llvm/InstrTypes.h | 5 +-
include/llvm/Instructions.h | 29 +--
include/llvm/LLVMContext.h | 3 +
include/llvm/LinkAllVMCore.h | 2 +-
include/llvm/Metadata.h | 31 +--
include/llvm/Support/IRBuilder.h | 42 ++--
include/llvm/Support/TypeBuilder.h | 28 +--
include/llvm/Target/TargetData.h | 3 +-
include/llvm/Type.h | 20 +-
lib/Analysis/BasicAliasAnalysis.cpp | 25 ++-
lib/Analysis/CaptureTracking.cpp | 2 +-
lib/Analysis/ConstantFolding.cpp | 31 +--
lib/Analysis/DebugInfo.cpp | 72 +++---
lib/Analysis/LoopDependenceAnalysis.cpp | 2 +-
lib/Analysis/LoopVR.cpp | 6 +-
lib/Analysis/PointerTracking.cpp | 25 ++-
lib/Analysis/ScalarEvolution.cpp | 22 +-
lib/Analysis/ScalarEvolutionExpander.cpp | 5 +-
lib/Analysis/ValueTracking.cpp | 11 +-
lib/AsmParser/LLLexer.cpp | 18 +-
lib/AsmParser/LLParser.cpp | 116 +++++-----
lib/Bitcode/Reader/BitcodeReader.cpp | 84 +++----
lib/Bitcode/Reader/BitcodeReader.h | 2 +-
lib/Bitcode/Writer/BitcodeWriter.cpp | 12 +-
lib/Bitcode/Writer/ValueEnumerator.cpp | 7 +-
lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 16 +-
lib/CodeGen/DwarfEHPrepare.cpp | 15 +-
lib/CodeGen/ELFWriter.cpp | 16 +-
lib/CodeGen/IntrinsicLowering.cpp | 84 +++----
lib/CodeGen/MachineFunction.cpp | 3 +-
lib/CodeGen/MachineInstr.cpp | 2 +-
lib/CodeGen/PseudoSourceValue.cpp | 7 +-
lib/CodeGen/SelectionDAG/FastISel.cpp | 3 +-
lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 5 +-
lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 +-
.../SelectionDAG/SelectionDAGBuild.cpp | 28 ++-
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 2 +-
lib/CodeGen/SelectionDAG/TargetLowering.cpp | 5 +-
lib/CodeGen/ShadowStackGC.cpp | 33 +--
lib/CodeGen/StackProtector.cpp | 11 +-
lib/ExecutionEngine/ExecutionEngine.cpp | 45 ++--
lib/ExecutionEngine/Interpreter/Execution.cpp | 25 ++-
.../Interpreter/ExternalFunctions.cpp | 21 +-
lib/ExecutionEngine/JIT/JIT.cpp | 24 +-
lib/Target/ARM/ARMBaseRegisterInfo.cpp | 3 +-
lib/Target/ARM/ARMCodeEmitter.cpp | 4 +-
lib/Target/ARM/ARMConstantPoolValue.cpp | 7 +-
lib/Target/ARM/ARMConstantPoolValue.h | 3 +-
lib/Target/ARM/ARMISelDAGToDAG.cpp | 3 +-
lib/Target/ARM/ARMISelLowering.cpp | 13 +-
lib/Target/ARM/ARMLoadStoreOptimizer.cpp | 5 +-
lib/Target/ARM/Thumb1RegisterInfo.cpp | 3 +-
lib/Target/ARM/Thumb2RegisterInfo.cpp | 3 +-
lib/Target/Alpha/AlphaISelDAGToDAG.cpp | 3 +-
lib/Target/CBackend/CBackend.cpp | 77 ++++---
lib/Target/CppBackend/CPPBackend.cpp | 12 +-
lib/Target/MSIL/MSILWriter.cpp | 10 +-
lib/Target/PowerPC/PPCISelLowering.cpp | 3 +-
lib/Target/Target.cpp | 2 +-
lib/Target/TargetData.cpp | 7 +-
lib/Target/X86/X86FastISel.cpp | 27 +--
lib/Target/X86/X86FloatingPointRegKill.cpp | 5 +-
lib/Target/X86/X86ISelLowering.cpp | 19 +-
lib/Target/X86/X86InstrInfo.cpp | 3 +-
lib/Target/XCore/XCoreISelDAGToDAG.cpp | 3 +-
lib/Target/XCore/XCoreISelLowering.cpp | 6 +-
lib/Transforms/IPO/ArgumentPromotion.cpp | 21 +-
.../IPO/DeadArgumentElimination.cpp | 20 +-
lib/Transforms/IPO/ExtractGV.cpp | 3 +-
lib/Transforms/IPO/GlobalOpt.cpp | 45 ++--
lib/Transforms/IPO/IPConstantPropagation.cpp | 2 +-
lib/Transforms/IPO/IndMemRemoval.cpp | 13 +-
lib/Transforms/IPO/LowerSetJmp.cpp | 62 +++--
lib/Transforms/IPO/MergeFunctions.cpp | 10 +-
lib/Transforms/IPO/PruneEH.cpp | 2 +-
lib/Transforms/IPO/RaiseAllocations.cpp | 43 ++--
lib/Transforms/IPO/StructRetPromotion.cpp | 7 +-
.../Instrumentation/BlockProfiling.cpp | 5 +-
.../Instrumentation/EdgeProfiling.cpp | 2 +-
.../Instrumentation/ProfilingUtils.cpp | 35 +--
.../Instrumentation/RSProfiling.cpp | 36 +--
lib/Transforms/Scalar/CodeGenPrepare.cpp | 3 +-
lib/Transforms/Scalar/CondPropagate.cpp | 2 +-
lib/Transforms/Scalar/GVN.cpp | 3 +-
lib/Transforms/Scalar/IndVarSimplify.cpp | 18 +-
.../Scalar/InstructionCombining.cpp | 212 +++++++++---------
lib/Transforms/Scalar/JumpThreading.cpp | 11 +-
lib/Transforms/Scalar/LICM.cpp | 2 +-
lib/Transforms/Scalar/LoopIndexSplit.cpp | 3 +-
lib/Transforms/Scalar/LoopRotation.cpp | 3 +-
lib/Transforms/Scalar/LoopStrengthReduce.cpp | 21 +-
lib/Transforms/Scalar/LoopUnswitch.cpp | 20 +-
lib/Transforms/Scalar/MemCpyOptimizer.cpp | 20 +-
lib/Transforms/Scalar/PredicateSimplifier.cpp | 9 +-
lib/Transforms/Scalar/Reg2Mem.cpp | 3 +-
lib/Transforms/Scalar/SCCP.cpp | 12 +-
.../Scalar/ScalarReplAggregates.cpp | 59 +++--
lib/Transforms/Scalar/SimplifyCFGPass.cpp | 2 +-
lib/Transforms/Scalar/SimplifyLibCalls.cpp | 183 +++++++--------
.../Scalar/TailRecursionElimination.cpp | 2 +-
lib/Transforms/Utils/BasicBlockUtils.cpp | 8 +-
lib/Transforms/Utils/BreakCriticalEdges.cpp | 4 +-
lib/Transforms/Utils/CloneFunction.cpp | 4 +-
lib/Transforms/Utils/CodeExtractor.cpp | 54 +++--
lib/Transforms/Utils/InlineFunction.cpp | 12 +-
lib/Transforms/Utils/InstructionNamer.cpp | 4 +-
lib/Transforms/Utils/LoopSimplify.cpp | 5 +-
lib/Transforms/Utils/LowerAllocations.cpp | 13 +-
lib/Transforms/Utils/LowerInvoke.cpp | 71 +++---
lib/Transforms/Utils/LowerSwitch.cpp | 6 +-
lib/Transforms/Utils/SSI.cpp | 2 +-
lib/Transforms/Utils/SimplifyCFG.cpp | 30 +--
.../Utils/UnifyFunctionExitNodes.cpp | 18 +-
lib/VMCore/AsmWriter.cpp | 16 +-
lib/VMCore/AutoUpgrade.cpp | 41 ++--
lib/VMCore/BasicBlock.cpp | 7 +-
lib/VMCore/ConstantFold.cpp | 92 ++++----
lib/VMCore/Constants.cpp | 71 +++---
lib/VMCore/ConstantsContext.h | 2 +-
lib/VMCore/Core.cpp | 68 ++++--
lib/VMCore/Function.cpp | 2 +-
lib/VMCore/InlineAsm.cpp | 2 +-
lib/VMCore/Instructions.cpp | 100 +++++----
lib/VMCore/Metadata.cpp | 16 +-
lib/VMCore/Module.cpp | 7 +-
lib/VMCore/Type.cpp | 148 ++++++++----
lib/VMCore/Value.cpp | 9 +-
lib/VMCore/ValueTypes.cpp | 66 +++---
lib/VMCore/Verifier.cpp | 34 +--
tools/bugpoint/CrashDebugger.cpp | 9 +-
tools/bugpoint/ExtractFunction.cpp | 5 +-
tools/bugpoint/Miscompilation.cpp | 29 ++-
tools/lli/lli.cpp | 5 +-
.../ExecutionEngine/ExecutionEngineTest.cpp | 12 +-
.../JIT/JITEventListenerTest.cpp | 4 +-
.../JIT/JITMemoryManagerTest.cpp | 3 +-
unittests/ExecutionEngine/JIT/JITTest.cpp | 4 +-
unittests/Support/TypeBuilderTest.cpp | 122 +++++-----
unittests/Support/ValueHandleTest.cpp | 20 +-
unittests/VMCore/ConstantsTest.cpp | 4 +-
unittests/VMCore/MetadataTest.cpp | 10 +-
unittests/VMCore/PassManagerTest.cpp | 34 +--
utils/TableGen/IntrinsicEmitter.cpp | 18 +-
160 files changed, 1985 insertions(+), 1598 deletions(-)
diff --git a/docs/tutorial/JITTutorial1.html b/docs/tutorial/JITTutorial1.html
index 5c65399c0c6..3b7b8dea1ac 100644
--- a/docs/tutorial/JITTutorial1.html
+++ b/docs/tutorial/JITTutorial1.html
@@ -153,7 +153,7 @@ function will interoperate properly with C code, which is a good thing.
- BasicBlock* block = BasicBlock::Create("entry", mul_add);
+ BasicBlock* block = BasicBlock::Create(getGlobalContext(), "entry", mul_add);
IRBuilder<> builder(block);
diff --git a/docs/tutorial/JITTutorial2.html b/docs/tutorial/JITTutorial2.html
index c2483e4d01b..504d96597b0 100644
--- a/docs/tutorial/JITTutorial2.html
+++ b/docs/tutorial/JITTutorial2.html
@@ -100,11 +100,11 @@ Module* makeLLVMModule() {
- BasicBlock* entry = BasicBlock::Create("entry", gcd);
- BasicBlock* ret = BasicBlock::Create("return", gcd);
- BasicBlock* cond_false = BasicBlock::Create("cond_false", gcd);
- BasicBlock* cond_true = BasicBlock::Create("cond_true", gcd);
- BasicBlock* cond_false_2 = BasicBlock::Create("cond_false", gcd);
+ BasicBlock* entry = BasicBlock::Create(getGlobalContext(), ("entry", gcd);
+ BasicBlock* ret = BasicBlock::Create(getGlobalContext(), ("return", gcd);
+ BasicBlock* cond_false = BasicBlock::Create(getGlobalContext(), ("cond_false", gcd);
+ BasicBlock* cond_true = BasicBlock::Create(getGlobalContext(), ("cond_true", gcd);
+ BasicBlock* cond_false_2 = BasicBlock::Create(getGlobalContext(), ("cond_false", gcd);
diff --git a/docs/tutorial/LangImpl3.html b/docs/tutorial/LangImpl3.html
index 5f1072f6329..5978707e3bb 100644
--- a/docs/tutorial/LangImpl3.html
+++ b/docs/tutorial/LangImpl3.html
@@ -206,7 +206,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: return ErrorV("invalid binary operator");
}
}
@@ -307,8 +307,8 @@ bodies and external function declarations. The code starts with:
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -439,7 +439,7 @@ is an LLVM Function object that is ready to go for us.
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
if (Value *RetVal = Body->Codegen()) {
@@ -1055,7 +1055,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: return ErrorV("invalid binary operator");
}
}
@@ -1081,8 +1081,8 @@ Value *CallExprAST::Codegen() {
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -1127,7 +1127,7 @@ Function *FunctionAST::Codegen() {
return 0;
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
if (Value *RetVal = Body->Codegen()) {
diff --git a/docs/tutorial/LangImpl4.html b/docs/tutorial/LangImpl4.html
index 5eb69d33572..2f1dd4af14b 100644
--- a/docs/tutorial/LangImpl4.html
+++ b/docs/tutorial/LangImpl4.html
@@ -890,7 +890,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: return ErrorV("invalid binary operator");
}
}
@@ -916,8 +916,8 @@ Value *CallExprAST::Codegen() {
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -962,7 +962,7 @@ Function *FunctionAST::Codegen() {
return 0;
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
if (Value *RetVal = Body->Codegen()) {
diff --git a/docs/tutorial/LangImpl5.html b/docs/tutorial/LangImpl5.html
index 53bbcdc58e1..acfee7b9b84 100644
--- a/docs/tutorial/LangImpl5.html
+++ b/docs/tutorial/LangImpl5.html
@@ -379,9 +379,9 @@ value as a 1-bit (bool) value.
// Create blocks for the then and else cases. Insert the 'then' block at the
// end of the function.
- BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
- BasicBlock *ElseBB = BasicBlock::Create("else");
- BasicBlock *MergeBB = BasicBlock::Create("ifcont");
+ BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
+ BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
+ BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
@@ -472,7 +472,7 @@ are emitted, we can finish up with the merge code:
// Emit merge block.
TheFunction->getBasicBlockList().push_back(MergeBB);
Builder.SetInsertPoint(MergeBB);
- PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
+ PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
PN->addIncoming(ThenV, ThenBB);
PN->addIncoming(ElseV, ElseBB);
@@ -727,7 +727,7 @@ block, but remember that the body code itself could consist of multiple blocks
// block.
Function *TheFunction = Builder.GetInsertBlock()->getParent();
BasicBlock *PreheaderBB = Builder.GetInsertBlock();
- BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
+ BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
// Insert an explicit fall through from the current block to the LoopBB.
Builder.CreateBr(LoopBB);
@@ -745,7 +745,7 @@ create an unconditional branch for the fall-through between the two blocks.
Builder.SetInsertPoint(LoopBB);
// Start the PHI node with an entry for Start.
- PHINode *Variable = Builder.CreatePHI(Type::DoubleTy, VarName.c_str());
+ PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), VarName.c_str());
Variable->addIncoming(StartVal, PreheaderBB);
@@ -828,7 +828,7 @@ statement.
// Create the "after loop" block and insert it.
BasicBlock *LoopEndBB = Builder.GetInsertBlock();
- BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
+ BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
// Insert the conditional branch into the end of LoopEndBB.
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
@@ -856,7 +856,7 @@ the loop again and exiting the loop. Any future code is emitted in the
NamedValues.erase(VarName);
// for expr always returns 0.0.
- return Constant::getNullValue(Type::DoubleTy);
+ return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
@@ -1381,7 +1381,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: return ErrorV("invalid binary operator");
}
}
@@ -1418,9 +1418,9 @@ Value *IfExprAST::Codegen() {
// Create blocks for the then and else cases. Insert the 'then' block at the
// end of the function.
- BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
- BasicBlock *ElseBB = BasicBlock::Create("else");
- BasicBlock *MergeBB = BasicBlock::Create("ifcont");
+ BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
+ BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
+ BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
@@ -1448,7 +1448,7 @@ Value *IfExprAST::Codegen() {
// Emit merge block.
TheFunction->getBasicBlockList().push_back(MergeBB);
Builder.SetInsertPoint(MergeBB);
- PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
+ PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
PN->addIncoming(ThenV, ThenBB);
PN->addIncoming(ElseV, ElseBB);
@@ -1480,7 +1480,7 @@ Value *ForExprAST::Codegen() {
// block.
Function *TheFunction = Builder.GetInsertBlock()->getParent();
BasicBlock *PreheaderBB = Builder.GetInsertBlock();
- BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
+ BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
// Insert an explicit fall through from the current block to the LoopBB.
Builder.CreateBr(LoopBB);
@@ -1489,7 +1489,7 @@ Value *ForExprAST::Codegen() {
Builder.SetInsertPoint(LoopBB);
// Start the PHI node with an entry for Start.
- PHINode *Variable = Builder.CreatePHI(Type::DoubleTy, VarName.c_str());
+ PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), VarName.c_str());
Variable->addIncoming(StartVal, PreheaderBB);
// Within the loop, the variable is defined equal to the PHI node. If it
@@ -1526,7 +1526,7 @@ Value *ForExprAST::Codegen() {
// Create the "after loop" block and insert it.
BasicBlock *LoopEndBB = Builder.GetInsertBlock();
- BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
+ BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
// Insert the conditional branch into the end of LoopEndBB.
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
@@ -1545,13 +1545,13 @@ Value *ForExprAST::Codegen() {
// for expr always returns 0.0.
- return getGlobalContext().getNullValue(Type::DoubleTy);
+ return getGlobalContext().getNullValue(Type::getDoubleTy(getGlobalContext()));
}
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -1596,7 +1596,7 @@ Function *FunctionAST::Codegen() {
return 0;
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
if (Value *RetVal = Body->Codegen()) {
diff --git a/docs/tutorial/LangImpl6.html b/docs/tutorial/LangImpl6.html
index d845eb86c1a..33df2452b67 100644
--- a/docs/tutorial/LangImpl6.html
+++ b/docs/tutorial/LangImpl6.html
@@ -283,7 +283,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: break;
}
@@ -321,7 +321,7 @@ Function *FunctionAST::Codegen() {
BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence();
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
if (Value *RetVal = Body->Codegen()) {
@@ -1398,7 +1398,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: break;
}
@@ -1443,9 +1443,9 @@ Value *IfExprAST::Codegen() {
// Create blocks for the then and else cases. Insert the 'then' block at the
// end of the function.
- BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
- BasicBlock *ElseBB = BasicBlock::Create("else");
- BasicBlock *MergeBB = BasicBlock::Create("ifcont");
+ BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
+ BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
+ BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
@@ -1473,7 +1473,7 @@ Value *IfExprAST::Codegen() {
// Emit merge block.
TheFunction->getBasicBlockList().push_back(MergeBB);
Builder.SetInsertPoint(MergeBB);
- PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
+ PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
PN->addIncoming(ThenV, ThenBB);
PN->addIncoming(ElseV, ElseBB);
@@ -1505,7 +1505,7 @@ Value *ForExprAST::Codegen() {
// block.
Function *TheFunction = Builder.GetInsertBlock()->getParent();
BasicBlock *PreheaderBB = Builder.GetInsertBlock();
- BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
+ BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
// Insert an explicit fall through from the current block to the LoopBB.
Builder.CreateBr(LoopBB);
@@ -1514,7 +1514,7 @@ Value *ForExprAST::Codegen() {
Builder.SetInsertPoint(LoopBB);
// Start the PHI node with an entry for Start.
- PHINode *Variable = Builder.CreatePHI(Type::DoubleTy, VarName.c_str());
+ PHINode *Variable = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), VarName.c_str());
Variable->addIncoming(StartVal, PreheaderBB);
// Within the loop, the variable is defined equal to the PHI node. If it
@@ -1551,7 +1551,7 @@ Value *ForExprAST::Codegen() {
// Create the "after loop" block and insert it.
BasicBlock *LoopEndBB = Builder.GetInsertBlock();
- BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
+ BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
// Insert the conditional branch into the end of LoopEndBB.
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
@@ -1570,13 +1570,13 @@ Value *ForExprAST::Codegen() {
// for expr always returns 0.0.
- return Constant::getNullValue(Type::DoubleTy);
+ return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -1625,7 +1625,7 @@ Function *FunctionAST::Codegen() {
BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence();
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
if (Value *RetVal = Body->Codegen()) {
diff --git a/docs/tutorial/LangImpl7.html b/docs/tutorial/LangImpl7.html
index 691bfacb600..81386bc1ab0 100644
--- a/docs/tutorial/LangImpl7.html
+++ b/docs/tutorial/LangImpl7.html
@@ -424,7 +424,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str());
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0, VarName.c_str());
}
@@ -1618,7 +1618,7 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str());
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0, VarName.c_str());
}
@@ -1678,7 +1678,7 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()), "booltmp");
default: break;
}
@@ -1723,9 +1723,9 @@ Value *IfExprAST::Codegen() {
// Create blocks for the then and else cases. Insert the 'then' block at the
// end of the function.
- BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
- BasicBlock *ElseBB = BasicBlock::Create("else");
- BasicBlock *MergeBB = BasicBlock::Create("ifcont");
+ BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
+ BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
+ BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
@@ -1753,7 +1753,7 @@ Value *IfExprAST::Codegen() {
// Emit merge block.
TheFunction->getBasicBlockList().push_back(MergeBB);
Builder.SetInsertPoint(MergeBB);
- PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
+ PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()), "iftmp");
PN->addIncoming(ThenV, ThenBB);
PN->addIncoming(ElseV, ElseBB);
@@ -1796,7 +1796,7 @@ Value *ForExprAST::Codegen() {
// Make the new basic block for the loop header, inserting after current
// block.
BasicBlock *PreheaderBB = Builder.GetInsertBlock();
- BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
+ BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
// Insert an explicit fall through from the current block to the LoopBB.
Builder.CreateBr(LoopBB);
@@ -1842,7 +1842,7 @@ Value *ForExprAST::Codegen() {
// Create the "after loop" block and insert it.
BasicBlock *LoopEndBB = Builder.GetInsertBlock();
- BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
+ BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
// Insert the conditional branch into the end of LoopEndBB.
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
@@ -1858,7 +1858,7 @@ Value *ForExprAST::Codegen() {
// for expr always returns 0.0.
- return Constant::getNullValue(Type::DoubleTy);
+ return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
Value *VarExprAST::Codegen() {
@@ -1910,8 +1910,8 @@ Value *VarExprAST::Codegen() {
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector<const Type*> Doubles(Args.size(), Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -1973,7 +1973,7 @@ Function *FunctionAST::Codegen() {
BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence();
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
// Add all arguments to the symbol table and create their allocas.
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index 8651b6e918a..5cf2b883bc4 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -54,31 +54,31 @@ void BrainF::header(LLVMContext& C) {
//Function prototypes
//declare void @llvm.memset.i32(i8 *, i8, i32, i32)
- const Type *Tys[] = { Type::Int32Ty };
+ const Type *Tys[] = { Type::getInt32Ty(C) };
Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset,
Tys, 1);
//declare i32 @getchar()
getchar_func = cast(module->
- getOrInsertFunction("getchar", IntegerType::Int32Ty, NULL));
+ getOrInsertFunction("getchar", IntegerType::getInt32Ty(C), NULL));
//declare i32 @putchar(i32)
putchar_func = cast(module->
- getOrInsertFunction("putchar", IntegerType::Int32Ty,
- IntegerType::Int32Ty, NULL));
+ getOrInsertFunction("putchar", IntegerType::getInt32Ty(C),
+ IntegerType::getInt32Ty(C), NULL));
//Function header
//define void @brainf()
brainf_func = cast(module->
- getOrInsertFunction("brainf", Type::VoidTy, NULL));
+ getOrInsertFunction("brainf", Type::getVoidTy(C), NULL));
- builder = new IRBuilder<>(BasicBlock::Create(label, brainf_func));
+ builder = new IRBuilder<>(BasicBlock::Create(C, label, brainf_func));
//%arr = malloc i8, i32 %d
ConstantInt *val_mem = ConstantInt::get(C, APInt(32, memtotal));
- ptr_arr = builder->CreateMalloc(IntegerType::Int8Ty, val_mem, "arr");
+ ptr_arr = builder->CreateMalloc(IntegerType::getInt8Ty(C), val_mem, "arr");
//call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1)
{
@@ -110,13 +110,13 @@ void BrainF::header(LLVMContext& C) {
//Function footer
//brainf.end:
- endbb = BasicBlock::Create(label, brainf_func);
+ endbb = BasicBlock::Create(C, label, brainf_func);
//free i8 *%arr
new FreeInst(ptr_arr, endbb);
//ret void
- ReturnInst::Create(endbb);
+ ReturnInst::Create(C, endbb);
@@ -125,7 +125,7 @@ void BrainF::header(LLVMContext& C) {
{
//@aberrormsg = internal constant [%d x i8] c"\00"
Constant *msg_0 =
- ConstantArray::get("Error: The head has left the tape.", true);
+ ConstantArray::get(C, "Error: The head has left the tape.", true);
GlobalVariable *aberrormsg = new GlobalVariable(
*module,
@@ -137,15 +137,15 @@ void BrainF::header(LLVMContext& C) {
//declare i32 @puts(i8 *)
Function *puts_func = cast(module->
- getOrInsertFunction("puts", IntegerType::Int32Ty,
- PointerType::getUnqual(IntegerType::Int8Ty), NULL));
+ getOrInsertFunction("puts", IntegerType::getInt32Ty(C),
+ PointerType::getUnqual(IntegerType::getInt8Ty(C)), NULL));
//brainf.aberror:
- aberrorbb = BasicBlock::Create(label, brainf_func);
+ aberrorbb = BasicBlock::Create(C, label, brainf_func);
//call i32 @puts(i8 *getelementptr([%d x i8] *@aberrormsg, i32 0, i32 0))
{
- Constant *zero_32 = Constant::getNullValue(IntegerType::Int32Ty);
+ Constant *zero_32 = Constant::getNullValue(IntegerType::getInt32Ty(C));
Constant *gep_params[] = {
zero_32,
@@ -198,7 +198,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
//%tape.%d = trunc i32 %tape.%d to i8
Value *tape_1 = builder->
- CreateTrunc(tape_0, IntegerType::Int8Ty, tapereg);
+ CreateTrunc(tape_0, IntegerType::getInt8Ty(C), tapereg);
//store i8 %tape.%d, i8 *%head.%d
builder->CreateStore(tape_1, curhead);
@@ -212,7 +212,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
//%tape.%d = sext i8 %tape.%d to i32
Value *tape_1 = builder->
- CreateSExt(tape_0, IntegerType::Int32Ty, tapereg);
+ CreateSExt(tape_0, IntegerType::getInt32Ty(C), tapereg);
//call i32 @putchar(i32 %tape.%d)
Value *putchar_params[] = {
@@ -248,7 +248,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
CreateOr(test_0, test_1, testreg);
//br i1 %test.%d, label %main.%d, label %main.%d
- BasicBlock *nextbb = BasicBlock::Create(label, brainf_func);
+ BasicBlock *nextbb = BasicBlock::Create(C, label, brainf_func);
builder->CreateCondBr(test_2, aberrorbb, nextbb);
//main.%d:
@@ -274,17 +274,17 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
case SYM_LOOP:
{
//br label %main.%d
- BasicBlock *testbb = BasicBlock::Create(label, brainf_func);
+ BasicBlock *testbb = BasicBlock::Create(C, label, brainf_func);
builder->CreateBr(testbb);
//main.%d:
BasicBlock *bb_0 = builder->GetInsertBlock();
- BasicBlock *bb_1 = BasicBlock::Create(label, brainf_func);
+ BasicBlock *bb_1 = BasicBlock::Create(C, label, brainf_func);
builder->SetInsertPoint(bb_1);
// Make part of PHI instruction now, wait until end of loop to finish
PHINode *phi_0 =
- PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty),
+ PHINode::Create(PointerType::getUnqual(IntegerType::getInt8Ty(C)),
headreg, testbb);
phi_0->reserveOperandSpace(2);
phi_0->addIncoming(curhead, bb_0);
@@ -432,7 +432,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
ConstantInt::get(C, APInt(8, 0)), testreg);
//br i1 %test.%d, label %main.%d, label %main.%d
- BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);
+ BasicBlock *bb_0 = BasicBlock::Create(C, label, brainf_func);
BranchInst::Create(bb_0, oldbb, test_0, testbb);
//main.%d:
@@ -440,7 +440,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
//%head.%d = phi i8 *[%head.%d, %main.%d]
PHINode *phi_1 = builder->
- CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
+ CreatePHI(PointerType::getUnqual(IntegerType::getInt8Ty(C)), headreg);
phi_1->reserveOperandSpace(1);
phi_1->addIncoming(head_0, testbb);
curhead = phi_1;
diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp
index 8c62ae29006..f4f1e79b822 100644
--- a/examples/BrainF/BrainFDriver.cpp
+++ b/examples/BrainF/BrainFDriver.cpp
@@ -58,9 +58,10 @@ JIT("jit", cl::desc("Run program Just-In-Time"));
void addMainFunction(Module *mod) {
//define i32 @main(i32 %argc, i8 **%argv)
Function *main_func = cast(mod->
- getOrInsertFunction("main", IntegerType::Int32Ty, IntegerType::Int32Ty,
+ getOrInsertFunction("main", IntegerType::getInt32Ty(mod->getContext()),
+ IntegerType::getInt32Ty(mod->getContext()),
PointerType::getUnqual(PointerType::getUnqual(
- IntegerType::Int8Ty)), NULL));
+ IntegerType::getInt8Ty(mod->getContext()))), NULL));
{
Function::arg_iterator args = main_func->arg_begin();
Value *arg_0 = args++;
@@ -70,7 +71,7 @@ void addMainFunction(Module *mod) {
}
//main.0:
- BasicBlock *bb = BasicBlock::Create("main.0", main_func);
+ BasicBlock *bb = BasicBlock::Create(mod->getContext(), "main.0", main_func);
//call void @brainf()
{
@@ -80,7 +81,8 @@ void addMainFunction(Module *mod) {
}
//ret i32 0
- ReturnInst::Create(ConstantInt::get(getGlobalContext(), APInt(32, 0)), bb);
+ ReturnInst::Create(mod->getContext(),
+ ConstantInt::get(mod->getContext(), APInt(32, 0)), bb);
}
int main(int argc, char **argv) {
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp
index 48efd5a1cc1..b1a4691a9f6 100644
--- a/examples/Fibonacci/fibonacci.cpp
+++ b/examples/Fibonacci/fibonacci.cpp
@@ -40,31 +40,32 @@ static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF =
- cast(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
+ cast(M->getOrInsertFunction("fib", Type::getInt32Ty(Context),
+ Type::getInt32Ty(Context),
(Type *)0));
// Add a basic block to the function.
- BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
+ BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", FibF);
// Get pointers to the constants.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
- Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+ Value *One = ConstantInt::get(Type::getInt32Ty(Context), 1);
+ Value *Two = ConstantInt::get(Type::getInt32Ty(Context), 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg.
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the true_block.
- BasicBlock *RetBB = BasicBlock::Create("return", FibF);
+ BasicBlock *RetBB = BasicBlock::Create(Context, "return", FibF);
// Create an exit block.
- BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
+ BasicBlock* RecurseBB = BasicBlock::Create(Context, "recurse", FibF);
// Create the "if (arg <= 2) goto exitbb"
Value *CondInst = new ICmpInst(*BB, ICmpInst::ICMP_SLE, ArgX, Two, "cond");
BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
// Create: ret int 1
- ReturnInst::Create(One, RetBB);
+ ReturnInst::Create(Context, One, RetBB);
// create fib(x-1)
Value *Sub = BinaryOperator::CreateSub(ArgX, One, "arg", RecurseBB);
@@ -82,7 +83,7 @@ static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
"addresult", RecurseBB);
// Create the return instruction and add it to the basic block
- ReturnInst::Create(Sum, RecurseBB);
+ ReturnInst::Create(Context, Sum, RecurseBB);
return FibF;
}
diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp
index 7a99ed44735..ec9c2e68541 100644
--- a/examples/HowToUseJIT/HowToUseJIT.cpp
+++ b/examples/HowToUseJIT/HowToUseJIT.cpp
@@ -61,15 +61,16 @@ int main() {
// function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types.
Function *Add1F =
- cast(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
+ cast(M->getOrInsertFunction("add1", Type::getInt32Ty(Context),
+ Type::getInt32Ty(Context),
(Type *)0));
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
- BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
+ BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", Add1F);
// Get pointers to the constant `1'.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
+ Value *One = ConstantInt::get(Type::getInt32Ty(Context), 1);
// Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -80,7 +81,7 @@ int main() {
Instruction *Add = BinaryOperator::CreateAdd(One, ArgX, "addresult", BB);
// Create the return instruction and add it to the basic block
- ReturnInst::Create(Add, BB);
+ ReturnInst::Create(Context, Add, BB);
// Now, function add1 is ready.
@@ -88,20 +89,21 @@ int main() {
// Now we going to create function `foo', which returns an int and takes no
// arguments.
Function *FooF =
- cast(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0));
+ cast(M->getOrInsertFunction("foo", Type::getInt32Ty(Context),
+ (Type *)0));
// Add a basic block to the FooF function.
- BB = BasicBlock::Create("EntryBlock", FooF);
+ BB = BasicBlock::Create(Context, "EntryBlock", FooF);
// Get pointers to the constant `10'.
- Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
+ Value *Ten = ConstantInt::get(Type::getInt32Ty(Context), 10);
// Pass Ten to the call call:
CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB);
Add1CallRes->setTailCall(true);
// Create the return instruction and add it to the basic block.
- ReturnInst::Create(Add1CallRes, BB);
+ ReturnInst::Create(Context, Add1CallRes, BB);
// Now we create the JIT.
ExecutionEngine* EE = EngineBuilder(M).create();
diff --git a/examples/Kaleidoscope/toy.cpp b/examples/Kaleidoscope/toy.cpp
index 22b8285e926..3c1ce8b4d41 100644
--- a/examples/Kaleidoscope/toy.cpp
+++ b/examples/Kaleidoscope/toy.cpp
@@ -618,7 +618,8 @@ static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
- return TmpB.CreateAlloca(Type::DoubleTy, 0, VarName.c_str());
+ return TmpB.CreateAlloca(Type::getDoubleTy(getGlobalContext()), 0,
+ VarName.c_str());
}
@@ -678,7 +679,8 @@ Value *BinaryExprAST::Codegen() {
case '<':
L = Builder.CreateFCmpULT(L, R, "cmptmp");
// Convert bool 0/1 to double 0.0 or 1.0
- return Builder.CreateUIToFP(L, Type::DoubleTy, "booltmp");
+ return Builder.CreateUIToFP(L, Type::getDoubleTy(getGlobalContext()),
+ "booltmp");
default: break;
}
@@ -723,9 +725,9 @@ Value *IfExprAST::Codegen() {
// Create blocks for the then and else cases. Insert the 'then' block at the
// end of the function.
- BasicBlock *ThenBB = BasicBlock::Create("then", TheFunction);
- BasicBlock *ElseBB = BasicBlock::Create("else");
- BasicBlock *MergeBB = BasicBlock::Create("ifcont");
+ BasicBlock *ThenBB = BasicBlock::Create(getGlobalContext(), "then", TheFunction);
+ BasicBlock *ElseBB = BasicBlock::Create(getGlobalContext(), "else");
+ BasicBlock *MergeBB = BasicBlock::Create(getGlobalContext(), "ifcont");
Builder.CreateCondBr(CondV, ThenBB, ElseBB);
@@ -753,7 +755,8 @@ Value *IfExprAST::Codegen() {
// Emit merge block.
TheFunction->getBasicBlockList().push_back(MergeBB);
Builder.SetInsertPoint(MergeBB);
- PHINode *PN = Builder.CreatePHI(Type::DoubleTy, "iftmp");
+ PHINode *PN = Builder.CreatePHI(Type::getDoubleTy(getGlobalContext()),
+ "iftmp");
PN->addIncoming(ThenV, ThenBB);
PN->addIncoming(ElseV, ElseBB);
@@ -795,7 +798,7 @@ Value *ForExprAST::Codegen() {
// Make the new basic block for the loop header, inserting after current
// block.
- BasicBlock *LoopBB = BasicBlock::Create("loop", TheFunction);
+ BasicBlock *LoopBB = BasicBlock::Create(getGlobalContext(), "loop", TheFunction);
// Insert an explicit fall through from the current block to the LoopBB.
Builder.CreateBr(LoopBB);
@@ -840,7 +843,7 @@ Value *ForExprAST::Codegen() {
"loopcond");
// Create the "after loop" block and insert it.
- BasicBlock *AfterBB = BasicBlock::Create("afterloop", TheFunction);
+ BasicBlock *AfterBB = BasicBlock::Create(getGlobalContext(), "afterloop", TheFunction);
// Insert the conditional branch into the end of LoopEndBB.
Builder.CreateCondBr(EndCond, LoopBB, AfterBB);
@@ -856,7 +859,7 @@ Value *ForExprAST::Codegen() {
// for expr always returns 0.0.
- return Constant::getNullValue(Type::DoubleTy);
+ return Constant::getNullValue(Type::getDoubleTy(getGlobalContext()));
}
Value *VarExprAST::Codegen() {
@@ -908,8 +911,10 @@ Value *VarExprAST::Codegen() {
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
- std::vector Doubles(Args.size(), Type::DoubleTy);
- FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
+ std::vector Doubles(Args.size(),
+ Type::getDoubleTy(getGlobalContext()));
+ FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()),
+ Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
@@ -971,7 +976,7 @@ Function *FunctionAST::Codegen() {
BinopPrecedence[Proto->getOperatorName()] = Proto->getBinaryPrecedence();
// Create a new basic block to start insertion into.
- BasicBlock *BB = BasicBlock::Create("entry", TheFunction);
+ BasicBlock *BB = BasicBlock::Create(getGlobalContext(), "entry", TheFunction);
Builder.SetInsertPoint(BB);
// Add all arguments to the symbol table and create their allocas.
diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp
index fc487af056d..ded78c7b17a 100644
--- a/examples/ModuleMaker/ModuleMaker.cpp
+++ b/examples/ModuleMaker/ModuleMaker.cpp
@@ -31,7 +31,7 @@ int main() {
// Create the main function: first create the type 'int ()'
FunctionType *FT =
- FunctionType::get(Type::Int32Ty, /*not vararg*/false);
+ FunctionType::get(Type::getInt32Ty(Context), /*not vararg*/false);
// By passing a module as the last parameter to the Function constructor,
// it automatically gets appended to the Module.
@@ -39,11 +39,11 @@ int main() {
// Add a basic block to the function... again, it automatically inserts
// because of the last argument.
- BasicBlock *BB = BasicBlock::Create("EntryBlock", F);
+ BasicBlock *BB = BasicBlock::Create(Context, "EntryBlock", F);
// Get pointers to the constant integers...
- Value *Two = ConstantInt::get(Type::Int32Ty, 2);
- Value *Three = ConstantInt::get(Type::Int32Ty, 3);
+ Value *Two = ConstantInt::get(Type::getInt32Ty(Context), 2);
+ Value *Three = ConstantInt::get(Type::getInt32Ty(Context), 3);
// Create the add instruction... does not insert...
Instruction *Add = BinaryOperator::Create(Instruction::Add, Two, Three,
@@ -53,7 +53,7 @@ int main() {
BB->getInstList().push_back(Add);
// Create the return instruction and add it to the basic block
- BB->getInstList().push_back(ReturnInst::Create(Add));
+ BB->getInstList().push_back(ReturnInst::Create(Context, Add));
// Output the bitcode file to stdout
WriteBitcodeToFile(M, std::cout);
diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp
index 83e2640636f..be40a282150 100644
--- a/examples/ParallelJIT/ParallelJIT.cpp
+++ b/examples/ParallelJIT/ParallelJIT.cpp
@@ -36,15 +36,17 @@ static Function* createAdd1(Module *M) {
// function will have a return type of "int" and take an argument of "int".
// The '0' terminates the list of argument types.
Function *Add1F =
- cast(M->getOrInsertFunction("add1", Type::Int32Ty, Type::Int32Ty,
+ cast(M->getOrInsertFunction("add1",
+ Type::getInt32Ty(M->getContext()),
+ Type::getInt32Ty(M->getContext()),
(Type *)0));
// Add a basic block to the function. As before, it automatically inserts
// because of the last argument.
- BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
+ BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", Add1F);
// Get pointers to the constant `1'.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
+ Value *One = ConstantInt::get(Type::getInt32Ty(M->getContext()), 1);
// Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -55,7 +57,7 @@ static Function* createAdd1(Module *M) {
Instruction *Add = BinaryOperator::CreateAdd(One, ArgX, "addresult", BB);
// Create the return instruction and add it to the basic block
- ReturnInst::Create(Add, BB);
+ ReturnInst::Create(M->getContext(), Add, BB);
// Now, function add1 is ready.
return Add1F;
@@ -65,31 +67,33 @@ static Function *CreateFibFunction(Module *M) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF =
- cast(M->getOrInsertFunction("fib", Type::Int32Ty, Type::Int32Ty,
+ cast(M->getOrInsertFunction("fib",
+ Type::getInt32Ty(M->getContext()),
+ Type::getInt32Ty(M->getContext()),
(Type *)0));
// Add a basic block to the function.
- BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
+ BasicBlock *BB = BasicBlock::Create(M->getContext(), "EntryBlock", FibF);
// Get pointers to the constants.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
- Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+ Value *One = ConstantInt::get(Type::getInt32Ty(M->getContext()), 1);
+ Value *Two = ConstantInt::get(Type::getInt32Ty(M->getContext()), 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg.
ArgX->setName("AnArg"); // Give it a nice symbolic name for fun.
// Create the true_block.
- BasicBlock *RetBB = BasicBlock::Create("return", FibF);
+ BasicBlock *RetBB = BasicBlock::Create(M->getContext(), "return", FibF);
// Create an exit block.
- BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF);
+ BasicBlock* RecurseBB = BasicBlock::Create(M->getContext(), "recurse", FibF);
// Create the "if (arg < 2) goto exitbb"
Value *CondInst = new ICmpInst(*BB, ICmpInst::ICMP_SLE, ArgX, Two, "cond");
BranchInst::Create(RetBB, RecurseBB, CondInst, BB);
// Create: ret int 1
- ReturnInst::Create(One, RetBB);
+ ReturnInst::Create(M->getContext(), One, RetBB);
// create fib(x-1)
Value *Sub = BinaryOperator::CreateSub(ArgX, One, "arg", RecurseBB);
@@ -104,7 +108,7 @@ static Function *CreateFibFunction(Module *M) {
BinaryOperator::CreateAdd(CallFibX1, CallFibX2, "addresult", RecurseBB);
// Create the return instruction and add it to the basic block
- ReturnInst::Create(Sum, RecurseBB);
+ ReturnInst::Create(M->getContext(), Sum, RecurseBB);
return FibF;
}
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index eabc1a0d2b6..9138d28c680 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -83,8 +83,8 @@ private:
/// is automatically inserted at either the end of the function (if
/// InsertBefore is null), or before the specified basic block.
///
- explicit BasicBlock(const Twine &Name = "", Function *Parent = 0,
- BasicBlock *InsertBefore = 0);
+ explicit BasicBlock(LLVMContext &C, const Twine &Name = "",
+ Function *Parent = 0, BasicBlock *InsertBefore = 0);
public:
/// getContext - Get the context in which this basic block lives,
/// or null if it is not currently attached to a function.
@@ -97,9 +97,9 @@ public:
/// Create - Creates a new BasicBlock. If the Parent parameter is specified,
/// the basic block is automatically inserted at either the end of the
/// function (if InsertBefore is 0), or before the specified basic block.
- static BasicBlock *Create(const Twine &Name = "", Function *Parent = 0,
- BasicBlock *InsertBefore = 0) {
- return new BasicBlock(Name, Parent, InsertBefore);
+ static BasicBlock *Create(LLVMContext &Context, const Twine &Name = "",
+ Function *Parent = 0,BasicBlock *InsertBefore = 0) {
+ return new BasicBlock(Context, Name, Parent, InsertBefore);
}
~BasicBlock();
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 30b48beb87b..e26bb62c357 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -346,7 +346,8 @@ public:
/// of the array by one (you've been warned). However, in some situations
/// this is not desired so if AddNull==false then the string is copied without
/// null termination.
- static Constant* get(const StringRef &Initializer, bool AddNull = true);
+ static Constant* get(LLVMContext &Context, const StringRef &Initializer,
+ bool AddNull = true);
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index e7b226be7b5..a8603acfbe2 100644
--- a/include/llvm/DerivedTypes.h
+++ b/include/llvm/DerivedTypes.h
@@ -102,7 +102,7 @@ public:
/// that instance will be returned. Otherwise a new one will be created. Only
/// one instance with a given NumBits value is ever created.
/// @brief Get or create an IntegerType instance.
- static const IntegerType* get(unsigned NumBits);
+ static const IntegerType* get(LLVMContext &C, unsigned NumBits);
/// @brief Get the number of bits in this IntegerType
unsigned getBitWidth() const { return getSubclassData(); }
@@ -399,7 +399,7 @@ public:
///
static VectorType *getInteger(const VectorType *VTy) {
unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
- const Type *EltTy = IntegerType::get(EltBits);
+ const Type *EltTy = IntegerType::get(VTy->getContext(), EltBits);
return VectorType::get(EltTy, VTy->getNumElements());
}
@@ -409,7 +409,7 @@ public:
///
static VectorType *getExtendedElementVectorType(const VectorType *VTy) {
unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
- const Type *EltTy = IntegerType::get(EltBits * 2);
+ const Type *EltTy = IntegerType::get(VTy->getContext(), EltBits * 2);
return VectorType::get(EltTy, VTy->getNumElements());
}
@@ -421,7 +421,7 @@ public:
unsigned EltBits = VTy->getElementType()->getPrimitiveSizeInBits();
assert((EltBits & 1) == 0 &&
"Cannot truncate vector element with odd bit-width");
- const Type *EltTy = IntegerType::get(EltBits / 2);
+ const Type *EltTy = IntegerType::get(VTy->getContext(), EltBits / 2);
return VectorType::get(EltTy, VTy->getNumElements());
}
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h
index faff7986ece..560c32b73ae 100644
--- a/include/llvm/InstrTypes.h
+++ b/include/llvm/InstrTypes.h
@@ -708,9 +708,10 @@ public:
/// @brief Create a result type for fcmp/icmp
static const Type* makeCmpResultType(const Type* opnd_type) {
if (const VectorType* vt = dyn_cast(opnd_type)) {
- return VectorType::get(Type::Int1Ty, vt->getNumElements());
+ return VectorType::get(Type::getInt1Ty(opnd_type->getContext()),
+ vt->getNumElements());
}
- return Type::Int1Ty;
+ return Type::getInt1Ty(opnd_type->getContext());
}
};
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 1e1cec1d12c..33af5bcd7a9 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -2025,18 +2025,21 @@ private:
//
// NOTE: If the Value* passed is of type void then the constructor behaves as
// if it was passed NULL.
- explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
- ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
- explicit ReturnInst(BasicBlock *InsertAtEnd);
+ explicit ReturnInst(LLVMContext &C, Value *retVal = 0,
+ Instruction *InsertBefore = 0);
+ ReturnInst(LLVMContext &C, Value *retVal, BasicBlock *InsertAtEnd);
+ explicit ReturnInst(LLVMContext &C, BasicBlock *InsertAtEnd);
public:
- static ReturnInst* Create(Value *retVal = 0, Instruction *InsertBefore = 0) {
- return new(!!retVal) ReturnInst(retVal, InsertBefore);
+ static ReturnInst* Create(LLVMContext &C, Value *retVal = 0,
+ Instruction *InsertBefore = 0) {
+ return new(!!retVal) ReturnInst(C, retVal, InsertBefore);
}
- static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) {
- return new(!!retVal) ReturnInst(retVal, InsertAtEnd);
+ static ReturnInst* Create(LLVMContext &C, Value *retVal,
+ BasicBlock *InsertAtEnd) {
+ return new(!!retVal) ReturnInst(C, retVal, InsertAtEnd);
}
- static ReturnInst* Create(BasicBlock *InsertAtEnd) {
- return new(0) ReturnInst(InsertAtEnd);
+ static ReturnInst* Create(LLVMContext &C, BasicBlock *InsertAtEnd) {
+ return new(0) ReturnInst(C, InsertAtEnd);
}
virtual ~ReturnInst();
@@ -2591,8 +2594,8 @@ public:
void *operator new(size_t s) {
return User::operator new(s, 0);
}
- explicit UnwindInst(Instruction *InsertBefore = 0);
- explicit UnwindInst(BasicBlock *InsertAtEnd);
+ explicit UnwindInst(LLVMContext &C, Instruction *InsertBefore = 0);
+ explicit UnwindInst(LLVMContext &C, BasicBlock *InsertAtEnd);
virtual UnwindInst *clone(LLVMContext &Context) const;
@@ -2628,8 +2631,8 @@ public:
void *operator new(size_t s) {
return User::operator new(s, 0);
}
- explicit UnreachableInst(Instruction *InsertBefore = 0);
- explicit UnreachableInst(BasicBlock *InsertAtEnd);
+ explicit UnreachableInst(LLVMContext &C, Instruction *InsertBefore = 0);
+ explicit UnreachableInst(LLVMContext &C, BasicBlock *InsertAtEnd);
virtual UnreachableInst *clone(LLVMContext &Context) const;
diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h
index 95b4eaa2941..56a640ea11c 100644
--- a/include/llvm/LLVMContext.h
+++ b/include/llvm/LLVMContext.h
@@ -25,6 +25,9 @@ class LLVMContextImpl;
/// LLVMContext itself provides no locking guarantees, so you should be careful
/// to have one context per thread.
class LLVMContext {
+ // DO NOT IMPLEMENT
+ LLVMContext(LLVMContext&);
+ void operator=(LLVMContext&);
public:
LLVMContextImpl* pImpl;
bool RemoveDeadMetadata();
diff --git a/include/llvm/LinkAllVMCore.h b/include/llvm/LinkAllVMCore.h
index e5a51971f16..0ee18d57a04 100644
--- a/include/llvm/LinkAllVMCore.h
+++ b/include/llvm/LinkAllVMCore.h
@@ -46,7 +46,7 @@ namespace {
if (std::getenv("bar") != (char*) -1)
return;
llvm::Module* M = new llvm::Module("", llvm::getGlobalContext());
- (void)new llvm::UnreachableInst();
+ (void)new llvm::UnreachableInst(llvm::getGlobalContext());
(void) llvm::createVerifierPass();
(void) new llvm::Mangler(*M,"");
}
diff --git a/include/llvm/Metadata.h b/include/llvm/Metadata.h
index 8533efddb0f..f36de687d69 100644
--- a/include/llvm/Metadata.h
+++ b/include/llvm/Metadata.h
@@ -44,12 +44,6 @@ protected:
void resizeOperands(unsigned NumOps);
public:
- /// getType() specialization - Type is always MetadataTy.
- ///
- inline const Type *getType() const {
- return Type::MetadataTy;
- }
-
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. This always returns false because getNullValue will never
/// produce metadata.
@@ -76,8 +70,8 @@ class MDString : public MetadataBase {
StringRef Str;
protected:
- explicit MDString(const char *begin, unsigned l)
- : MetadataBase(Type::MetadataTy, Value::MDStringVal), Str(begin, l) {}
+ explicit MDString(LLVMContext &C, const char *begin, unsigned l)
+ : MetadataBase(Type::getMetadataTy(C), Value::MDStringVal), Str(begin, l) {}
public:
// Do not allocate any space for operands.
@@ -119,7 +113,7 @@ class MDNode : public MetadataBase {
friend struct ConstantCreator >;
protected:
- explicit MDNode(Value*const* Vals, unsigned NumVals);
+ explicit MDNode(LLVMContext &C, Value*const* Vals, unsigned NumVals);
public:
// Do not allocate any space for operands.
void *operator new(size_t s) {
@@ -156,12 +150,6 @@ public:
elem_iterator elem_begin() { return Node.begin(); }
elem_iterator elem_end() { return Node.end(); }
- /// getType() specialization - Type is always MetadataTy.
- ///
- inline const Type *getType() const {
- return Type::MetadataTy;
- }
-
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. This always returns false because getNullValue will never
/// produce metadata.
@@ -217,16 +205,17 @@ class NamedMDNode : public MetadataBase, public ilist_node {
typedef SmallVectorImpl::iterator elem_iterator;
protected:
- explicit NamedMDNode(const Twine &N, MetadataBase*const* Vals,
+ explicit NamedMDNode(LLVMContext &C, const Twine &N, MetadataBase*const* Vals,
unsigned NumVals, Module *M = 0);
public:
// Do not allocate any space for operands.
void *operator new(size_t s) {
return User::operator new(s, 0);
}
- static NamedMDNode *Create(const Twine &N, MetadataBase*const*MDs,
+ static NamedMDNode *Create(LLVMContext &C, const Twine &N,
+ MetadataBase*const*MDs,
unsigned NumMDs, Module *M = 0) {
- return new NamedMDNode(N, MDs, NumMDs, M);
+ return new NamedMDNode(C, N, MDs, NumMDs, M);
}
static NamedMDNode *Create(const NamedMDNode *NMD, Module *M = 0);
@@ -271,12 +260,6 @@ public:
elem_iterator elem_begin() { return Node.begin(); }
elem_iterator elem_end() { return Node.end(); }
- /// getType() specialization - Type is always MetadataTy.
- ///
- inline const Type *getType() const {
- return Type::MetadataTy;
- }
-
/// isNullValue - Return true if this is the value that would be returned by
/// getNullValue. This always returns false because getNullValue will never
/// produce metadata.
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h
index 9e0073a378b..e216d4c9566 100644
--- a/include/llvm/Support/IRBuilder.h
+++ b/include/llvm/Support/IRBuilder.h
@@ -129,14 +129,14 @@ public:
/// CreateRetVoid - Create a 'ret void' instruction.
ReturnInst *CreateRetVoid() {
- return Insert(ReturnInst::Create());
+ return Insert(ReturnInst::Create(getGlobalContext()));
}
/// @verbatim
/// CreateRet - Create a 'ret ' instruction.
/// @endverbatim
ReturnInst *CreateRet(Value *V) {
- return Insert(ReturnInst::Create(V));
+ return Insert(ReturnInst::Create(getGlobalContext(), V));
}
/// CreateAggregateRet - Create a sequence of N insertvalue instructions,
@@ -151,7 +151,7 @@ public:
Value *V = UndefValue::get(RetType);
for (unsigned i = 0; i != N; ++i)
V = CreateInsertValue(V, retVals[i], i, "mrv");
- return Insert(ReturnInst::Create(V));
+ return Insert(ReturnInst::Create(getGlobalContext(), V));
}
/// CreateBr - Create an unconditional 'br label X' instruction.
@@ -182,11 +182,11 @@ public:
}
UnwindInst *CreateUnwind() {
- return Insert(new UnwindInst());
+ return Insert(new UnwindInst(Context));
}
UnreachableInst *CreateUnreachable() {
- return Insert(new UnreachableInst());
+ return Insert(new UnreachableInst(Context));
}
//===--------------------------------------------------------------------===//
@@ -406,7 +406,7 @@ public:
return Insert(GetElementPtrInst::CreateInBounds(Ptr, Idx), Name);
}
Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const char *Name = "") {
- Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0);
+ Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Idx0);
if (Constant *PC = dyn_cast(Ptr))
return Folder.CreateGetElementPtr(PC, &Idx, 1);
@@ -415,7 +415,7 @@ public:
}
Value *CreateConstInBoundsGEP1_32(Value *Ptr, unsigned Idx0,
const char *Name = "") {
- Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0);
+ Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Idx0);
if (Constant *PC = dyn_cast(Ptr))
return Folder.CreateInBoundsGetElementPtr(PC, &Idx, 1);
@@ -425,8 +425,8 @@ public:
Value *CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1,
const char *Name = "") {
Value *Idxs[] = {
- ConstantInt::get(Type::Int32Ty, Idx0),
- ConstantInt::get(Type::Int32Ty, Idx1)
+ ConstantInt::get(Type::getInt32Ty(Context), Idx0),
+ ConstantInt::get(Type::getInt32Ty(Context), Idx1)
};
if (Constant *PC = dyn_cast(Ptr))
@@ -437,8 +437,8 @@ public:
Value *CreateConstInBoundsGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1,
const char *Name = "") {
Value *Idxs[] = {
- ConstantInt::get(Type::Int32Ty, Idx0),
- ConstantInt::get(Type::Int32Ty, Idx1)
+ ConstantInt::get(Type::getInt32Ty(Context), Idx0),
+ ConstantInt::get(Type::getInt32Ty(Context), Idx1)
};
if (Constant *PC = dyn_cast(Ptr))
@@ -447,7 +447,7 @@ public:
return Insert(GetElementPtrInst::CreateInBounds(Ptr, Idxs, Idxs+2), Name);
}
Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const char *Name = "") {
- Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0);
+ Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
if (Constant *PC = dyn_cast(Ptr))
return Folder.CreateGetElementPtr(PC, &Idx, 1);
@@ -456,7 +456,7 @@ public:
}
Value *CreateConstInBoundsGEP1_64(Value *Ptr, uint64_t Idx0,
const char *Name = "") {
- Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0);
+ Value *Idx = ConstantInt::get(Type::getInt64Ty(Context), Idx0);
if (Constant *PC = dyn_cast(Ptr))
return Folder.CreateInBoundsGetElementPtr(PC, &Idx, 1);
@@ -466,8 +466,8 @@ public:
Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1,
const char *Name = "") {
Value *Idxs[] = {
- ConstantInt::get(Type::Int64Ty, Idx0),
- ConstantInt::get(Type::Int64Ty, Idx1)
+ ConstantInt::get(Type::getInt64Ty(Context), Idx0),
+ ConstantInt::get(Type::getInt64Ty(Context), Idx1)
};
if (Constant *PC = dyn_cast(Ptr))
@@ -478,8 +478,8 @@ public:
Value *CreateConstInBoundsGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1,
const char *Name = "") {
Value *Idxs[] = {
- ConstantInt::get(Type::Int64Ty, Idx0),
- ConstantInt::get(Type::Int64Ty, Idx1)
+ ConstantInt::get(Type::getInt64Ty(Context), Idx0),
+ ConstantInt::get(Type::getInt64Ty(Context), Idx1)
};
if (Constant *PC = dyn_cast(Ptr))
@@ -491,7 +491,7 @@ public:
return CreateConstInBoundsGEP2_32(Ptr, 0, Idx, Name);
}
Value *CreateGlobalString(const char *Str = "", const char *Name = "") {
- Constant *StrConstant = ConstantArray::get(Str, true);
+ Constant *StrConstant = ConstantArray::get(Context, Str, true);
Module &M = *BB->getParent()->getParent();
GlobalVariable *gv = new GlobalVariable(M,
StrConstant->getType(),
@@ -506,7 +506,7 @@ public:
}
Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") {
Value *gv = CreateGlobalString(Str, Name);
- Value *zero = ConstantInt::get(Type::Int32Ty, 0);
+ Value *zero = ConstantInt::get(Type::getInt32Ty(Context), 0);
Value *Args[] = { zero, zero };
return CreateInBoundsGEP(gv, Args, Args+2, Name);
}
@@ -802,8 +802,8 @@ public:
assert(LHS->getType() == RHS->getType() &&
"Pointer subtraction operand types must match!");
const PointerType *ArgType = cast(LHS->getType());
- Value *LHS_int = CreatePtrToInt(LHS, Type::Int64Ty);
- Value *RHS_int = CreatePtrToInt(RHS, Type::Int64Ty);
+ Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context));
+ Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context));
Value *Difference = CreateSub(LHS_int, RHS_int);
return CreateExactSDiv(Difference,
ConstantExpr::getSizeOf(ArgType->getElementType()),
diff --git a/include/llvm/Support/TypeBuilder.h b/include/llvm/Support/TypeBuilder.h
index 1f85f1d1258..64af647cdb8 100644
--- a/include/llvm/Support/TypeBuilder.h
+++ b/include/llvm/Support/TypeBuilder.h
@@ -161,7 +161,7 @@ template<> class TypeBuilder { \
public: \
static const IntegerType *get(LLVMContext &Context) { \
static const IntegerType *const result = \
- IntegerType::get(sizeof(T) * CHAR_BIT); \
+ IntegerType::get(Context, sizeof(T) * CHAR_BIT); \
return result; \
} \
}; \
@@ -190,53 +190,53 @@ DEFINE_INTEGRAL_TYPEBUILDER(unsigned long long);
template
class TypeBuilder, cross> {
public:
- static const IntegerType *get(LLVMContext &Context) {
- static const IntegerType *const result = IntegerType::get(num_bits);
+ static const IntegerType *get(LLVMContext &C) {
+ static const IntegerType *const result = IntegerType::get(C, num_bits);
return result;
}
};
template<> class TypeBuilder {
public:
- static const Type *get(LLVMContext&) {
- return Type::FloatTy;
+ static const Type *get(LLVMContext& C) {
+ return Type::getFloatTy(C);
}
};
template<> class TypeBuilder {};
template<> class TypeBuilder {
public:
- static const Type *get(LLVMContext&) {
- return Type::DoubleTy;
+ static const Type *get(LLVMContext& C) {
+ return Type::getDoubleTy(C);
}
};
template<> class TypeBuilder {};
template class TypeBuilder {
public:
- static const Type *get(LLVMContext&) { return Type::FloatTy; }
+ static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); }
};
template class TypeBuilder {
public:
- static const Type *get(LLVMContext&) { return Type::DoubleTy; }
+ static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); }
};
template class TypeBuilder {
public:
- static const Type *get(LLVMContext&) { return Type::X86_FP80Ty; }
+ static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); }
};
template class TypeBuilder {
public:
- static const Type *get(LLVMContext&) { return Type::FP128Ty; }
+ static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); }
};
template class TypeBuilder {
public:
- static const Type *get(LLVMContext&) { return Type::PPC_FP128Ty; }
+ static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); }
};
template class TypeBuilder {
public:
- static const Type *get(LLVMContext&) {
- return Type::VoidTy;
+ static const Type *get(LLVMContext &C) {
+ return Type::getVoidTy(C);
}
};
diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h
index 60c2c323d7d..23775be70f9 100644
--- a/include/llvm/Target/TargetData.h
+++ b/include/llvm/Target/TargetData.h
@@ -34,6 +34,7 @@ class IntegerType;
class StructType;
class StructLayout;
class GlobalVariable;
+class LLVMContext;
/// Enum used to categorize the alignment types stored by TargetAlignElem
enum AlignTypeEnum {
@@ -229,7 +230,7 @@ public:
/// getIntPtrType - Return an unsigned integer type that is the same size or
/// greater to the host pointer size.
///
- const IntegerType *getIntPtrType() const;
+ const IntegerType *getIntPtrType(LLVMContext &C) const;
/// getIndexedOffset - return the offset from the beginning of the type for
/// the specified indices. This is used to implement getelementptr.
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 5e09a612220..05a4e26c8bb 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -306,7 +306,7 @@ public:
/// getVAArgsPromotedType - Return the type an argument of this type
/// will be promoted to if passed through a variable argument
/// function.
- const Type *getVAArgsPromotedType() const;
+ const Type *getVAArgsPromotedType(LLVMContext &C) const;
/// getScalarType - If this is a vector type, return the element type,
/// otherwise return this.
@@ -338,14 +338,24 @@ public:
//
/// getPrimitiveType - Return a type based on an identifier.
- static const Type *getPrimitiveType(TypeID IDNumber);
+ static const Type *getPrimitiveType(LLVMContext &C, TypeID IDNumber);
//===--------------------------------------------------------------------===//
// These are the builtin types that are always available...
//
- static const Type *VoidTy, *LabelTy, *FloatTy, *DoubleTy, *MetadataTy;
- static const Type *X86_FP80Ty, *FP128Ty, *PPC_FP128Ty;
- static const IntegerType *Int1Ty, *Int8Ty, *Int16Ty, *Int32Ty, *Int64Ty;
+ static const Type *getVoidTy(LLVMContext &C);
+ static const Type *getLabelTy(LLVMContext &C);
+ static const Type *getFloatTy(LLVMContext &C);
+ static const Type *getDoubleTy(LLVMContext &C);
+ static const Type *getMetadataTy(LLVMContext &C);
+ static const Type *getX86_FP80Ty(LLVMContext &C);
+ static const Type *getFP128Ty(LLVMContext &C);
+ static const Type *getPPC_FP128Ty(LLVMContext &C);
+ static const IntegerType *getInt1Ty(LLVMContext &C);
+ static const IntegerType *getInt8Ty(LLVMContext &C);
+ static const IntegerType *getInt16Ty(LLVMContext &C);
+ static const IntegerType *getInt32Ty(LLVMContext &C);
+ static const IntegerType *getInt64Ty(LLVMContext &C);
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Type *) { return true; }
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index a89505549f8..286f12a1ba1 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -502,10 +502,10 @@ static bool IndexOperandsEqual(Value *V1, Value *V2, LLVMContext &Context) {
if (Constant *C1 = dyn_cast(V1))
if (Constant *C2 = dyn_cast(V2)) {
// Sign extend the constants to long types, if necessary
- if (C1->getType() != Type::Int64Ty)
- C1 = ConstantExpr::getSExt(C1, Type::Int64Ty);
- if (C2->getType() != Type::Int64Ty)
- C2 = ConstantExpr::getSExt(C2, Type::Int64Ty);
+ if (C1->getType() != Type::getInt64Ty(Context))
+ C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(Context));
+ if (C2->getType() != Type::getInt64Ty(Context))
+ C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(Context));
return C1 == C2;
}
return false;
@@ -600,10 +600,10 @@ BasicAliasAnalysis::CheckGEPInstructions(
if (Constant *G2OC = dyn_cast(const_cast(G2Oper))){
if (G1OC->getType() != G2OC->getType()) {
// Sign extend both operands to long.
- if (G1OC->getType() != Type::Int64Ty)
- G1OC = ConstantExpr::getSExt(G1OC, Type::Int64Ty);
- if (G2OC->getType() != Type::Int64Ty)
- G2OC = ConstantExpr::getSExt(G2OC, Type::Int64Ty);
+ if (G1OC->getType() != Type::getInt64Ty(Context))
+ G1OC = ConstantExpr::getSExt(G1OC, Type::getInt64Ty(Context));
+ if (G2OC->getType() != Type::getInt64Ty(Context))
+ G2OC = ConstantExpr::getSExt(G2OC, Type::getInt64Ty(Context));
GEP1Ops[FirstConstantOper] = G1OC;
GEP2Ops[FirstConstantOper] = G2OC;
}
@@ -738,7 +738,8 @@ BasicAliasAnalysis::CheckGEPInstructions(
const Type *ZeroIdxTy = GEPPointerTy;
for (unsigned i = 0; i != FirstConstantOper; ++i) {
if (!isa(ZeroIdxTy))
- GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::Int32Ty);
+ GEP1Ops[i] = GEP2Ops[i] =
+ Constant::getNullValue(Type::getInt32Ty(Context));
if (const CompositeType *CT = dyn_cast(ZeroIdxTy))
ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]);
@@ -780,10 +781,12 @@ BasicAliasAnalysis::CheckGEPInstructions(
//
if (const ArrayType *AT = dyn_cast(BasePtr1Ty))
GEP1Ops[i] =
- ConstantInt::get(Type::Int64Ty,AT->getNumElements()-1);
+ ConstantInt::get(Type::getInt64Ty(Context),
+ AT->getNumElements()-1);
else if (const VectorType *VT = dyn_cast(BasePtr1Ty))
GEP1Ops[i] =
- ConstantInt::get(Type::Int64Ty,VT->getNumElements()-1);
+ ConstantInt::get(Type::getInt64Ty(Context),
+ VT->getNumElements()-1);
}
}
diff --git a/lib/Analysis/CaptureTracking.cpp b/lib/Analysis/CaptureTracking.cpp
index a19b8e4f94d..b30ac719ae0 100644
--- a/lib/Analysis/CaptureTracking.cpp
+++ b/lib/Analysis/CaptureTracking.cpp
@@ -54,7 +54,7 @@ bool llvm::PointerMayBeCaptured(const Value *V, bool ReturnCaptures) {
// its return value and doesn't unwind (a readonly function can leak bits
// by throwing an exception or not depending on the input value).
if (CS.onlyReadsMemory() && CS.doesNotThrow() &&
- I->getType() == Type::VoidTy)
+ I->getType() == Type::getVoidTy(V->getContext()))
break;
// Not captured if only passed via 'nocapture' arguments. Note that
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 57e781615a3..9234f2aaf9c 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -151,7 +151,7 @@ static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps,
uint64_t Offset = TD->getIndexedOffset(Ptr->getType(),
(Value**)Ops+1, NumOps-1);
- Constant *C = ConstantInt::get(TD->getIntPtrType(), Offset+BasePtr);
+ Constant *C = ConstantInt::get(TD->getIntPtrType(Context), Offset+BasePtr);
return ConstantExpr::getIntToPtr(C, ResultTy);
}
@@ -185,7 +185,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
// Fold to an vector of integers with same size as our FP type.
unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits();
const Type *DestIVTy = VectorType::get(
- IntegerType::get(FPWidth), NumDstElt);
+ IntegerType::get(Context, FPWidth), NumDstElt);
// Recursively handle this integer conversion, if possible.
C = FoldBitCast(C, DestIVTy, TD, Context);
if (!C) return 0;
@@ -199,7 +199,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
if (SrcEltTy->isFloatingPoint()) {
unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits();
const Type *SrcIVTy = VectorType::get(
- IntegerType::get(FPWidth), NumSrcElt);
+ IntegerType::get(Context, FPWidth), NumSrcElt);
// Ask VMCore to do the conversion now that #elts line up.
C = ConstantExpr::getBitCast(C, SrcIVTy);
CV = dyn_cast(C);
@@ -480,7 +480,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
// around to know if bit truncation is happening.
if (ConstantExpr *CE0 = dyn_cast(Ops[0])) {
if (TD && Ops[1]->isNullValue()) {
- const Type *IntPtrTy = TD->getIntPtrType();
+ const Type *IntPtrTy = TD->getIntPtrType(Context);
if (CE0->getOpcode() == Instruction::IntToPtr) {
// Convert the integer value to the right size to ensure we get the
// proper extension or truncation.
@@ -505,7 +505,7 @@ Constant *llvm::ConstantFoldCompareInstOperands(unsigned Predicate,
if (ConstantExpr *CE1 = dyn_cast(Ops[1])) {
if (TD && CE0->getOpcode() == CE1->getOpcode()) {
- const Type *IntPtrTy = TD->getIntPtrType();
+ const Type *IntPtrTy = TD->getIntPtrType(Context);
if (CE0->getOpcode() == Instruction::IntToPtr) {
// Convert the integer value to the right size to ensure we get the
@@ -654,9 +654,9 @@ static Constant *ConstantFoldFP(double (*NativeFP)(double), double V,
return 0;
}
- if (Ty == Type::FloatTy)
+ if (Ty == Type::getFloatTy(Context))
return ConstantFP::get(Context, APFloat((float)V));
- if (Ty == Type::DoubleTy)
+ if (Ty == Type::getDoubleTy(Context))
return ConstantFP::get(Context, APFloat(V));
llvm_unreachable("Can only constant fold float/double");
return 0; // dummy return to suppress warning
@@ -673,9 +673,9 @@ static Constant *ConstantFoldBinaryFP(double (*NativeFP)(double, double),
return 0;
}
- if (Ty == Type::FloatTy)
+ if (Ty == Type::getFloatTy(Context))
return ConstantFP::get(Context, APFloat((float)V));
- if (Ty == Type::DoubleTy)
+ if (Ty == Type::getDoubleTy(Context))
return ConstantFP::get(Context, APFloat(V));
llvm_unreachable("Can only constant fold float/double");
return 0; // dummy return to suppress warning
@@ -694,13 +694,15 @@ llvm::ConstantFoldCall(Function *F,
const Type *Ty = F->getReturnType();
if (NumOperands == 1) {
if (ConstantFP *Op = dyn_cast(Operands[0])) {
- if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy)
+ if (Ty!=Type::getFloatTy(F->getContext()) &&
+ Ty!=Type::getDoubleTy(Context))
return 0;
/// Currently APFloat versions of these functions do not exist, so we use
/// the host native double versions. Float versions are not called
/// directly but for all these it is true (float)(f((double)arg)) ==
/// f(arg). Long double not supported yet.
- double V = Ty==Type::FloatTy ? (double)Op->getValueAPF().convertToFloat():
+ double V = Ty==Type::getFloatTy(F->getContext()) ?
+ (double)Op->getValueAPF().convertToFloat():
Op->getValueAPF().convertToDouble();
switch (Name[0]) {
case 'a':
@@ -777,13 +779,14 @@ llvm::ConstantFoldCall(Function *F,
}
} else if (NumOperands == 2) {
if (ConstantFP *Op1 = dyn_cast(Operands[0])) {
- if (Ty!=Type::FloatTy && Ty!=Type::DoubleTy)
+ if (Ty!=Type::getFloatTy(F->getContext()) &&
+ Ty!=Type::getDoubleTy(Context))
return 0;
- double Op1V = Ty==Type::FloatTy ?
+ double Op1V = Ty==Type::getFloatTy(F->getContext()) ?
(double)Op1->getValueAPF().convertToFloat():
Op1->getValueAPF().convertToDouble();
if (ConstantFP *Op2 = dyn_cast(Operands[1])) {
- double Op2V = Ty==Type::FloatTy ?
+ double Op2V = Ty==Type::getFloatTy(F->getContext()) ?
(double)Op2->getValueAPF().convertToFloat():
Op2->getValueAPF().convertToDouble();
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 3d9c93378fb..527dae2029d 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -483,7 +483,7 @@ Constant *DIFactory::getCastToEmpty(DIDescriptor D) {
Constant *DIFactory::GetTagConstant(unsigned TAG) {
assert((TAG & LLVMDebugVersionMask) == 0 &&
"Tag too large for debug encoding!");
- return ConstantInt::get(Type::Int32Ty, TAG | LLVMDebugVersion);
+ return ConstantInt::get(Type::getInt32Ty(VMContext), TAG | LLVMDebugVersion);
}
Constant *DIFactory::GetStringConstant(const std::string &String) {
@@ -493,14 +493,14 @@ Constant *DIFactory::GetStringConstant(const std::string &String) {
// Return Constant if previously defined.
if (Slot) return Slot;
- const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty);
+ const PointerType *DestTy = PointerType::getUnqual(Type::getInt8Ty(VMContext));
// If empty string then use a i8* null instead.
if (String.empty())
return Slot = ConstantPointerNull::get(DestTy);
// Construct string as an llvm constant.
- Constant *ConstStr = ConstantArray::get(String);
+ Constant *ConstStr = ConstantArray::get(VMContext, String);
// Otherwise create and return a new string global.
GlobalVariable *StrGV = new GlobalVariable(M, ConstStr->getType(), true,
@@ -542,8 +542,8 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
DISubrange DIFactory::GetOrCreateSubrange(int64_t Lo, int64_t Hi) {
Constant *Elts[] = {
GetTagConstant(dwarf::DW_TAG_subrange_type),
- ConstantInt::get(Type::Int64Ty, Lo),
- ConstantInt::get(Type::Int64Ty, Hi)
+ ConstantInt::get(Type::getInt64Ty(VMContext), Lo),
+ ConstantInt::get(Type::getInt64Ty(VMContext), Hi)
};
Constant *Init = ConstantStruct::get(VMContext, Elts,
@@ -578,14 +578,14 @@ DICompileUnit DIFactory::CreateCompileUnit(unsigned LangID,
Constant *Elts[] = {
GetTagConstant(dwarf::DW_TAG_compile_unit),
llvm::Constant::getNullValue(EmptyStructPtr),
- ConstantInt::get(Type::Int32Ty, LangID),
+ ConstantInt::get(Type::getInt32Ty(VMContext), LangID),
GetStringConstant(Filename),
GetStringConstant(Directory),
GetStringConstant(Producer),
- ConstantInt::get(Type::Int1Ty, isMain),
- ConstantInt::get(Type::Int1Ty, isOptimized),
+ ConstantInt::get(Type::getInt1Ty(VMContext), isMain),
+ ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
GetStringConstant(Flags),
- ConstantInt::get(Type::Int32Ty, RunTimeVer)
+ ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer)
};
Constant *Init = ConstantStruct::get(VMContext, Elts,
@@ -604,7 +604,7 @@ DIEnumerator DIFactory::CreateEnumerator(const std::string &Name, uint64_t Val){
Constant *Elts[] = {
GetTagConstant(dwarf::DW_TAG_enumerator),
GetStringConstant(Name),
- ConstantInt::get(Type::Int64Ty, Val)
+ ConstantInt::get(Type::getInt64Ty(VMContext), Val)
};
Constant *Init = ConstantStruct::get(VMContext, Elts,
@@ -633,12 +633,12 @@ DIBasicType DIFactory::CreateBasicType(DIDescriptor Context,
getCastToEmpty(Context),
GetStringConstant(Name),
getCastToEmpty(CompileUnit),
- ConstantInt::get(Type::Int32Ty, LineNumber),
- ConstantInt::get(Type::Int64Ty, SizeInBits),
- ConstantInt::get(Type::Int64Ty, AlignInBits),
- ConstantInt::get(Type::Int64Ty, OffsetInBits),
- ConstantInt::get(Type::Int32Ty, Flags),
- ConstantInt::get(Type::Int32Ty, Encoding)
+ ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
+ ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
+ ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
+ ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
+ ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
+ ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
};
Constant *Init = ConstantStruct::get(VMContext, Elts,
@@ -669,11 +669,11 @@ DIDerivedType DIFactory::CreateDerivedType(unsigned Tag,
getCastToEmpty(Context),
GetStringConstant(Name),
getCastToEmpty(CompileUnit),
- ConstantInt::get(Type::Int32Ty, LineNumber),
- ConstantInt::get(Type::Int64Ty, SizeInBits),
- ConstantInt::get(Type::Int64Ty, AlignInBits),
- ConstantInt::get(Type::Int64Ty, OffsetInBits),
- ConstantInt::get(Type::Int32Ty, Flags),
+ ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
+ ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
+ ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
+ ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
+ ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
getCastToEmpty(DerivedFrom)
};
@@ -707,14 +707,14 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag,
getCastToEmpty(Context),
GetStringConstant(Name),
getCastToEmpty(CompileUnit),
- ConstantInt::get(Type::Int32Ty, LineNumber),
- ConstantInt::get(Type::Int64Ty, SizeInBits),
- ConstantInt::get(Type::Int64Ty, AlignInBits),
- ConstantInt::get(Type::Int64Ty, OffsetInBits),
- ConstantInt::get(Type::Int32Ty, Flags),
+ ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
+ ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
+ ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
+ ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
+ ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
getCastToEmpty(DerivedFrom),
getCastToEmpty(Elements),
- ConstantInt::get(Type::Int32Ty, RuntimeLang)
+ ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
};
Constant *Init = ConstantStruct::get(VMContext, Elts,
@@ -749,10 +749,10 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
GetStringConstant(DisplayName),
GetStringConstant(LinkageName),
getCastToEmpty(CompileUnit),
- ConstantInt::get(Type::Int32Ty, LineNo),
+ ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
getCastToEmpty(Type),
- ConstantInt::get(Type::Int1Ty, isLocalToUnit),
- ConstantInt::get(Type::Int1Ty, isDefinition)
+ ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
+ ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition)
};
Constant *Init = ConstantStruct::get(VMContext, Elts,
@@ -782,10 +782,10 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, const std::string &Name,
GetStringConstant(DisplayName),
GetStringConstant(LinkageName),
getCastToEmpty(CompileUnit),
- ConstantInt::get(Type::Int32Ty, LineNo),
+ ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
getCastToEmpty(Type),
- ConstantInt::get(Type::Int1Ty, isLocalToUnit),
- ConstantInt::get(Type::Int1Ty, isDefinition),
+ ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
+ ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
ConstantExpr::getBitCast(Val, EmptyStructPtr)
};
@@ -811,7 +811,7 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
getCastToEmpty(Context),
GetStringConstant(Name),
getCastToEmpty(CompileUnit),
- ConstantInt::get(Type::Int32Ty, LineNo),
+ ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
getCastToEmpty(Type)
};
@@ -863,8 +863,8 @@ void DIFactory::InsertStopPoint(DICompileUnit CU, unsigned LineNo,
// Invoke llvm.dbg.stoppoint
Value *Args[] = {
- ConstantInt::get(llvm::Type::Int32Ty, LineNo),
- ConstantInt::get(llvm::Type::Int32Ty, ColNo),
+ ConstantInt::get(llvm::Type::getInt32Ty(VMContext), LineNo),
+ ConstantInt::get(llvm::Type::getInt32Ty(VMContext), ColNo),
getCastToEmpty(CU)
};
CallInst::Create(StopPointFn, Args, Args+3, "", BB);
diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp
index d37273c3728..4045dd4de25 100644
--- a/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/lib/Analysis/LoopDependenceAnalysis.cpp
@@ -93,7 +93,7 @@ static AliasAnalysis::AliasResult UnderlyingObjectsAlias(AliasAnalysis *AA,
}
static inline const SCEV *GetZeroSCEV(ScalarEvolution *SE) {
- return SE->getConstant(Type::Int32Ty, 0L);
+ return SE->getConstant(Type::getInt32Ty(SE->getContext()), 0L);
}
//===----------------------------------------------------------------------===//
diff --git a/lib/Analysis/LoopVR.cpp b/lib/Analysis/LoopVR.cpp
index 921d6ce06e9..bae02015c65 100644
--- a/lib/Analysis/LoopVR.cpp
+++ b/lib/Analysis/LoopVR.cpp
@@ -73,9 +73,9 @@ ConstantRange LoopVR::getRange(const SCEV *S, const SCEV *T, ScalarEvolution &SE
ConstantRange X = getRange(Mul->getOperand(0), T, SE);
if (X.isFullSet()) return FullSet;
- const IntegerType *Ty = IntegerType::get(X.getBitWidth());
- const IntegerType *ExTy = IntegerType::get(X.getBitWidth() *
- Mul->getNumOperands());
+ const IntegerType *Ty = IntegerType::get(SE.getContext(), X.getBitWidth());
+ const IntegerType *ExTy = IntegerType::get(SE.getContext(),
+ X.getBitWidth() * Mul->getNumOperands());
ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth());
for (unsigned i = 1, e = Mul->getNumOperands(); i != e; ++i) {
diff --git a/lib/Analysis/PointerTracking.cpp b/lib/Analysis/PointerTracking.cpp
index 1ae2fe6910f..f2154f73889 100644
--- a/lib/Analysis/PointerTracking.cpp
+++ b/lib/Analysis/PointerTracking.cpp
@@ -47,7 +47,7 @@ void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const {
}
bool PointerTracking::doInitialization(Module &M) {
- const Type *PTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type *PTy = PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
// Find calloc(i64, i64) or calloc(i32, i32).
callocFunc = M.getFunction("calloc");
@@ -55,10 +55,10 @@ bool PointerTracking::doInitialization(Module &M) {
const FunctionType *Ty = callocFunc->getFunctionType();
std::vector args, args2;
- args.push_back(Type::Int64Ty);
- args.push_back(Type::Int64Ty);
- args2.push_back(Type::Int32Ty);
- args2.push_back(Type::Int32Ty);
+ args.push_back(Type::getInt64Ty(M.getContext()));
+ args.push_back(Type::getInt64Ty(M.getContext()));
+ args2.push_back(Type::getInt32Ty(M.getContext()));
+ args2.push_back(Type::getInt32Ty(M.getContext()));
const FunctionType *Calloc1Type =
FunctionType::get(PTy, args, false);
const FunctionType *Calloc2Type =
@@ -73,9 +73,9 @@ bool PointerTracking::doInitialization(Module &M) {
const FunctionType *Ty = reallocFunc->getFunctionType();
std::vector args, args2;
args.push_back(PTy);
- args.push_back(Type::Int64Ty);
+ args.push_back(Type::getInt64Ty(M.getContext()));
args2.push_back(PTy);
- args2.push_back(Type::Int32Ty);
+ args2.push_back(Type::getInt32Ty(M.getContext()));
const FunctionType *Realloc1Type =
FunctionType::get(PTy, args, false);
@@ -104,11 +104,12 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
Constant *C = GV->getInitializer();
if (const ArrayType *ATy = dyn_cast(C->getType())) {
Ty = ATy->getElementType();
- return SE->getConstant(Type::Int32Ty, ATy->getNumElements());
+ return SE->getConstant(Type::getInt32Ty(Ty->getContext()),
+ ATy->getNumElements());
}
}
Ty = GV->getType();
- return SE->getConstant(Type::Int32Ty, 1);
+ return SE->getConstant(Type::getInt32Ty(Ty->getContext()), 1);
//TODO: implement more tracking for globals
}
@@ -117,13 +118,13 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
Function *F = dyn_cast(CS.getCalledValue()->stripPointerCasts());
const Loop *L = LI->getLoopFor(CI->getParent());
if (F == callocFunc) {
- Ty = Type::Int8Ty;
+ Ty = Type::getInt8Ty(Ty->getContext());
// calloc allocates arg0*arg1 bytes.
return SE->getSCEVAtScope(SE->getMulExpr(SE->getSCEV(CS.getArgument(0)),
SE->getSCEV(CS.getArgument(1))),
L);
} else if (F == reallocFunc) {
- Ty = Type::Int8Ty;
+ Ty = Type::getInt8Ty(Ty->getContext());
// realloc allocates arg1 bytes.
return SE->getSCEVAtScope(CS.getArgument(1), L);
}
@@ -163,7 +164,7 @@ const SCEV *PointerTracking::getAllocationElementCount(Value *V) const {
}
const SCEV *PointerTracking::getAllocationSizeInBytes(Value *V) const {
- return computeAllocationCountForType(V, Type::Int8Ty);
+ return computeAllocationCountForType(V, Type::getInt8Ty(V->getContext()));
}
// Helper for isLoopGuardedBy that checks the swapped and inverted predicate too
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 72cb9b212fa..8ce812cc066 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -598,7 +598,8 @@ static const SCEV *BinomialCoefficient(const SCEV *It, unsigned K,
MultiplyFactor = MultiplyFactor.trunc(W);
// Calculate the product, at width T+W
- const IntegerType *CalculationTy = IntegerType::get(CalculationBits);
+ const IntegerType *CalculationTy = IntegerType::get(SE.getContext(),
+ CalculationBits);
const SCEV *Dividend = SE.getTruncateOrZeroExtend(It, CalculationTy);
for (unsigned i = 1; i != K; ++i) {
const SCEV *S = SE.getMinusSCEV(It, SE.getIntegerSCEV(i, It->getType()));
@@ -760,7 +761,7 @@ const SCEV *ScalarEvolution::getZeroExtendExpr(const SCEV *Op,
const SCEV *RecastedMaxBECount =
getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType());
if (MaxBECount == RecastedMaxBECount) {
- const Type *WideTy = IntegerType::get(BitWidth * 2);
+ const Type *WideTy = IntegerType::get(getContext(), BitWidth * 2);
// Check whether Start+Step*MaxBECount has no unsigned overflow.
const SCEV *ZMul =
getMulExpr(CastedMaxBECount,
@@ -899,7 +900,7 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op,
const SCEV *RecastedMaxBECount =
getTruncateOrZeroExtend(CastedMaxBECount, MaxBECount->getType());
if (MaxBECount == RecastedMaxBECount) {
- const Type *WideTy = IntegerType::get(BitWidth * 2);
+ const Type *WideTy = IntegerType::get(getContext(), BitWidth * 2);
// Check whether Start+Step*MaxBECount has no signed overflow.
const SCEV *SMul =
getMulExpr(CastedMaxBECount,
@@ -1637,7 +1638,7 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
if (!RHSC->getValue()->getValue().isPowerOf2())
++MaxShiftAmt;
const IntegerType *ExtTy =
- IntegerType::get(getTypeSizeInBits(Ty) + MaxShiftAmt);
+ IntegerType::get(getContext(), getTypeSizeInBits(Ty) + MaxShiftAmt);
// {X,+,N}/C --> {X/C,+,N/C} if safe and N/C can be folded.
if (const SCEVAddRecExpr *AR = dyn_cast(LHS))
if (const SCEVConstant *Step =
@@ -2064,7 +2065,7 @@ const Type *ScalarEvolution::getEffectiveSCEVType(const Type *Ty) const {
return Ty;
assert(isa(Ty) && "Unexpected non-pointer non-integer type!");
- return TD->getIntPtrType();
+ return TD->getIntPtrType(getContext());
}
const SCEV *ScalarEvolution::getCouldNotCompute() {
@@ -2432,7 +2433,7 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
///
const SCEV *ScalarEvolution::createNodeForGEP(Operator *GEP) {
- const Type *IntPtrTy = TD->getIntPtrType();
+ const Type *IntPtrTy = TD->getIntPtrType(getContext());
Value *Base = GEP->getOperand(0);
// Don't attempt to analyze GEPs over unsized objects.
if (!cast(Base->getType())->getElementType()->isSized())
@@ -2826,7 +2827,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
if (LZ != 0 && !((~A & ~KnownZero) & EffectiveMask))
return
getZeroExtendExpr(getTruncateExpr(getSCEV(U->getOperand(0)),
- IntegerType::get(BitWidth - LZ)),
+ IntegerType::get(getContext(), BitWidth - LZ)),
U->getType());
}
break;
@@ -2925,7 +2926,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
return getIntegerSCEV(0, U->getType()); // value is undefined
return
getSignExtendExpr(getTruncateExpr(getSCEV(L->getOperand(0)),
- IntegerType::get(Amt)),
+ IntegerType::get(getContext(), Amt)),
U->getType());
}
break;
@@ -3748,7 +3749,7 @@ ScalarEvolution::ComputeBackedgeTakenCountExhaustively(const Loop *L,
if (CondVal->getValue() == uint64_t(ExitWhen)) {
++NumBruteForceTripCountsComputed;
- return getConstant(Type::Int32Ty, IterationNum);
+ return getConstant(Type::getInt32Ty(getContext()), IterationNum);
}
// Compute the value of the PHI node for the next iteration.
@@ -4670,7 +4671,8 @@ const SCEV *ScalarEvolution::getBECount(const SCEV *Start,
// Check Add for unsigned overflow.
// TODO: More sophisticated things could be done here.
- const Type *WideTy = IntegerType::get(getTypeSizeInBits(Ty) + 1);
+ const Type *WideTy = IntegerType::get(getContext(),
+ getTypeSizeInBits(Ty) + 1);
const SCEV *EDiff = getZeroExtendExpr(Diff, WideTy);
const SCEV *ERoundUp = getZeroExtendExpr(RoundUp, WideTy);
const SCEV *OperandExtendedAdd = getAddExpr(EDiff, ERoundUp);
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp
index 40bf0a1a026..3ec6fe42d47 100644
--- a/lib/Analysis/ScalarEvolutionExpander.cpp
+++ b/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -298,7 +298,8 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin,
uint64_t FullOffset = C->getValue()->getZExtValue();
if (FullOffset < SL.getSizeInBytes()) {
unsigned ElIdx = SL.getElementContainingOffset(FullOffset);
- GepIndices.push_back(ConstantInt::get(Type::Int32Ty, ElIdx));
+ GepIndices.push_back(
+ ConstantInt::get(Type::getInt32Ty(Ty->getContext()), ElIdx));
ElTy = STy->getTypeAtIndex(ElIdx);
Ops[0] =
SE.getConstant(Ty, FullOffset - SL.getElementOffset(ElIdx));
@@ -321,7 +322,7 @@ Value *SCEVExpander::expandAddToGEP(const SCEV *const *op_begin,
// better than ptrtoint+arithmetic+inttoptr at least.
if (!AnyNonZeroIndices) {
V = InsertNoopCastOfTo(V,
- Type::Int8Ty->getPointerTo(PTy->getAddressSpace()));
+ Type::getInt8Ty(Ty->getContext())->getPointerTo(PTy->getAddressSpace()));
Value *Idx = expandCodeFor(SE.getAddExpr(Ops), Ty);
// Fold a GEP with constant operands.
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index af8649499b2..604d10c68b9 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -460,10 +460,12 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask,
Align = TD->getABITypeAlignment(AI->getType()->getElementType());
Align =
std::max(Align,
- (unsigned)TD->getABITypeAlignment(Type::DoubleTy));
+ (unsigned)TD->getABITypeAlignment(
+ Type::getDoubleTy(V->getContext())));
Align =
std::max(Align,
- (unsigned)TD->getABITypeAlignment(Type::Int64Ty));
+ (unsigned)TD->getABITypeAlignment(
+ Type::getInt64Ty(V->getContext())));
}
}
@@ -1034,7 +1036,7 @@ bool llvm::GetConstantStringInfo(Value *V, std::string &Str, uint64_t Offset,
// Make sure the index-ee is a pointer to array of i8.
const PointerType *PT = cast(GEP->getOperand(0)->getType());
const ArrayType *AT = dyn_cast(PT->getElementType());
- if (AT == 0 || AT->getElementType() != Type::Int8Ty)
+ if (AT == 0 || AT->getElementType() != Type::getInt8Ty(V->getContext()))
return false;
// Check to make sure that the first operand of the GEP is an integer and
@@ -1073,7 +1075,8 @@ bool llvm::GetConstantStringInfo(Value *V, std::string &Str, uint64_t Offset,
// Must be a Constant Array
ConstantArray *Array = dyn_cast(GlobalInit);
- if (Array == 0 || Array->getType()->getElementType() != Type::Int8Ty)
+ if (Array == 0 ||
+ Array->getType()->getElementType() != Type::getInt8Ty(V->getContext()))
return false;
// Get the number of elements in the array
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index c5e64244645..b98669efa3d 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -471,7 +471,7 @@ lltok::Kind LLLexer::LexIdentifier() {
Error("bitwidth for integer type out of range!");
return lltok::Error;
}
- TyVal = IntegerType::get(NumBits);
+ TyVal = IntegerType::get(Context, NumBits);
return lltok::Type;
}
@@ -579,14 +579,14 @@ lltok::Kind LLLexer::LexIdentifier() {
#define TYPEKEYWORD(STR, LLVMTY) \
if (Len == strlen(STR) && !memcmp(StartChar, STR, strlen(STR))) { \
TyVal = LLVMTY; return lltok::Type; }
- TYPEKEYWORD("void", Type::VoidTy);
- TYPEKEYWORD("float", Type::FloatTy);
- TYPEKEYWORD("double", Type::DoubleTy);
- TYPEKEYWORD("x86_fp80", Type::X86_FP80Ty);
- TYPEKEYWORD("fp128", Type::FP128Ty);
- TYPEKEYWORD("ppc_fp128", Type::PPC_FP128Ty);
- TYPEKEYWORD("label", Type::LabelTy);
- TYPEKEYWORD("metadata", Type::MetadataTy);
+ TYPEKEYWORD("void", Type::getVoidTy(Context));
+ TYPEKEYWORD("float", Type::getFloatTy(Context));
+ TYPEKEYWORD("double", Type::getDoubleTy(Context));
+ TYPEKEYWORD("x86_fp80", Type::getX86_FP80Ty(Context));
+ TYPEKEYWORD("fp128", Type::getFP128Ty(Context));
+ TYPEKEYWORD("ppc_fp128", Type::getPPC_FP128Ty(Context));
+ TYPEKEYWORD("label", Type::getLabelTy(Context));
+ TYPEKEYWORD("metadata", Type::getMetadataTy(Context));
#undef TYPEKEYWORD
// Handle special forms for autoupgrading. Drop these in LLVM 3.0. This is
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index ab686ced9b0..c3fd31ed4ce 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -259,7 +259,7 @@ bool LLParser::ParseUnnamedType() {
LocTy TypeLoc = Lex.getLoc();
Lex.Lex(); // eat kw_type
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty)) return true;
// See if this type was previously referenced.
@@ -286,7 +286,7 @@ bool LLParser::ParseNamedType() {
LocTy NameLoc = Lex.getLoc();
Lex.Lex(); // eat LocalVar.
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseToken(lltok::equal, "expected '=' after name") ||
ParseToken(lltok::kw_type, "expected 'type' after name") ||
@@ -486,7 +486,7 @@ bool LLParser::ParseNamedMetadata() {
if (ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
- NamedMDNode::Create(Name, Elts.data(), Elts.size(), M);
+ NamedMDNode::Create(Context, Name, Elts.data(), Elts.size(), M);
return false;
}
@@ -504,7 +504,7 @@ bool LLParser::ParseStandaloneMetadata() {
return true;
LocTy TyLoc;
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty, TyLoc))
return true;
@@ -628,7 +628,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
bool ThreadLocal, IsConstant;
LocTy TyLoc;
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseOptionalToken(lltok::kw_thread_local, ThreadLocal) ||
ParseOptionalAddrSpace(AddrSpace) ||
ParseGlobalType(IsConstant) ||
@@ -645,7 +645,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
return true;
}
- if (isa(Ty) || Ty == Type::LabelTy)
+ if (isa(Ty) || Ty == Type::getLabelTy(Context))
return Error(TyLoc, "invalid type for global variable");
GlobalVariable *GV = 0;
@@ -1065,7 +1065,7 @@ bool LLParser::ParseType(PATypeHolder &Result, bool AllowVoid) {
if (!UpRefs.empty())
return Error(UpRefs.back().Loc, "invalid unresolved type up reference");
- if (!AllowVoid && Result.get() == Type::VoidTy)
+ if (!AllowVoid && Result.get() == Type::getVoidTy(Context))
return Error(TypeLoc, "void type only allowed for function results");
return false;
@@ -1227,9 +1227,9 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
// TypeRec ::= TypeRec '*'
case lltok::star:
- if (Result.get() == Type::LabelTy)
+ if (Result.get() == Type::getLabelTy(Context))
return TokError("basic block pointers are invalid");
- if (Result.get() == Type::VoidTy)
+ if (Result.get() == Type::getVoidTy(Context))
return TokError("pointers to void are invalid; use i8* instead");
if (!PointerType::isValidElementType(Result.get()))
return TokError("pointer to this type is invalid");
@@ -1239,9 +1239,9 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
// TypeRec ::= TypeRec 'addrspace' '(' uint32 ')' '*'
case lltok::kw_addrspace: {
- if (Result.get() == Type::LabelTy)
+ if (Result.get() == Type::getLabelTy(Context))
return TokError("basic block pointers are invalid");
- if (Result.get() == Type::VoidTy)
+ if (Result.get() == Type::getVoidTy(Context))
return TokError("pointers to void are invalid; use i8* instead");
if (!PointerType::isValidElementType(Result.get()))
return TokError("pointer to this type is invalid");
@@ -1281,7 +1281,7 @@ bool LLParser::ParseParameterList(SmallVectorImpl &ArgList,
// Parse the argument.
LocTy ArgLoc;
- PATypeHolder ArgTy(Type::VoidTy);
+ PATypeHolder ArgTy(Type::getVoidTy(Context));
unsigned ArgAttrs1, ArgAttrs2;
Value *V;
if (ParseType(ArgTy, ArgLoc) ||
@@ -1322,7 +1322,7 @@ bool LLParser::ParseArgumentList(std::vector &ArgList,
Lex.Lex();
} else {
LocTy TypeLoc = Lex.getLoc();
- PATypeHolder ArgTy(Type::VoidTy);
+ PATypeHolder ArgTy(Type::getVoidTy(Context));
unsigned Attrs;
std::string Name;
@@ -1332,7 +1332,7 @@ bool LLParser::ParseArgumentList(std::vector &ArgList,
if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
ParseOptionalAttrs(Attrs, 0)) return true;
- if (ArgTy == Type::VoidTy)
+ if (ArgTy == Type::getVoidTy(Context))
return Error(TypeLoc, "argument can not have void type");
if (Lex.getKind() == lltok::LocalVar ||
@@ -1358,7 +1358,7 @@ bool LLParser::ParseArgumentList(std::vector &ArgList,
if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
ParseOptionalAttrs(Attrs, 0)) return true;
- if (ArgTy == Type::VoidTy)
+ if (ArgTy == Type::getVoidTy(Context))
return Error(TypeLoc, "argument can not have void type");
if (Lex.getKind() == lltok::LocalVar ||
@@ -1436,7 +1436,7 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
if (ParseTypeRec(Result)) return true;
ParamsList.push_back(Result);
- if (Result == Type::VoidTy)
+ if (Result == Type::getVoidTy(Context))
return Error(EltTyLoc, "struct element can not have void type");
if (!StructType::isValidElementType(Result))
return Error(EltTyLoc, "invalid element type for struct");
@@ -1445,7 +1445,7 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
EltTyLoc = Lex.getLoc();
if (ParseTypeRec(Result)) return true;
- if (Result == Type::VoidTy)
+ if (Result == Type::getVoidTy(Context))
return Error(EltTyLoc, "struct element can not have void type");
if (!StructType::isValidElementType(Result))
return Error(EltTyLoc, "invalid element type for struct");
@@ -1481,10 +1481,10 @@ bool LLParser::ParseArrayVectorType(PATypeHolder &Result, bool isVector) {
return true;
LocTy TypeLoc = Lex.getLoc();
- PATypeHolder EltTy(Type::VoidTy);
+ PATypeHolder EltTy(Type::getVoidTy(Context));
if (ParseTypeRec(EltTy)) return true;
- if (EltTy == Type::VoidTy)
+ if (EltTy == Type::getVoidTy(Context))
return Error(TypeLoc, "array and vector element type cannot be void");
if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
@@ -1575,7 +1575,7 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
- if (Ty == Type::LabelTy)
+ if (Ty == Type::getLabelTy(F.getContext()))
P.Error(Loc, "'%" + Name + "' is not a basic block");
else
P.Error(Loc, "'%" + Name + "' defined with type '" +
@@ -1584,15 +1584,16 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
}
// Don't make placeholders with invalid type.
- if (!Ty->isFirstClassType() && !isa(Ty) && Ty != Type::LabelTy) {
+ if (!Ty->isFirstClassType() && !isa(Ty) &&
+ Ty != Type::getLabelTy(F.getContext())) {
P.Error(Loc, "invalid use of a non-first-class type");
return 0;
}
// Otherwise, create a new forward reference for this value and remember it.
Value *FwdVal;
- if (Ty == Type::LabelTy)
- FwdVal = BasicBlock::Create(Name, &F);
+ if (Ty == Type::getLabelTy(F.getContext()))
+ FwdVal = BasicBlock::Create(F.getContext(), Name, &F);
else
FwdVal = new Argument(Ty, Name);
@@ -1617,7 +1618,7 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, const Type *Ty,
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
- if (Ty == Type::LabelTy)
+ if (Ty == Type::getLabelTy(F.getContext()))
P.Error(Loc, "'%" + utostr(ID) + "' is not a basic block");
else
P.Error(Loc, "'%" + utostr(ID) + "' defined with type '" +
@@ -1625,15 +1626,16 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, const Type *Ty,
return 0;
}
- if (!Ty->isFirstClassType() && !isa(Ty) && Ty != Type::LabelTy) {
+ if (!Ty->isFirstClassType() && !isa(Ty) &&
+ Ty != Type::getLabelTy(F.getContext())) {
P.Error(Loc, "invalid use of a non-first-class type");
return 0;
}
// Otherwise, create a new forward reference for this value and remember it.
Value *FwdVal;
- if (Ty == Type::LabelTy)
- FwdVal = BasicBlock::Create("", &F);
+ if (Ty == Type::getLabelTy(F.getContext()))
+ FwdVal = BasicBlock::Create(F.getContext(), "", &F);
else
FwdVal = new Argument(Ty);
@@ -1647,7 +1649,7 @@ bool LLParser::PerFunctionState::SetInstName(int NameID,
const std::string &NameStr,
LocTy NameLoc, Instruction *Inst) {
// If this instruction has void type, it cannot have a name or ID specified.
- if (Inst->getType() == Type::VoidTy) {
+ if (Inst->getType() == Type::getVoidTy(F.getContext())) {
if (NameID != -1 || !NameStr.empty())
return P.Error(NameLoc, "instructions returning void cannot have a name");
return false;
@@ -1702,11 +1704,13 @@ bool LLParser::PerFunctionState::SetInstName(int NameID,
/// forward reference record if needed.
BasicBlock *LLParser::PerFunctionState::GetBB(const std::string &Name,
LocTy Loc) {
- return cast_or_null(GetVal(Name, Type::LabelTy, Loc));
+ return cast_or_null(GetVal(Name,
+ Type::getLabelTy(F.getContext()), Loc));
}
BasicBlock *LLParser::PerFunctionState::GetBB(unsigned ID, LocTy Loc) {
- return cast_or_null(GetVal(ID, Type::LabelTy, Loc));
+ return cast_or_null(GetVal(ID,
+ Type::getLabelTy(F.getContext()), Loc));
}
/// DefineBB - Define the specified basic block, which is either named or
@@ -1899,7 +1903,7 @@ bool LLParser::ParseValID(ValID &ID) {
}
case lltok::kw_c: // c "foo"
Lex.Lex();
- ID.ConstantVal = ConstantArray::get(Lex.getStrVal(), false);
+ ID.ConstantVal = ConstantArray::get(Context, Lex.getStrVal(), false);
if (ParseToken(lltok::StringConstant, "expected string")) return true;
ID.Kind = ValID::t_Constant;
return false;
@@ -1932,7 +1936,7 @@ bool LLParser::ParseValID(ValID &ID) {
case lltok::kw_inttoptr:
case lltok::kw_ptrtoint: {
unsigned Opc = Lex.getUIntVal();
- PATypeHolder DestTy(Type::VoidTy);
+ PATypeHolder DestTy(Type::getVoidTy(Context));
Constant *SrcVal;
Lex.Lex();
if (ParseToken(lltok::lparen, "expected '(' after constantexpr cast") ||
@@ -2225,7 +2229,7 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
// The lexer has no type info, so builds all float and double FP constants
// as double. Fix this here. Long double does not need this.
if (&ID.APFloatVal.getSemantics() == &APFloat::IEEEdouble &&
- Ty == Type::FloatTy) {
+ Ty == Type::getFloatTy(Context)) {
bool Ignored;
ID.APFloatVal.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven,
&Ignored);
@@ -2244,7 +2248,7 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
return false;
case ValID::t_Undef:
// FIXME: LabelTy should not be a first-class type.
- if ((!Ty->isFirstClassType() || Ty == Type::LabelTy) &&
+ if ((!Ty->isFirstClassType() || Ty == Type::getLabelTy(Context)) &&
!isa(Ty))
return Error(ID.Loc, "invalid type for undef constant");
V = UndefValue::get(Ty);
@@ -2256,7 +2260,7 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
return false;
case ValID::t_Zero:
// FIXME: LabelTy should not be a first-class type.
- if (!Ty->isFirstClassType() || Ty == Type::LabelTy)
+ if (!Ty->isFirstClassType() || Ty == Type::getLabelTy(Context))
return Error(ID.Loc, "invalid type for null constant");
V = Constant::getNullValue(Ty);
return false;
@@ -2269,7 +2273,7 @@ bool LLParser::ConvertGlobalValIDToValue(const Type *Ty, ValID &ID,
}
bool LLParser::ParseGlobalTypeAndValue(Constant *&V) {
- PATypeHolder Type(Type::VoidTy);
+ PATypeHolder Type(Type::getVoidTy(Context));
return ParseType(Type) ||
ParseGlobalValue(Type, V);
}
@@ -2336,7 +2340,7 @@ bool LLParser::ParseValue(const Type *Ty, Value *&V, PerFunctionState &PFS) {
}
bool LLParser::ParseTypeAndValue(Value *&V, PerFunctionState &PFS) {
- PATypeHolder T(Type::VoidTy);
+ PATypeHolder T(Type::getVoidTy(Context));
return ParseType(T) ||
ParseValue(T, V, PFS);
}
@@ -2351,7 +2355,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
unsigned Linkage;
unsigned Visibility, CC, RetAttrs;
- PATypeHolder RetType(Type::VoidTy);
+ PATypeHolder RetType(Type::getVoidTy(Context));
LocTy RetTypeLoc = Lex.getLoc();
if (ParseOptionalLinkage(Linkage) ||
ParseOptionalVisibility(Visibility) ||
@@ -2460,7 +2464,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end());
if (PAL.paramHasAttr(1, Attribute::StructRet) &&
- RetType != Type::VoidTy)
+ RetType != Type::getVoidTy(Context))
return Error(RetTypeLoc, "functions with 'sret' argument must return void");
const FunctionType *FT =
@@ -2631,8 +2635,8 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
switch (Token) {
default: return Error(Loc, "expected instruction opcode");
// Terminator Instructions.
- case lltok::kw_unwind: Inst = new UnwindInst(); return false;
- case lltok::kw_unreachable: Inst = new UnreachableInst(); return false;
+ case lltok::kw_unwind: Inst = new UnwindInst(Context); return false;
+ case lltok::kw_unreachable: Inst = new UnreachableInst(Context); return false;
case lltok::kw_ret: return ParseRet(Inst, BB, PFS);
case lltok::kw_br: return ParseBr(Inst, PFS);
case lltok::kw_switch: return ParseSwitch(Inst, PFS);
@@ -2788,11 +2792,11 @@ bool LLParser::ParseCmpPredicate(unsigned &P, unsigned Opc) {
/// ::= 'ret' TypeAndValue (',' TypeAndValue)+ [[obsolete: LLVM 3.0]]
bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
PerFunctionState &PFS) {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty, true /*void allowed*/)) return true;
- if (Ty == Type::VoidTy) {
- Inst = ReturnInst::Create();
+ if (Ty == Type::getVoidTy(Context)) {
+ Inst = ReturnInst::Create(Context);
return false;
}
@@ -2818,7 +2822,7 @@ bool LLParser::ParseRet(Instruction *&Inst, BasicBlock *BB,
RV = I;
}
}
- Inst = ReturnInst::Create(RV);
+ Inst = ReturnInst::Create(Context, RV);
return false;
}
@@ -2836,7 +2840,7 @@ bool LLParser::ParseBr(Instruction *&Inst, PerFunctionState &PFS) {
return false;
}
- if (Op0->getType() != Type::Int1Ty)
+ if (Op0->getType() != Type::getInt1Ty(Context))
return Error(Loc, "branch condition must have 'i1' type");
if (ParseToken(lltok::comma, "expected ',' after branch condition") ||
@@ -2911,7 +2915,7 @@ bool LLParser::ParseSwitch(Instruction *&Inst, PerFunctionState &PFS) {
bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
LocTy CallLoc = Lex.getLoc();
unsigned CC, RetAttrs, FnAttrs;
- PATypeHolder RetType(Type::VoidTy);
+ PATypeHolder RetType(Type::getVoidTy(Context));
LocTy RetTypeLoc;
ValID CalleeID;
SmallVector ArgList;
@@ -3104,7 +3108,7 @@ bool LLParser::ParseCompare(Instruction *&Inst, PerFunctionState &PFS,
bool LLParser::ParseCast(Instruction *&Inst, PerFunctionState &PFS,
unsigned Opc) {
LocTy Loc; Value *Op;
- PATypeHolder DestTy(Type::VoidTy);
+ PATypeHolder DestTy(Type::getVoidTy(Context));
if (ParseTypeAndValue(Op, Loc, PFS) ||
ParseToken(lltok::kw_to, "expected 'to' after cast value") ||
ParseType(DestTy))
@@ -3143,7 +3147,7 @@ bool LLParser::ParseSelect(Instruction *&Inst, PerFunctionState &PFS) {
/// ::= 'va_arg' TypeAndValue ',' Type
bool LLParser::ParseVA_Arg(Instruction *&Inst, PerFunctionState &PFS) {
Value *Op;
- PATypeHolder EltTy(Type::VoidTy);
+ PATypeHolder EltTy(Type::getVoidTy(Context));
LocTy TypeLoc;
if (ParseTypeAndValue(Op, PFS) ||
ParseToken(lltok::comma, "expected ',' after vaarg operand") ||
@@ -3215,7 +3219,7 @@ bool LLParser::ParseShuffleVector(Instruction *&Inst, PerFunctionState &PFS) {
/// ParsePHI
/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Valueß ']')*
bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
Value *Op0, *Op1;
LocTy TypeLoc = Lex.getLoc();
@@ -3223,7 +3227,7 @@ bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
ParseToken(lltok::lsquare, "expected '[' in phi value list") ||
ParseValue(Ty, Op0, PFS) ||
ParseToken(lltok::comma, "expected ',' after insertelement value") ||
- ParseValue(Type::LabelTy, Op1, PFS) ||
+ ParseValue(Type::getLabelTy(Context), Op1, PFS) ||
ParseToken(lltok::rsquare, "expected ']' in phi value list"))
return true;
@@ -3237,7 +3241,7 @@ bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
if (ParseToken(lltok::lsquare, "expected '[' in phi value list") ||
ParseValue(Ty, Op0, PFS) ||
ParseToken(lltok::comma, "expected ',' after insertelement value") ||
- ParseValue(Type::LabelTy, Op1, PFS) ||
+ ParseValue(Type::getLabelTy(Context), Op1, PFS) ||
ParseToken(lltok::rsquare, "expected ']' in phi value list"))
return true;
}
@@ -3259,7 +3263,7 @@ bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
bool isTail) {
unsigned CC, RetAttrs, FnAttrs;
- PATypeHolder RetType(Type::VoidTy);
+ PATypeHolder RetType(Type::getVoidTy(Context));
LocTy RetTypeLoc;
ValID CalleeID;
SmallVector ArgList;
@@ -3358,7 +3362,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
/// ::= 'alloca' Type (',' TypeAndValue)? (',' OptionalAlignment)?
bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS,
unsigned Opc) {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
Value *Size = 0;
LocTy SizeLoc;
unsigned Alignment = 0;
@@ -3373,7 +3377,7 @@ bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS,
}
}
- if (Size && Size->getType() != Type::Int32Ty)
+ if (Size && Size->getType() != Type::getInt32Ty(Context))
return Error(SizeLoc, "element count must be i32");
if (Opc == Instruction::Malloc)
@@ -3540,7 +3544,7 @@ bool LLParser::ParseMDNodeVector(SmallVectorImpl &Elts) {
Lex.Lex();
V = 0;
} else {
- PATypeHolder Ty(Type::VoidTy);
+ PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty)) return true;
if (Lex.getKind() == lltok::Metadata) {
Lex.Lex();
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 5f184ec58d1..168f32951d5 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -143,7 +143,7 @@ namespace {
}
explicit ConstantPlaceHolder(const Type *Ty, LLVMContext& Context)
: ConstantExpr(Ty, Instruction::UserOp1, &Op<0>(), 1) {
- Op<0>() = UndefValue::get(Type::Int32Ty);
+ Op<0>() = UndefValue::get(Type::getInt32Ty(Context));
}
/// @brief Methods to support type inquiry through isa, cast, and dyn_cast.
@@ -339,12 +339,12 @@ Value *BitcodeReaderMDValueList::getValueFwdRef(unsigned Idx) {
resize(Idx + 1);
if (Value *V = MDValuePtrs[Idx]) {
- assert(V->getType() == Type::MetadataTy && "Type mismatch in value table!");
+ assert(V->getType() == Type::getMetadataTy(Context) && "Type mismatch in value table!");
return V;
}
// Create and return a placeholder, which will later be RAUW'd.
- Value *V = new Argument(Type::MetadataTy);
+ Value *V = new Argument(Type::getMetadataTy(Context));
MDValuePtrs[Idx] = V;
return V;
}
@@ -518,37 +518,37 @@ bool BitcodeReader::ParseTypeTable() {
TypeList.reserve(Record[0]);
continue;
case bitc::TYPE_CODE_VOID: // VOID
- ResultTy = Type::VoidTy;
+ ResultTy = Type::getVoidTy(Context);
break;
case bitc::TYPE_CODE_FLOAT: // FLOAT
- ResultTy = Type::FloatTy;
+ ResultTy = Type::getFloatTy(Context);
break;
case bitc::TYPE_CODE_DOUBLE: // DOUBLE
- ResultTy = Type::DoubleTy;
+ ResultTy = Type::getDoubleTy(Context);
break;
case bitc::TYPE_CODE_X86_FP80: // X86_FP80
- ResultTy = Type::X86_FP80Ty;
+ ResultTy = Type::getX86_FP80Ty(Context);
break;
case bitc::TYPE_CODE_FP128: // FP128
- ResultTy = Type::FP128Ty;
+ ResultTy = Type::getFP128Ty(Context);
break;
case bitc::TYPE_CODE_PPC_FP128: // PPC_FP128
- ResultTy = Type::PPC_FP128Ty;
+ ResultTy = Type::getPPC_FP128Ty(Context);
break;
case bitc::TYPE_CODE_LABEL: // LABEL
- ResultTy = Type::LabelTy;
+ ResultTy = Type::getLabelTy(Context);
break;
case bitc::TYPE_CODE_OPAQUE: // OPAQUE
ResultTy = 0;
break;
case bitc::TYPE_CODE_METADATA: // METADATA
- ResultTy = Type::MetadataTy;
+ ResultTy = Type::getMetadataTy(Context);
break;
case bitc::TYPE_CODE_INTEGER: // INTEGER: [width]
if (Record.size() < 1)
return Error("Invalid Integer type record");
- ResultTy = IntegerType::get(Record[0]);
+ ResultTy = IntegerType::get(Context, Record[0]);
break;
case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or
// [pointee type, address space]
@@ -792,8 +792,8 @@ bool BitcodeReader::ParseMetadata() {
if (MetadataBase *B = dyn_cast(MD))
Elts.push_back(B);
}
- Value *V = NamedMDNode::Create(Name.c_str(), Elts.data(), Elts.size(),
- TheModule);
+ Value *V = NamedMDNode::Create(Context, Name.c_str(), Elts.data(),
+ Elts.size(), TheModule);
MDValueList.AssignValue(V, NextValueNo++);
break;
}
@@ -805,9 +805,9 @@ bool BitcodeReader::ParseMetadata() {
SmallVector Elts;
for (unsigned i = 0; i != Size; i += 2) {
const Type *Ty = getTypeByID(Record[i], false);
- if (Ty == Type::MetadataTy)
+ if (Ty == Type::getMetadataTy(Context))
Elts.push_back(MDValueList.getValueFwdRef(Record[i+1]));
- else if (Ty != Type::VoidTy)
+ else if (Ty != Type::getVoidTy(Context))
Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
else
Elts.push_back(NULL);
@@ -900,7 +900,7 @@ bool BitcodeReader::ParseConstants() {
SmallVector Record;
// Read all the records for this value table.
- const Type *CurTy = Type::Int32Ty;
+ const Type *CurTy = Type::getInt32Ty(Context);
unsigned NextCstNo = ValueList.size();
while (1) {
unsigned Code = Stream.ReadCode();
@@ -961,19 +961,19 @@ bool BitcodeReader::ParseConstants() {
case bitc::CST_CODE_FLOAT: { // FLOAT: [fpval]
if (Record.empty())
return Error("Invalid FLOAT record");
- if (CurTy == Type::FloatTy)
+ if (CurTy == Type::getFloatTy(Context))
V = ConstantFP::get(Context, APFloat(APInt(32, (uint32_t)Record[0])));
- else if (CurTy == Type::DoubleTy)
+ else if (CurTy == Type::getDoubleTy(Context))
V = ConstantFP::get(Context, APFloat(APInt(64, Record[0])));
- else if (CurTy == Type::X86_FP80Ty) {
+ else if (CurTy == Type::getX86_FP80Ty(Context)) {
// Bits are not stored the same way as a normal i80 APInt, compensate.
uint64_t Rearrange[2];
Rearrange[0] = (Record[1] & 0xffffLL) | (Record[0] << 16);
Rearrange[1] = Record[0] >> 48;
V = ConstantFP::get(Context, APFloat(APInt(80, 2, Rearrange)));
- } else if (CurTy == Type::FP128Ty)
+ } else if (CurTy == Type::getFP128Ty(Context))
V = ConstantFP::get(Context, APFloat(APInt(128, 2, &Record[0]), true));
- else if (CurTy == Type::PPC_FP128Ty)
+ else if (CurTy == Type::getPPC_FP128Ty(Context))
V = ConstantFP::get(Context, APFloat(APInt(128, 2, &Record[0])));
else
V = UndefValue::get(CurTy);
@@ -1081,7 +1081,7 @@ bool BitcodeReader::ParseConstants() {
case bitc::CST_CODE_CE_SELECT: // CE_SELECT: [opval#, opval#, opval#]
if (Record.size() < 3) return Error("Invalid CE_SELECT record");
V = ConstantExpr::getSelect(ValueList.getConstantFwdRef(Record[0],
- Type::Int1Ty),
+ Type::getInt1Ty(Context)),
ValueList.getConstantFwdRef(Record[1],CurTy),
ValueList.getConstantFwdRef(Record[2],CurTy));
break;
@@ -1091,7 +1091,7 @@ bool BitcodeReader::ParseConstants() {
dyn_cast_or_null(getTypeByID(Record[0]));
if (OpTy == 0) return Error("Invalid CE_EXTRACTELT record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
- Constant *Op1 = ValueList.getConstantFwdRef(Record[2], Type::Int32Ty);
+ Constant *Op1 = ValueList.getConstantFwdRef(Record[2], Type::getInt32Ty(Context));
V = ConstantExpr::getExtractElement(Op0, Op1);
break;
}
@@ -1102,7 +1102,7 @@ bool BitcodeReader::ParseConstants() {
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1],
OpTy->getElementType());
- Constant *Op2 = ValueList.getConstantFwdRef(Record[2], Type::Int32Ty);
+ Constant *Op2 = ValueList.getConstantFwdRef(Record[2], Type::getInt32Ty(Context));
V = ConstantExpr::getInsertElement(Op0, Op1, Op2);
break;
}
@@ -1112,7 +1112,7 @@ bool BitcodeReader::ParseConstants() {
return Error("Invalid CE_SHUFFLEVEC record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
- const Type *ShufTy = VectorType::get(Type::Int32Ty,
+ const Type *ShufTy = VectorType::get(Type::getInt32Ty(Context),
OpTy->getNumElements());
Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy);
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
@@ -1125,7 +1125,7 @@ bool BitcodeReader::ParseConstants() {
return Error("Invalid CE_SHUFVEC_EX record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
- const Type *ShufTy = VectorType::get(Type::Int32Ty,
+ const Type *ShufTy = VectorType::get(Type::getInt32Ty(Context),
RTy->getNumElements());
Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy);
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
@@ -1592,7 +1592,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
// Create all the basic blocks for the function.
FunctionBBs.resize(Record[0]);
for (unsigned i = 0, e = FunctionBBs.size(); i != e; ++i)
- FunctionBBs[i] = BasicBlock::Create("", F);
+ FunctionBBs[i] = BasicBlock::Create(Context, "", F);
CurBB = FunctionBBs[0];
continue;
@@ -1698,7 +1698,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
Value *TrueVal, *FalseVal, *Cond;
if (getValueTypePair(Record, OpNum, NextValueNo, TrueVal) ||
getValue(Record, OpNum, TrueVal->getType(), FalseVal) ||
- getValue(Record, OpNum, Type::Int1Ty, Cond))
+ getValue(Record, OpNum, Type::getInt1Ty(Context), Cond))
return Error("Invalid SELECT record");
I = SelectInst::Create(Cond, TrueVal, FalseVal);
@@ -1719,11 +1719,11 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
if (const VectorType* vector_type =
dyn_cast(Cond->getType())) {
// expect
- if (vector_type->getElementType() != Type::Int1Ty)
+ if (vector_type->getElementType() != Type::getInt1Ty(Context))
return Error("Invalid SELECT condition type");
} else {
// expect i1
- if (Cond->getType() != Type::Int1Ty)
+ if (Cond->getType() != Type::getInt1Ty(Context))
return Error("Invalid SELECT condition type");
}
@@ -1735,7 +1735,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
unsigned OpNum = 0;
Value *Vec, *Idx;
if (getValueTypePair(Record, OpNum, NextValueNo, Vec) ||
- getValue(Record, OpNum, Type::Int32Ty, Idx))
+ getValue(Record, OpNum, Type::getInt32Ty(Context), Idx))
return Error("Invalid EXTRACTELT record");
I = ExtractElementInst::Create(Vec, Idx);
break;
@@ -1747,7 +1747,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
if (getValueTypePair(Record, OpNum, NextValueNo, Vec) ||
getValue(Record, OpNum,
cast(Vec->getType())->getElementType(), Elt) ||
- getValue(Record, OpNum, Type::Int32Ty, Idx))
+ getValue(Record, OpNum, Type::getInt32Ty(Context), Idx))
return Error("Invalid INSERTELT record");
I = InsertElementInst::Create(Vec, Elt, Idx);
break;
@@ -1802,7 +1802,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
{
unsigned Size = Record.size();
if (Size == 0) {
- I = ReturnInst::Create();
+ I = ReturnInst::Create(Context);
break;
}
@@ -1826,11 +1826,11 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
ValueList.AssignValue(I, NextValueNo++);
RV = I;
}
- I = ReturnInst::Create(RV);
+ I = ReturnInst::Create(Context, RV);
break;
}
- I = ReturnInst::Create(Vs[0]);
+ I = ReturnInst::Create(Context, Vs[0]);
break;
}
case bitc::FUNC_CODE_INST_BR: { // BR: [bb#, bb#, opval] or [bb#]
@@ -1844,7 +1844,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
I = BranchInst::Create(TrueDest);
else {
BasicBlock *FalseDest = getBasicBlock(Record[1]);
- Value *Cond = getFnValueByID(Record[2], Type::Int1Ty);
+ Value *Cond = getFnValueByID(Record[2], Type::getInt1Ty(Context));
if (FalseDest == 0 || Cond == 0)
return Error("Invalid BR record");
I = BranchInst::Create(TrueDest, FalseDest, Cond);
@@ -1923,10 +1923,10 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
break;
}
case bitc::FUNC_CODE_INST_UNWIND: // UNWIND
- I = new UnwindInst();
+ I = new UnwindInst(Context);
break;
case bitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE
- I = new UnreachableInst();
+ I = new UnreachableInst(Context);
break;
case bitc::FUNC_CODE_INST_PHI: { // PHI: [ty, val0,bb0, ...]
if (Record.size() < 1 || ((Record.size()-1)&1))
@@ -1952,7 +1952,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
return Error("Invalid MALLOC record");
const PointerType *Ty =
dyn_cast_or_null(getTypeByID(Record[0]));
- Value *Size = getFnValueByID(Record[1], Type::Int32Ty);
+ Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context));
unsigned Align = Record[2];
if (!Ty || !Size) return Error("Invalid MALLOC record");
I = new MallocInst(Ty->getElementType(), Size, (1 << Align) >> 1);
@@ -1972,7 +1972,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
return Error("Invalid ALLOCA record");
const PointerType *Ty =
dyn_cast_or_null(getTypeByID(Record[0]));
- Value *Size = getFnValueByID(Record[1], Type::Int32Ty);
+ Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context));
unsigned Align = Record[2];
if (!Ty || !Size) return Error("Invalid ALLOCA record");
I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
@@ -2089,7 +2089,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
}
// Non-void values get registered in the value table for future use.
- if (I && I->getType() != Type::VoidTy)
+ if (I && I->getType() != Type::getVoidTy(Context))
ValueList.AssignValue(I, NextValueNo++);
}
diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h
index bd048885a65..a7853abbc98 100644
--- a/lib/Bitcode/Reader/BitcodeReader.h
+++ b/lib/Bitcode/Reader/BitcodeReader.h
@@ -196,7 +196,7 @@ public:
private:
const Type *getTypeByID(unsigned ID, bool isTypeTable = false);
Value *getFnValueByID(unsigned ID, const Type *Ty) {
- if (Ty == Type::MetadataTy)
+ if (Ty == Type::getMetadataTy(Context))
return MDValueList.getValueFwdRef(ID);
else
return ValueList.getValueFwdRef(ID, Ty);
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index cb181d2810b..07566a71c3f 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -482,7 +482,7 @@ static void WriteMDNode(const MDNode *N,
Record.push_back(VE.getTypeID(N->getElement(i)->getType()));
Record.push_back(VE.getValueID(N->getElement(i)));
} else {
- Record.push_back(VE.getTypeID(Type::VoidTy));
+ Record.push_back(VE.getTypeID(Type::getVoidTy(N->getContext())));
Record.push_back(0);
}
}
@@ -663,16 +663,18 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal,
} else if (const ConstantFP *CFP = dyn_cast(C)) {
Code = bitc::CST_CODE_FLOAT;
const Type *Ty = CFP->getType();
- if (Ty == Type::FloatTy || Ty == Type::DoubleTy) {
+ if (Ty == Type::getFloatTy(Ty->getContext()) ||
+ Ty == Type::getDoubleTy(Ty->getContext())) {
Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
- } else if (Ty == Type::X86_FP80Ty) {
+ } else if (Ty == Type::getX86_FP80Ty(Ty->getContext())) {
// api needed to prevent premature destruction
// bits are not in the same order as a normal i80 APInt, compensate.
APInt api = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
Record.push_back((p[1] << 48) | (p[0] >> 16));
Record.push_back(p[0] & 0xffffLL);
- } else if (Ty == Type::FP128Ty || Ty == Type::PPC_FP128Ty) {
+ } else if (Ty == Type::getFP128Ty(Ty->getContext()) ||
+ Ty == Type::getPPC_FP128Ty(Ty->getContext())) {
APInt api = CFP->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
Record.push_back(p[0]);
@@ -1139,7 +1141,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
I != E; ++I) {
WriteInstruction(*I, InstID, VE, Stream, Vals);
- if (I->getType() != Type::VoidTy)
+ if (I->getType() != Type::getVoidTy(F.getContext()))
++InstID;
}
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp
index 4712dea7629..783022cac29 100644
--- a/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -198,7 +198,7 @@ void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
if (*I)
EnumerateValue(*I);
else
- EnumerateType(Type::VoidTy);
+ EnumerateType(Type::getVoidTy(MD->getContext()));
}
return;
} else if (const NamedMDNode *N = dyn_cast(MD)) {
@@ -218,7 +218,8 @@ void ValueEnumerator::EnumerateMetadata(const MetadataBase *MD) {
}
void ValueEnumerator::EnumerateValue(const Value *V) {
- assert(V->getType() != Type::VoidTy && "Can't insert void values!");
+ assert(V->getType() != Type::getVoidTy(V->getContext()) &&
+ "Can't insert void values!");
if (const MetadataBase *MB = dyn_cast(V))
return EnumerateMetadata(MB);
@@ -358,7 +359,7 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
// Add all of the instructions.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
- if (I->getType() != Type::VoidTy)
+ if (I->getType() != Type::getVoidTy(F.getContext()))
EnumerateValue(I);
}
}
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 55ff0b716ba..6d1c7da1e18 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -871,7 +871,8 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
// Handle casts to pointers by changing them into casts to the appropriate
// integer type. This promotes constant folding and simplifies this code.
Constant *Op = CE->getOperand(0);
- Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(), false/*ZExt*/);
+ Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(CV->getContext()),
+ false/*ZExt*/);
return EmitConstantValueOnly(Op);
}
@@ -1016,8 +1017,9 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
unsigned AddrSpace) {
// FP Constants are printed as integer constants to avoid losing
// precision...
+ LLVMContext &Context = CFP->getContext();
const TargetData *TD = TM.getTargetData();
- if (CFP->getType() == Type::DoubleTy) {
+ if (CFP->getType() == Type::getDoubleTy(Context)) {
double Val = CFP->getValueAPF().convertToDouble(); // for comment only
uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
if (TAI->getData64bitsDirective(AddrSpace)) {
@@ -1059,7 +1061,7 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
O << '\n';
}
return;
- } else if (CFP->getType() == Type::FloatTy) {
+ } else if (CFP->getType() == Type::getFloatTy(Context)) {
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
O << TAI->getData32bitsDirective(AddrSpace)
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue();
@@ -1069,7 +1071,7 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
}
O << '\n';
return;
- } else if (CFP->getType() == Type::X86_FP80Ty) {
+ } else if (CFP->getType() == Type::getX86_FP80Ty(Context)) {
// all long double variants are printed as hex
// api needed to prevent premature destruction
APInt api = CFP->getValueAPF().bitcastToAPInt();
@@ -1151,10 +1153,10 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
}
O << '\n';
}
- EmitZeros(TD->getTypeAllocSize(Type::X86_FP80Ty) -
- TD->getTypeStoreSize(Type::X86_FP80Ty), AddrSpace);
+ EmitZeros(TD->getTypeAllocSize(Type::getX86_FP80Ty(Context)) -
+ TD->getTypeStoreSize(Type::getX86_FP80Ty(Context)), AddrSpace);
return;
- } else if (CFP->getType() == Type::PPC_FP128Ty) {
+ } else if (CFP->getType() == Type::getPPC_FP128Ty(Context)) {
// all long double variants are printed as hex
// api needed to prevent premature destruction
APInt api = CFP->getValueAPF().bitcastToAPInt();
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 5bfb32870c9..16581112b66 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -142,7 +142,8 @@ bool DwarfEHPrepare::NormalizeLandingPads() {
// edges to a new basic block which falls through into this one.
// Create the new basic block.
- BasicBlock *NewBB = BasicBlock::Create(LPad->getName() + "_unwind_edge");
+ BasicBlock *NewBB = BasicBlock::Create(F->getContext(),
+ LPad->getName() + "_unwind_edge");
// Insert it into the function right before the original landing pad.
LPad->getParent()->getBasicBlockList().insert(LPad, NewBB);
@@ -230,8 +231,10 @@ bool DwarfEHPrepare::LowerUnwinds() {
// Find the rewind function if we didn't already.
if (!RewindFunction) {
- std::vector Params(1, PointerType::getUnqual(Type::Int8Ty));
- FunctionType *FTy = FunctionType::get(Type::VoidTy, Params, false);
+ std::vector Params(1,
+ PointerType::getUnqual(Type::getInt8Ty(TI->getContext())));
+ FunctionType *FTy = FunctionType::get(Type::getVoidTy(TI->getContext()),
+ Params, false);
const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME);
RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy);
}
@@ -239,7 +242,7 @@ bool DwarfEHPrepare::LowerUnwinds() {
// Create the call...
CallInst::Create(RewindFunction, CreateReadOfExceptionValue(I), "", TI);
// ...followed by an UnreachableInst.
- new UnreachableInst(TI);
+ new UnreachableInst(TI->getContext(), TI);
// Nuke the unwind instruction.
TI->eraseFromParent();
@@ -354,8 +357,8 @@ Instruction *DwarfEHPrepare::CreateValueLoad(BasicBlock *BB) {
// Create the temporary if we didn't already.
if (!ExceptionValueVar) {
- ExceptionValueVar = new AllocaInst(PointerType::getUnqual(Type::Int8Ty),
- "eh.value", F->begin()->begin());
+ ExceptionValueVar = new AllocaInst(PointerType::getUnqual(
+ Type::getInt8Ty(BB->getContext())), "eh.value", F->begin()->begin());
++NumStackTempsIntroduced;
}
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index 1518a34acb6..e62079f9472 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/lib/CodeGen/ELFWriter.cpp
@@ -440,15 +440,16 @@ void ELFWriter::EmitGlobalConstant(const Constant *CV, ELFSection &GblS) {
return;
} else if (const ConstantFP *CFP = dyn_cast(CV)) {
APInt Val = CFP->getValueAPF().bitcastToAPInt();
- if (CFP->getType() == Type::DoubleTy)
+ if (CFP->getType() == Type::getDoubleTy(CV->getContext()))
GblS.emitWord64(Val.getZExtValue());
- else if (CFP->getType() == Type::FloatTy)
+ else if (CFP->getType() == Type::getFloatTy(CV->getContext()))
GblS.emitWord32(Val.getZExtValue());
- else if (CFP->getType() == Type::X86_FP80Ty) {
- unsigned PadSize = TD->getTypeAllocSize(Type::X86_FP80Ty)-
- TD->getTypeStoreSize(Type::X86_FP80Ty);
+ else if (CFP->getType() == Type::getX86_FP80Ty(CV->getContext())) {
+ unsigned PadSize =
+ TD->getTypeAllocSize(Type::getX86_FP80Ty(CV->getContext()))-
+ TD->getTypeStoreSize(Type::getX86_FP80Ty(CV->getContext()));
GblS.emitWordFP80(Val.getRawData(), PadSize);
- } else if (CFP->getType() == Type::PPC_FP128Ty)
+ } else if (CFP->getType() == Type::getPPC_FP128Ty(CV->getContext()))
llvm_unreachable("PPC_FP128Ty global emission not implemented");
return;
} else if (const ConstantInt *CI = dyn_cast(CV)) {
@@ -526,7 +527,8 @@ CstExprResTy ELFWriter::ResolveConstantExpr(const Constant *CV) {
}
case Instruction::IntToPtr: {
Constant *Op = CE->getOperand(0);
- Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(), false/*ZExt*/);
+ Op = ConstantExpr::getIntegerCast(Op, TD->getIntPtrType(CV->getContext()),
+ false/*ZExt*/);
return ResolveConstantExpr(Op);
}
case Instruction::PtrToInt: {
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 67e4e6f7626..cf855f0e896 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -40,11 +40,11 @@ static void EnsureFPIntrinsicsExist(Module &M, Function *Fn,
switch((int)Fn->arg_begin()->getType()->getTypeID()) {
case Type::FloatTyID:
EnsureFunctionExists(M, FName, Fn->arg_begin(), Fn->arg_end(),
- Type::FloatTy);
+ Type::getFloatTy(M.getContext()));
break;
case Type::DoubleTyID:
EnsureFunctionExists(M, DName, Fn->arg_begin(), Fn->arg_end(),
- Type::DoubleTy);
+ Type::getDoubleTy(M.getContext()));
break;
case Type::X86_FP80TyID:
case Type::FP128TyID:
@@ -83,39 +83,43 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
}
void IntrinsicLowering::AddPrototypes(Module &M) {
+ LLVMContext &Context = M.getContext();
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (I->isDeclaration() && !I->use_empty())
switch (I->getIntrinsicID()) {
default: break;
case Intrinsic::setjmp:
EnsureFunctionExists(M, "setjmp", I->arg_begin(), I->arg_end(),
- Type::Int32Ty);
+ Type::getInt32Ty(M.getContext()));
break;
case Intrinsic::longjmp:
EnsureFunctionExists(M, "longjmp", I->arg_begin(), I->arg_end(),
- Type::VoidTy);
+ Type::getVoidTy(M.getContext()));
break;
case Intrinsic::siglongjmp:
EnsureFunctionExists(M, "abort", I->arg_end(), I->arg_end(),
- Type::VoidTy);
+ Type::getVoidTy(M.getContext()));
break;
case Intrinsic::memcpy:
- M.getOrInsertFunction("memcpy", PointerType::getUnqual(Type::Int8Ty),
- PointerType::getUnqual(Type::Int8Ty),
- PointerType::getUnqual(Type::Int8Ty),
- TD.getIntPtrType(), (Type *)0);
+ M.getOrInsertFunction("memcpy",
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ TD.getIntPtrType(Context), (Type *)0);
break;
case Intrinsic::memmove:
- M.getOrInsertFunction("memmove", PointerType::getUnqual(Type::Int8Ty),
- PointerType::getUnqual(Type::Int8Ty),
- PointerType::getUnqual(Type::Int8Ty),
- TD.getIntPtrType(), (Type *)0);
+ M.getOrInsertFunction("memmove",
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ TD.getIntPtrType(Context), (Type *)0);
break;
case Intrinsic::memset:
- M.getOrInsertFunction("memset", PointerType::getUnqual(Type::Int8Ty),
- PointerType::getUnqual(Type::Int8Ty),
- Type::Int32Ty,
- TD.getIntPtrType(), (Type *)0);
+ M.getOrInsertFunction("memset",
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ PointerType::getUnqual(Type::getInt8Ty(Context)),
+ Type::getInt32Ty(M.getContext()),
+ TD.getIntPtrType(Context), (Type *)0);
break;
case Intrinsic::sqrt:
EnsureFPIntrinsicsExist(M, I, "sqrtf", "sqrt", "sqrtl");
@@ -176,10 +180,10 @@ static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) {
Value *Tmp1 = Builder.CreateLShr(V,ConstantInt::get(V->getType(), 24),
"bswap.1");
Tmp3 = Builder.CreateAnd(Tmp3,
- ConstantInt::get(Type::Int32Ty, 0xFF0000),
+ ConstantInt::get(Type::getInt32Ty(Context), 0xFF0000),
"bswap.and3");
Tmp2 = Builder.CreateAnd(Tmp2,
- ConstantInt::get(Type::Int32Ty, 0xFF00),
+ ConstantInt::get(Type::getInt32Ty(Context), 0xFF00),
"bswap.and2");
Tmp4 = Builder.CreateOr(Tmp4, Tmp3, "bswap.or1");
Tmp2 = Builder.CreateOr(Tmp2, Tmp1, "bswap.or2");
@@ -207,24 +211,28 @@ static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) {
ConstantInt::get(V->getType(), 56),
"bswap.1");
Tmp7 = Builder.CreateAnd(Tmp7,
- ConstantInt::get(Type::Int64Ty,
+ ConstantInt::get(Type::getInt64Ty(Context),
0xFF000000000000ULL),
"bswap.and7");
Tmp6 = Builder.CreateAnd(Tmp6,
- ConstantInt::get(Type::Int64Ty,
+ ConstantInt::get(Type::getInt64Ty(Context),
0xFF0000000000ULL),
"bswap.and6");
Tmp5 = Builder.CreateAnd(Tmp5,
- ConstantInt::get(Type::Int64Ty, 0xFF00000000ULL),
+ ConstantInt::get(Type::getInt64Ty(Context),
+ 0xFF00000000ULL),
"bswap.and5");
Tmp4 = Builder.CreateAnd(Tmp4,
- ConstantInt::get(Type::Int64Ty, 0xFF000000ULL),
+ ConstantInt::get(Type::getInt64Ty(Context),
+ 0xFF000000ULL),
"bswap.and4");
Tmp3 = Builder.CreateAnd(Tmp3,
- ConstantInt::get(Type::Int64Ty, 0xFF0000ULL),
+ ConstantInt::get(Type::getInt64Ty(Context),
+ 0xFF0000ULL),
"bswap.and3");
Tmp2 = Builder.CreateAnd(Tmp2,
- ConstantInt::get(Type::Int64Ty, 0xFF00ULL),
+ ConstantInt::get(Type::getInt64Ty(Context),
+ 0xFF00ULL),
"bswap.and2");
Tmp8 = Builder.CreateOr(Tmp8, Tmp7, "bswap.or1");
Tmp6 = Builder.CreateOr(Tmp6, Tmp5, "bswap.or2");
@@ -303,11 +311,11 @@ static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
default: llvm_unreachable("Invalid type in intrinsic");
case Type::FloatTyID:
ReplaceCallWith(Fname, CI, CI->op_begin() + 1, CI->op_end(),
- Type::FloatTy);
+ Type::getFloatTy(CI->getContext()));
break;
case Type::DoubleTyID:
ReplaceCallWith(Dname, CI, CI->op_begin() + 1, CI->op_end(),
- Type::DoubleTy);
+ Type::getDoubleTy(CI->getContext()));
break;
case Type::X86_FP80TyID:
case Type::FP128TyID:
@@ -339,26 +347,26 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
// convert the call to an explicit setjmp or longjmp call.
case Intrinsic::setjmp: {
Value *V = ReplaceCallWith("setjmp", CI, CI->op_begin() + 1, CI->op_end(),
- Type::Int32Ty);
- if (CI->getType() != Type::VoidTy)
+ Type::getInt32Ty(Context));
+ if (CI->getType() != Type::getVoidTy(Context))
CI->replaceAllUsesWith(V);
break;
}
case Intrinsic::sigsetjmp:
- if (CI->getType() != Type::VoidTy)
+ if (CI->getType() != Type::getVoidTy(Context))
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
break;
case Intrinsic::longjmp: {
ReplaceCallWith("longjmp", CI, CI->op_begin() + 1, CI->op_end(),
- Type::VoidTy);
+ Type::getVoidTy(Context));
break;
}
case Intrinsic::siglongjmp: {
// Insert the call to abort
ReplaceCallWith("abort", CI, CI->op_end(), CI->op_end(),
- Type::VoidTy);
+ Type::getVoidTy(Context));
break;
}
case Intrinsic::ctpop:
@@ -414,7 +422,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::readcyclecounter: {
cerr << "WARNING: this target does not support the llvm.readcyclecoun"
<< "ter intrinsic. It is being lowered to a constant 0\n";
- CI->replaceAllUsesWith(ConstantInt::get(Type::Int64Ty, 0));
+ CI->replaceAllUsesWith(ConstantInt::get(Type::getInt64Ty(Context), 0));
break;
}
@@ -441,7 +449,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break; // Strip out annotate intrinsic
case Intrinsic::memcpy: {
- const IntegerType *IntPtr = TD.getIntPtrType();
+ const IntegerType *IntPtr = TD.getIntPtrType(Context);
Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
/* isSigned */ false);
Value *Ops[3];
@@ -452,7 +460,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break;
}
case Intrinsic::memmove: {
- const IntegerType *IntPtr = TD.getIntPtrType();
+ const IntegerType *IntPtr = TD.getIntPtrType(Context);
Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
/* isSigned */ false);
Value *Ops[3];
@@ -463,13 +471,13 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break;
}
case Intrinsic::memset: {
- const IntegerType *IntPtr = TD.getIntPtrType();
+ const IntegerType *IntPtr = TD.getIntPtrType(Context);
Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
/* isSigned */ false);
Value *Ops[3];
Ops[0] = CI->getOperand(1);
// Extend the amount to i32.
- Ops[1] = Builder.CreateIntCast(CI->getOperand(2), Type::Int32Ty,
+ Ops[1] = Builder.CreateIntCast(CI->getOperand(2), Type::getInt32Ty(Context),
/* isSigned */ false);
Ops[2] = Size;
ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getOperand(1)->getType());
@@ -505,7 +513,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
}
case Intrinsic::flt_rounds:
// Lower to "round to the nearest"
- if (CI->getType() != Type::VoidTy)
+ if (CI->getType() != Type::getVoidTy(Context))
CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
break;
}
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 3b854a59a1f..9efec1c1caa 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -100,7 +100,8 @@ MachineFunction::MachineFunction(Function *F,
const TargetData &TD = *TM.getTargetData();
bool IsPic = TM.getRelocationModel() == Reloc::PIC_;
unsigned EntrySize = IsPic ? 4 : TD.getPointerSize();
- unsigned TyAlignment = IsPic ? TD.getABITypeAlignment(Type::Int32Ty)
+ unsigned TyAlignment = IsPic ?
+ TD.getABITypeAlignment(Type::getInt32Ty(F->getContext()))
: TD.getPointerABIAlignment();
JumpTableInfo = new (Allocator.Allocate())
MachineJumpTableInfo(EntrySize, TyAlignment);
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index dd2fef7ff00..7d1f15c487b 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -243,7 +243,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
OS << getImm();
break;
case MachineOperand::MO_FPImmediate:
- if (getFPImm()->getType() == Type::FloatTy)
+ if (getFPImm()->getType() == Type::getFloatTy(getFPImm()->getContext()))
OS << getFPImm()->getValueAPF().convertToFloat();
else
OS << getFPImm()->getValueAPF().convertToDouble();
diff --git a/lib/CodeGen/PseudoSourceValue.cpp b/lib/CodeGen/PseudoSourceValue.cpp
index 81cbfb83d2f..c44093606e3 100644
--- a/lib/CodeGen/PseudoSourceValue.cpp
+++ b/lib/CodeGen/PseudoSourceValue.cpp
@@ -39,8 +39,13 @@ static const char *const PSVNames[] = {
"ConstantPool"
};
+// FIXME: THIS IS A HACK!!!!
+// Eventually these should be uniqued on LLVMContext rather than in a managed
+// static. For now, we can safely use the global context for the time being to
+// squeak by.
PseudoSourceValue::PseudoSourceValue() :
- Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {}
+ Value(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())),
+ PseudoSourceValueVal) {}
void PseudoSourceValue::dump() const {
print(errs()); errs() << '\n';
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index d0d4f198f6a..9496ff24460 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -92,7 +92,8 @@ unsigned FastISel::getRegForValue(Value *V) {
} else if (isa(V)) {
// Translate this as an integer zero so that it can be
// local-CSE'd with actual integer zeros.
- Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType()));
+ Reg =
+ getRegForValue(Constant::getNullValue(TD.getIntPtrType(V->getContext())));
} else if (ConstantFP *CF = dyn_cast(V)) {
Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF);
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index b4799f12e98..ab4ebefa30b 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -1997,7 +1997,8 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(bool isSigned,
case MVT::i64: FF = 0x5F800000ULL; break; // 2^64 (as a float)
}
if (TLI.isLittleEndian()) FF <<= 32;
- Constant *FudgeFactor = ConstantInt::get(Type::Int64Ty, FF);
+ Constant *FudgeFactor = ConstantInt::get(
+ Type::getInt64Ty(*DAG.getContext()), FF);
SDValue CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
unsigned Alignment = cast(CPIdx)->getAlignment();
@@ -2275,7 +2276,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
// If this operation is not supported, lower it to 'abort()' call
TargetLowering::ArgListTy Args;
std::pair CallResult =
- TLI.LowerCallTo(Node->getOperand(0), Type::VoidTy,
+ TLI.LowerCallTo(Node->getOperand(0), Type::getVoidTy(*DAG.getContext()),
false, false, false, false, 0, CallingConv::C, false,
/*isReturnValueUsed=*/true,
DAG.getExternalSymbol("abort", TLI.getPointerTy()),
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 8dba404acf3..afcbc0987bf 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -789,7 +789,7 @@ void SelectionDAG::VerifyNode(SDNode *N) {
///
unsigned SelectionDAG::getEVTAlignment(EVT VT) const {
const Type *Ty = VT == MVT::iPTR ?
- PointerType::get(Type::Int8Ty, 0) :
+ PointerType::get(Type::getInt8Ty(*getContext()), 0) :
VT.getTypeForEVT(*getContext());
return TLI.getTargetData()->getABITypeAlignment(Ty);
@@ -3383,13 +3383,13 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst,
// Emit a library call.
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
- Entry.Ty = TLI.getTargetData()->getIntPtrType();
+ Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext());
Entry.Node = Dst; Args.push_back(Entry);
Entry.Node = Src; Args.push_back(Entry);
Entry.Node = Size; Args.push_back(Entry);
// FIXME: pass in DebugLoc
std::pair CallResult =
- TLI.LowerCallTo(Chain, Type::VoidTy,
+ TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
false, false, false, false, 0, CallingConv::C, false,
/*isReturnValueUsed=*/false,
getExternalSymbol(TLI.getLibcallName(RTLIB::MEMCPY),
@@ -3431,13 +3431,13 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst,
// Emit a library call.
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
- Entry.Ty = TLI.getTargetData()->getIntPtrType();
+ Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext());
Entry.Node = Dst; Args.push_back(Entry);
Entry.Node = Src; Args.push_back(Entry);
Entry.Node = Size; Args.push_back(Entry);
// FIXME: pass in DebugLoc
std::pair CallResult =
- TLI.LowerCallTo(Chain, Type::VoidTy,
+ TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
false, false, false, false, 0, CallingConv::C, false,
/*isReturnValueUsed=*/false,
getExternalSymbol(TLI.getLibcallName(RTLIB::MEMMOVE),
@@ -3475,7 +3475,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst,
return Result;
// Emit a library call.
- const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType();
+ const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext());
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Entry.Node = Dst; Entry.Ty = IntPtrTy;
@@ -3485,13 +3485,17 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst,
Src = getNode(ISD::TRUNCATE, dl, MVT::i32, Src);
else
Src = getNode(ISD::ZERO_EXTEND, dl, MVT::i32, Src);
- Entry.Node = Src; Entry.Ty = Type::Int32Ty; Entry.isSExt = true;
+ Entry.Node = Src;
+ Entry.Ty = Type::getInt32Ty(*getContext());
+ Entry.isSExt = true;
Args.push_back(Entry);
- Entry.Node = Size; Entry.Ty = IntPtrTy; Entry.isSExt = false;
+ Entry.Node = Size;
+ Entry.Ty = IntPtrTy;
+ Entry.isSExt = false;
Args.push_back(Entry);
// FIXME: pass in DebugLoc
std::pair CallResult =
- TLI.LowerCallTo(Chain, Type::VoidTy,
+ TLI.LowerCallTo(Chain, Type::getVoidTy(*getContext()),
false, false, false, false, 0, CallingConv::C, false,
/*isReturnValueUsed=*/false,
getExternalSymbol(TLI.getLibcallName(RTLIB::MEMSET),
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index d9a22d935f3..cf0ddd42438 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -137,7 +137,7 @@ static void ComputeValueVTs(const TargetLowering &TLI, const Type *Ty,
return;
}
// Interpret void as zero return values.
- if (Ty == Type::VoidTy)
+ if (Ty == Type::getVoidTy(Ty->getContext()))
return;
// Base case: we can get an EVT for this LLVM IR type.
ValueVTs.push_back(TLI.getValueType(Ty));
@@ -2934,7 +2934,7 @@ void SelectionDAGLowering::visitTargetIntrinsic(CallInst &I,
else if (!HasChain)
Result = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, getCurDebugLoc(),
VTs, &Ops[0], Ops.size());
- else if (I.getType() != Type::VoidTy)
+ else if (I.getType() != Type::getVoidTy(*DAG.getContext()))
Result = DAG.getNode(ISD::INTRINSIC_W_CHAIN, getCurDebugLoc(),
VTs, &Ops[0], Ops.size());
else
@@ -2948,7 +2948,7 @@ void SelectionDAGLowering::visitTargetIntrinsic(CallInst &I,
else
DAG.setRoot(Chain);
}
- if (I.getType() != Type::VoidTy) {
+ if (I.getType() != Type::getVoidTy(*DAG.getContext())) {
if (const VectorType *PTy = dyn_cast(I.getType())) {
EVT VT = TLI.getValueType(PTy);
Result = DAG.getNode(ISD::BIT_CONVERT, getCurDebugLoc(), VT, Result);
@@ -4836,7 +4836,8 @@ public:
/// getCallOperandValEVT - Return the EVT of the Value* that this operand
/// corresponds to. If there is no Value* for this operand, it returns
/// MVT::Other.
- EVT getCallOperandValEVT(const TargetLowering &TLI,
+ EVT getCallOperandValEVT(LLVMContext &Context,
+ const TargetLowering &TLI,
const TargetData *TD) const {
if (CallOperandVal == 0) return MVT::Other;
@@ -4862,7 +4863,7 @@ public:
case 32:
case 64:
case 128:
- OpTy = IntegerType::get(BitSize);
+ OpTy = IntegerType::get(Context, BitSize);
break;
}
}
@@ -5131,7 +5132,8 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
// The return value of the call is this value. As such, there is no
// corresponding argument.
- assert(CS.getType() != Type::VoidTy && "Bad inline asm!");
+ assert(CS.getType() != Type::getVoidTy(*DAG.getContext()) &&
+ "Bad inline asm!");
if (const StructType *STy = dyn_cast(CS.getType())) {
OpVT = TLI.getValueType(STy->getElementType(ResNo));
} else {
@@ -5160,7 +5162,7 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
OpInfo.CallOperand = getValue(OpInfo.CallOperandVal);
}
- OpVT = OpInfo.getCallOperandValEVT(TLI, TD);
+ OpVT = OpInfo.getCallOperandValEVT(*DAG.getContext(), TLI, TD);
}
OpInfo.ConstraintVT = OpVT;
@@ -5298,7 +5300,8 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
OpInfo.CallOperandVal));
} else {
// This is the result value of the call.
- assert(CS.getType() != Type::VoidTy && "Bad inline asm!");
+ assert(CS.getType() != Type::getVoidTy(*DAG.getContext()) &&
+ "Bad inline asm!");
// Concatenate this output onto the outputs list.
RetValRegs.append(OpInfo.AssignedRegs);
}
@@ -5536,7 +5539,7 @@ void SelectionDAGLowering::visitMalloc(MallocInst &I) {
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Entry.Node = Src;
- Entry.Ty = TLI.getTargetData()->getIntPtrType();
+ Entry.Ty = TLI.getTargetData()->getIntPtrType(*DAG.getContext());
Args.push_back(Entry);
bool isTailCall = PerformTailCallOpt &&
@@ -5557,13 +5560,14 @@ void SelectionDAGLowering::visitFree(FreeInst &I) {
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Entry.Node = getValue(I.getOperand(0));
- Entry.Ty = TLI.getTargetData()->getIntPtrType();
+ Entry.Ty = TLI.getTargetData()->getIntPtrType(*DAG.getContext());
Args.push_back(Entry);
EVT IntPtr = TLI.getPointerTy();
bool isTailCall = PerformTailCallOpt &&
isInTailCallPosition(&I, Attribute::None, TLI);
std::pair Result =
- TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, false, false,
+ TLI.LowerCallTo(getRoot(), Type::getVoidTy(*DAG.getContext()),
+ false, false, false, false,
0, CallingConv::C, isTailCall,
/*isReturnValueUsed=*/true,
DAG.getExternalSymbol("free", IntPtr), Args, DAG,
@@ -5822,7 +5826,7 @@ LowerArguments(BasicBlock *LLVMBB) {
for (unsigned Value = 0, NumValues = ValueVTs.size();
Value != NumValues; ++Value) {
EVT VT = ValueVTs[Value];
- const Type *ArgTy = VT.getTypeForEVT(*CurDAG->getContext());
+ const Type *ArgTy = VT.getTypeForEVT(*DAG.getContext());
ISD::ArgFlagsTy Flags;
unsigned OriginalAlignment =
TD->getABITypeAlignment(ArgTy);
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 3d1327f13e6..87fc751c551 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -750,7 +750,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
BI->dump();
}
- if (BI->getType() != Type::VoidTy) {
+ if (BI->getType() != Type::getVoidTy(*CurDAG->getContext())) {
unsigned &R = FuncInfo->ValueMap[BI];
if (!R)
R = FuncInfo->CreateRegForValue(BI);
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 728dccfd69d..767238e7813 100644
--- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -496,8 +496,7 @@ TargetLowering::TargetLowering(TargetMachine &tm,TargetLoweringObjectFile *tlof)
IsLittleEndian = TD->isLittleEndian();
UsesGlobalOffsetTable = false;
- ShiftAmountTy = PointerTy =
- getValueType(TD->getIntPtrType()).getSimpleVT().SimpleTy;
+ ShiftAmountTy = PointerTy = MVT::getIntegerVT(8*TD->getPointerSize());
memset(RegClassForVT, 0,MVT::LAST_VALUETYPE*sizeof(TargetRegisterClass*));
memset(TargetDAGCombineArray, 0, array_lengthof(TargetDAGCombineArray));
maxStoresPerMemset = maxStoresPerMemcpy = maxStoresPerMemmove = 8;
@@ -704,7 +703,7 @@ const char *TargetLowering::getTargetNodeName(unsigned Opcode) const {
MVT::SimpleValueType TargetLowering::getSetCCResultType(EVT VT) const {
- return getValueType(TD->getIntPtrType()).getSimpleVT().SimpleTy;
+ return PointerTy.SimpleTy;
}
/// getVectorTypeBreakdown - Vector types are broken down into some number of
diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp
index 514629bff73..5b4cc7fe269 100644
--- a/lib/CodeGen/ShadowStackGC.cpp
+++ b/lib/CodeGen/ShadowStackGC.cpp
@@ -138,8 +138,9 @@ namespace {
return 0;
// Create a cleanup block.
- BasicBlock *CleanupBB = BasicBlock::Create(CleanupBBName, &F);
- UnwindInst *UI = new UnwindInst(CleanupBB);
+ BasicBlock *CleanupBB = BasicBlock::Create(F.getContext(),
+ CleanupBBName, &F);
+ UnwindInst *UI = new UnwindInst(F.getContext(), CleanupBB);
// Transform the 'call' instructions into 'invoke's branching to the
// cleanup block. Go in reverse order to make prettier BB names.
@@ -188,7 +189,7 @@ ShadowStackGC::ShadowStackGC() : Head(0), StackEntryTy(0) {
Constant *ShadowStackGC::GetFrameMap(Function &F) {
// doInitialization creates the abstract type of this value.
- Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
+ Type *VoidPtr = PointerType::getUnqual(Type::getInt8Ty(F.getContext()));
// Truncate the ShadowStackDescriptor if some metadata is null.
unsigned NumMeta = 0;
@@ -201,8 +202,8 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
}
Constant *BaseElts[] = {
- ConstantInt::get(Type::Int32Ty, Roots.size(), false),
- ConstantInt::get(Type::Int32Ty, NumMeta, false),
+ ConstantInt::get(Type::getInt32Ty(F.getContext()), Roots.size(), false),
+ ConstantInt::get(Type::getInt32Ty(F.getContext()), NumMeta, false),
};
Constant *DescriptorElts[] = {
@@ -234,8 +235,10 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
GlobalVariable::InternalLinkage,
FrameMap, "__gc_" + F.getName());
- Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0),
- ConstantInt::get(Type::Int32Ty, 0) };
+ Constant *GEPIndices[2] = {
+ ConstantInt::get(Type::getInt32Ty(F.getContext()), 0),
+ ConstantInt::get(Type::getInt32Ty(F.getContext()), 0)
+ };
return ConstantExpr::getGetElementPtr(GV, GEPIndices, 2);
}
@@ -263,8 +266,10 @@ bool ShadowStackGC::initializeCustomLowering(Module &M) {
// void *Meta[]; // May be absent for roots without metadata.
// };
std::vector EltTys;
- EltTys.push_back(Type::Int32Ty); // 32 bits is ok up to a 32GB stack frame. :)
- EltTys.push_back(Type::Int32Ty); // Specifies length of variable length array.
+ // 32 bits is ok up to a 32GB stack frame. :)
+ EltTys.push_back(Type::getInt32Ty(M.getContext()));
+ // Specifies length of variable length array.
+ EltTys.push_back(Type::getInt32Ty(M.getContext()));
StructType *FrameMapTy = StructType::get(M.getContext(), EltTys);
M.addTypeName("gc_map", FrameMapTy);
PointerType *FrameMapPtrTy = PointerType::getUnqual(FrameMapTy);
@@ -340,9 +345,9 @@ void ShadowStackGC::CollectRoots(Function &F) {
GetElementPtrInst *
ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
int Idx, int Idx2, const char *Name) {
- Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
- ConstantInt::get(Type::Int32Ty, Idx),
- ConstantInt::get(Type::Int32Ty, Idx2) };
+ Value *Indices[] = { ConstantInt::get(Type::getInt32Ty(Context), 0),
+ ConstantInt::get(Type::getInt32Ty(Context), Idx),
+ ConstantInt::get(Type::getInt32Ty(Context), Idx2) };
Value* Val = B.CreateGEP(BasePtr, Indices, Indices + 3, Name);
assert(isa(Val) && "Unexpected folded constant");
@@ -353,8 +358,8 @@ ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
GetElementPtrInst *
ShadowStackGC::CreateGEP(LLVMContext &Context, IRBuilder<> &B, Value *BasePtr,
int Idx, const char *Name) {
- Value *Indices[] = { ConstantInt::get(Type::Int32Ty, 0),
- ConstantInt::get(Type::Int32Ty, Idx) };
+ Value *Indices[] = { ConstantInt::get(Type::getInt32Ty(Context), 0),
+ ConstantInt::get(Type::getInt32Ty(Context), Idx) };
Value *Val = B.CreateGEP(BasePtr, Indices, Indices + 2, Name);
assert(isa(Val) && "Unexpected folded constant");
diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp
index 9043b89e354..350bc6e1ade 100644
--- a/lib/CodeGen/StackProtector.cpp
+++ b/lib/CodeGen/StackProtector.cpp
@@ -148,7 +148,8 @@ bool StackProtector::InsertStackProtectors() {
// StackGuard = load __stack_chk_guard
// call void @llvm.stackprotect.create(StackGuard, StackGuardSlot)
//
- PointerType *PtrTy = PointerType::getUnqual(Type::Int8Ty);
+ PointerType *PtrTy = PointerType::getUnqual(
+ Type::getInt8Ty(RI->getContext()));
StackGuardVar = M->getOrInsertGlobal("__stack_chk_guard", PtrTy);
BasicBlock &Entry = F->getEntryBlock();
@@ -215,10 +216,12 @@ bool StackProtector::InsertStackProtectors() {
/// CreateFailBB - Create a basic block to jump to when the stack protector
/// check fails.
BasicBlock *StackProtector::CreateFailBB() {
- BasicBlock *FailBB = BasicBlock::Create("CallStackCheckFailBlk", F);
+ BasicBlock *FailBB = BasicBlock::Create(F->getContext(),
+ "CallStackCheckFailBlk", F);
Constant *StackChkFail =
- M->getOrInsertFunction("__stack_chk_fail", Type::VoidTy, NULL);
+ M->getOrInsertFunction("__stack_chk_fail",
+ Type::getVoidTy(F->getContext()), NULL);
CallInst::Create(StackChkFail, "", FailBB);
- new UnreachableInst(FailBB);
+ new UnreachableInst(F->getContext(), FailBB);
return FailBB;
}
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 348190a75ba..a20122d9f9c 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -238,13 +238,13 @@ const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {
// CreateArgv - Turn a vector of strings into a nice argv style array of
// pointers to null terminated strings.
//
-static void *CreateArgv(ExecutionEngine *EE,
+static void *CreateArgv(LLVMContext &C, ExecutionEngine *EE,
const std::vector &InputArgv) {
unsigned PtrSize = EE->getTargetData()->getPointerSize();
char *Result = new char[(InputArgv.size()+1)*PtrSize];
DOUT << "JIT: ARGV = " << (void*)Result << "\n";
- const Type *SBytePtr = PointerType::getUnqual(Type::Int8Ty);
+ const Type *SBytePtr = PointerType::getUnqual(Type::getInt8Ty(C));
for (unsigned i = 0; i != InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1;
@@ -340,7 +340,8 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
const FunctionType *FTy = Fn->getFunctionType();
const Type* PPInt8Ty =
- PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
+ PointerType::getUnqual(PointerType::getUnqual(
+ Type::getInt8Ty(Fn->getContext())));
switch (NumArgs) {
case 3:
if (FTy->getParamType(2) != PPInt8Ty) {
@@ -353,13 +354,13 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
}
// FALLS THROUGH
case 1:
- if (FTy->getParamType(0) != Type::Int32Ty) {
+ if (FTy->getParamType(0) != Type::getInt32Ty(Fn->getContext())) {
llvm_report_error("Invalid type for first argument of main() supplied");
}
// FALLS THROUGH
case 0:
if (!isa(FTy->getReturnType()) &&
- FTy->getReturnType() != Type::VoidTy) {
+ FTy->getReturnType() != Type::getVoidTy(FTy->getContext())) {
llvm_report_error("Invalid return type of main() supplied");
}
break;
@@ -370,14 +371,16 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
if (NumArgs) {
GVArgs.push_back(GVArgc); // Arg #0 = argc.
if (NumArgs > 1) {
- GVArgs.push_back(PTOGV(CreateArgv(this, argv))); // Arg #1 = argv.
+ // Arg #1 = argv.
+ GVArgs.push_back(PTOGV(CreateArgv(Fn->getContext(), this, argv)));
assert(!isTargetNullPtr(this, GVTOP(GVArgs[1])) &&
"argv[0] was null after CreateArgv");
if (NumArgs > 2) {
std::vector EnvVars;
for (unsigned i = 0; envp[i]; ++i)
EnvVars.push_back(envp[i]);
- GVArgs.push_back(PTOGV(CreateArgv(this, EnvVars))); // Arg #2 = envp.
+ // Arg #2 = envp.
+ GVArgs.push_back(PTOGV(CreateArgv(Fn->getContext(), this, EnvVars)));
}
}
}
@@ -525,11 +528,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
}
case Instruction::UIToFP: {
GenericValue GV = getConstantValue(Op0);
- if (CE->getType() == Type::FloatTy)
+ if (CE->getType() == Type::getFloatTy(CE->getContext()))
GV.FloatVal = float(GV.IntVal.roundToDouble());
- else if (CE->getType() == Type::DoubleTy)
+ else if (CE->getType() == Type::getDoubleTy(CE->getContext()))
GV.DoubleVal = GV.IntVal.roundToDouble();
- else if (CE->getType() == Type::X86_FP80Ty) {
+ else if (CE->getType() == Type::getX86_FP80Ty(Op0->getContext())) {
const uint64_t zero[] = {0, 0};
APFloat apf = APFloat(APInt(80, 2, zero));
(void)apf.convertFromAPInt(GV.IntVal,
@@ -541,11 +544,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
}
case Instruction::SIToFP: {
GenericValue GV = getConstantValue(Op0);
- if (CE->getType() == Type::FloatTy)
+ if (CE->getType() == Type::getFloatTy(CE->getContext()))
GV.FloatVal = float(GV.IntVal.signedRoundToDouble());
- else if (CE->getType() == Type::DoubleTy)
+ else if (CE->getType() == Type::getDoubleTy(CE->getContext()))
GV.DoubleVal = GV.IntVal.signedRoundToDouble();
- else if (CE->getType() == Type::X86_FP80Ty) {
+ else if (CE->getType() == Type::getX86_FP80Ty(CE->getContext())) {
const uint64_t zero[] = { 0, 0};
APFloat apf = APFloat(APInt(80, 2, zero));
(void)apf.convertFromAPInt(GV.IntVal,
@@ -559,11 +562,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
case Instruction::FPToSI: {
GenericValue GV = getConstantValue(Op0);
uint32_t BitWidth = cast(CE->getType())->getBitWidth();
- if (Op0->getType() == Type::FloatTy)
+ if (Op0->getType() == Type::getFloatTy(Op0->getContext()))
GV.IntVal = APIntOps::RoundFloatToAPInt(GV.FloatVal, BitWidth);
- else if (Op0->getType() == Type::DoubleTy)
+ else if (Op0->getType() == Type::getDoubleTy(Op0->getContext()))
GV.IntVal = APIntOps::RoundDoubleToAPInt(GV.DoubleVal, BitWidth);
- else if (Op0->getType() == Type::X86_FP80Ty) {
+ else if (Op0->getType() == Type::getX86_FP80Ty(Op0->getContext())) {
APFloat apf = APFloat(GV.IntVal);
uint64_t v;
bool ignored;
@@ -596,17 +599,19 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
default: llvm_unreachable("Invalid bitcast operand");
case Type::IntegerTyID:
assert(DestTy->isFloatingPoint() && "invalid bitcast");
- if (DestTy == Type::FloatTy)
+ if (DestTy == Type::getFloatTy(Op0->getContext()))
GV.FloatVal = GV.IntVal.bitsToFloat();
- else if (DestTy == Type::DoubleTy)
+ else if (DestTy == Type::getDoubleTy(DestTy->getContext()))
GV.DoubleVal = GV.IntVal.bitsToDouble();
break;
case Type::FloatTyID:
- assert(DestTy == Type::Int32Ty && "Invalid bitcast");
+ assert(DestTy == Type::getInt32Ty(DestTy->getContext()) &&
+ "Invalid bitcast");
GV.IntVal.floatToBits(GV.FloatVal);
break;
case Type::DoubleTyID:
- assert(DestTy == Type::Int64Ty && "Invalid bitcast");
+ assert(DestTy == Type::getInt64Ty(DestTy->getContext()) &&
+ "Invalid bitcast");
GV.IntVal.doubleToBits(GV.DoubleVal);
break;
case Type::PointerTyID:
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 8d21d1f40b5..45180c91f07 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -366,7 +366,7 @@ static GenericValue executeFCMP_OGT(GenericValue Src1, GenericValue Src2,
}
#define IMPLEMENT_UNORDERED(TY, X,Y) \
- if (TY == Type::FloatTy) { \
+ if (TY == Type::getFloatTy(Ty->getContext())) { \
if (X.FloatVal != X.FloatVal || Y.FloatVal != Y.FloatVal) { \
Dest.IntVal = APInt(1,true); \
return Dest; \
@@ -422,7 +422,7 @@ static GenericValue executeFCMP_UGT(GenericValue Src1, GenericValue Src2,
static GenericValue executeFCMP_ORD(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- if (Ty == Type::FloatTy)
+ if (Ty == Type::getFloatTy(Ty->getContext()))
Dest.IntVal = APInt(1,(Src1.FloatVal == Src1.FloatVal &&
Src2.FloatVal == Src2.FloatVal));
else
@@ -434,7 +434,7 @@ static GenericValue executeFCMP_ORD(GenericValue Src1, GenericValue Src2,
static GenericValue executeFCMP_UNO(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- if (Ty == Type::FloatTy)
+ if (Ty == Type::getFloatTy(Ty->getContext()))
Dest.IntVal = APInt(1,(Src1.FloatVal != Src1.FloatVal ||
Src2.FloatVal != Src2.FloatVal));
else
@@ -602,7 +602,8 @@ void Interpreter::popStackAndReturnValueToCaller (const Type *RetTy,
// fill in the return value...
ExecutionContext &CallingSF = ECStack.back();
if (Instruction *I = CallingSF.Caller.getInstruction()) {
- if (CallingSF.Caller.getType() != Type::VoidTy) // Save result...
+ // Save result...
+ if (CallingSF.Caller.getType() != Type::getVoidTy(RetTy->getContext()))
SetValue(I, Result, CallingSF);
if (InvokeInst *II = dyn_cast (I))
SwitchToNewBasicBlock (II->getNormalDest (), CallingSF);
@@ -613,7 +614,7 @@ void Interpreter::popStackAndReturnValueToCaller (const Type *RetTy,
void Interpreter::visitReturnInst(ReturnInst &I) {
ExecutionContext &SF = ECStack.back();
- const Type *RetTy = Type::VoidTy;
+ const Type *RetTy = Type::getVoidTy(I.getContext());
GenericValue Result;
// Save away the return value... (if we are not 'ret void')
@@ -970,7 +971,8 @@ GenericValue Interpreter::executeZExtInst(Value *SrcVal, const Type *DstTy,
GenericValue Interpreter::executeFPTruncInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- assert(SrcVal->getType() == Type::DoubleTy && DstTy == Type::FloatTy &&
+ assert(SrcVal->getType() == Type::getDoubleTy(SrcVal->getContext()) &&
+ DstTy == Type::getFloatTy(SrcVal->getContext()) &&
"Invalid FPTrunc instruction");
Dest.FloatVal = (float) Src.DoubleVal;
return Dest;
@@ -979,7 +981,8 @@ GenericValue Interpreter::executeFPTruncInst(Value *SrcVal, const Type *DstTy,
GenericValue Interpreter::executeFPExtInst(Value *SrcVal, const Type *DstTy,
ExecutionContext &SF) {
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- assert(SrcVal->getType() == Type::FloatTy && DstTy == Type::DoubleTy &&
+ assert(SrcVal->getType() == Type::getFloatTy(SrcVal->getContext()) &&
+ DstTy == Type::getDoubleTy(SrcVal->getContext()) &&
"Invalid FPTrunc instruction");
Dest.DoubleVal = (double) Src.FloatVal;
return Dest;
@@ -1070,22 +1073,22 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, const Type *DstTy,
assert(isa(SrcTy) && "Invalid BitCast");
Dest.PointerVal = Src.PointerVal;
} else if (DstTy->isInteger()) {
- if (SrcTy == Type::FloatTy) {
+ if (SrcTy == Type::getFloatTy(SrcVal->getContext())) {
Dest.IntVal.zext(sizeof(Src.FloatVal) * CHAR_BIT);
Dest.IntVal.floatToBits(Src.FloatVal);
- } else if (SrcTy == Type::DoubleTy) {
+ } else if (SrcTy == Type::getDoubleTy(SrcVal->getContext())) {
Dest.IntVal.zext(sizeof(Src.DoubleVal) * CHAR_BIT);
Dest.IntVal.doubleToBits(Src.DoubleVal);
} else if (SrcTy->isInteger()) {
Dest.IntVal = Src.IntVal;
} else
llvm_unreachable("Invalid BitCast");
- } else if (DstTy == Type::FloatTy) {
+ } else if (DstTy == Type::getFloatTy(SrcVal->getContext())) {
if (SrcTy->isInteger())
Dest.FloatVal = Src.IntVal.bitsToFloat();
else
Dest.FloatVal = Src.FloatVal;
- } else if (DstTy == Type::DoubleTy) {
+ } else if (DstTy == Type::getDoubleTy(SrcVal->getContext())) {
if (SrcTy->isInteger())
Dest.DoubleVal = Src.IntVal.bitsToDouble();
else
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 37f6ef07f6d..92fd817cde0 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -418,7 +418,8 @@ GenericValue lle_X_printf(const FunctionType *FT,
return GV;
}
-static void ByteswapSCANFResults(const char *Fmt, void *Arg0, void *Arg1,
+static void ByteswapSCANFResults(LLVMContext &C,
+ const char *Fmt, void *Arg0, void *Arg1,
void *Arg2, void *Arg3, void *Arg4, void *Arg5,
void *Arg6, void *Arg7, void *Arg8) {
void *Args[] = { Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, 0 };
@@ -458,26 +459,26 @@ static void ByteswapSCANFResults(const char *Fmt, void *Arg0, void *Arg1,
case 'i': case 'o': case 'u': case 'x': case 'X': case 'n': case 'p':
case 'd':
if (Long || LongLong) {
- Size = 8; Ty = Type::Int64Ty;
+ Size = 8; Ty = Type::getInt64Ty(C);
} else if (Half) {
- Size = 4; Ty = Type::Int16Ty;
+ Size = 4; Ty = Type::getInt16Ty(C);
} else {
- Size = 4; Ty = Type::Int32Ty;
+ Size = 4; Ty = Type::getInt32Ty(C);
}
break;
case 'e': case 'g': case 'E':
case 'f':
if (Long || LongLong) {
- Size = 8; Ty = Type::DoubleTy;
+ Size = 8; Ty = Type::getDoubleTy(C);
} else {
- Size = 4; Ty = Type::FloatTy;
+ Size = 4; Ty = Type::getFloatTy(C);
}
break;
case 's': case 'c': case '[': // No byteswap needed
Size = 1;
- Ty = Type::Int8Ty;
+ Ty = Type::getInt8Ty(C);
break;
default: break;
@@ -506,7 +507,8 @@ GenericValue lle_X_sscanf(const FunctionType *FT,
GenericValue GV;
GV.IntVal = APInt(32, sscanf(Args[0], Args[1], Args[2], Args[3], Args[4],
Args[5], Args[6], Args[7], Args[8], Args[9]));
- ByteswapSCANFResults(Args[1], Args[2], Args[3], Args[4],
+ ByteswapSCANFResults(FT->getContext(),
+ Args[1], Args[2], Args[3], Args[4],
Args[5], Args[6], Args[7], Args[8], Args[9], 0);
return GV;
}
@@ -523,7 +525,8 @@ GenericValue lle_X_scanf(const FunctionType *FT,
GenericValue GV;
GV.IntVal = APInt(32, scanf( Args[0], Args[1], Args[2], Args[3], Args[4],
Args[5], Args[6], Args[7], Args[8], Args[9]));
- ByteswapSCANFResults(Args[0], Args[1], Args[2], Args[3], Args[4],
+ ByteswapSCANFResults(FT->getContext(),
+ Args[0], Args[1], Args[2], Args[3], Args[4],
Args[5], Args[6], Args[7], Args[8], Args[9]);
return GV;
}
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index b932c8cef19..37433504333 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -382,10 +382,11 @@ GenericValue JIT::runFunction(Function *F,
// Handle some common cases first. These cases correspond to common `main'
// prototypes.
- if (RetTy == Type::Int32Ty || RetTy == Type::VoidTy) {
+ if (RetTy == Type::getInt32Ty(F->getContext()) ||
+ RetTy == Type::getVoidTy(F->getContext())) {
switch (ArgValues.size()) {
case 3:
- if (FTy->getParamType(0) == Type::Int32Ty &&
+ if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) &&
isa(FTy->getParamType(1)) &&
isa(FTy->getParamType(2))) {
int (*PF)(int, char **, const char **) =
@@ -400,7 +401,7 @@ GenericValue JIT::runFunction(Function *F,
}
break;
case 2:
- if (FTy->getParamType(0) == Type::Int32Ty &&
+ if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) &&
isa(FTy->getParamType(1))) {
int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr;
@@ -413,7 +414,7 @@ GenericValue JIT::runFunction(Function *F,
break;
case 1:
if (FTy->getNumParams() == 1 &&
- FTy->getParamType(0) == Type::Int32Ty) {
+ FTy->getParamType(0) == Type::getInt32Ty(F->getContext())) {
GenericValue rv;
int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
@@ -474,7 +475,7 @@ GenericValue JIT::runFunction(Function *F,
F->getParent());
// Insert a basic block.
- BasicBlock *StubBB = BasicBlock::Create("", Stub);
+ BasicBlock *StubBB = BasicBlock::Create(F->getContext(), "", Stub);
// Convert all of the GenericValue arguments over to constants. Note that we
// currently don't support varargs.
@@ -502,9 +503,11 @@ GenericValue JIT::runFunction(Function *F,
case Type::PointerTyID:
void *ArgPtr = GVTOP(AV);
if (sizeof(void*) == 4)
- C = ConstantInt::get(Type::Int32Ty, (int)(intptr_t)ArgPtr);
+ C = ConstantInt::get(Type::getInt32Ty(F->getContext()),
+ (int)(intptr_t)ArgPtr);
else
- C = ConstantInt::get(Type::Int64Ty, (intptr_t)ArgPtr);
+ C = ConstantInt::get(Type::getInt64Ty(F->getContext()),
+ (intptr_t)ArgPtr);
// Cast the integer to pointer
C = ConstantExpr::getIntToPtr(C, ArgTy);
break;
@@ -516,10 +519,11 @@ GenericValue JIT::runFunction(Function *F,
"", StubBB);
TheCall->setCallingConv(F->getCallingConv());
TheCall->setTailCall();
- if (TheCall->getType() != Type::VoidTy)
- ReturnInst::Create(TheCall, StubBB); // Return result of the call.
+ if (TheCall->getType() != Type::getVoidTy(F->getContext()))
+ // Return result of the call.
+ ReturnInst::Create(F->getContext(), TheCall, StubBB);
else
- ReturnInst::Create(StubBB); // Just return void.
+ ReturnInst::Create(F->getContext(), StubBB); // Just return void.
// Finally, return the value returned by our nullary stub function.
return runFunction(Stub, std::vector());
diff --git a/lib/Target/ARM/ARMBaseRegisterInfo.cpp b/lib/Target/ARM/ARMBaseRegisterInfo.cpp
index 98a08e12d68..309a5c6eb5d 100644
--- a/lib/Target/ARM/ARMBaseRegisterInfo.cpp
+++ b/lib/Target/ARM/ARMBaseRegisterInfo.cpp
@@ -903,7 +903,8 @@ emitLoadConstPool(MachineBasicBlock &MBB,
unsigned PredReg) const {
MachineFunction &MF = *MBB.getParent();
MachineConstantPool *ConstantPool = MF.getConstantPool();
- Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+ Constant *C =
+ ConstantInt::get(Type::getInt32Ty(MF.getFunction()->getContext()), Val);
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp))
diff --git a/lib/Target/ARM/ARMCodeEmitter.cpp b/lib/Target/ARM/ARMCodeEmitter.cpp
index d5f9cd1314f..6218fceac1c 100644
--- a/lib/Target/ARM/ARMCodeEmitter.cpp
+++ b/lib/Target/ARM/ARMCodeEmitter.cpp
@@ -456,9 +456,9 @@ void Emitter::emitConstPoolInstruction(const MachineInstr &MI) {
uint32_t Val = *(uint32_t*)CI->getValue().getRawData();
emitWordLE(Val);
} else if (const ConstantFP *CFP = dyn_cast(CV)) {
- if (CFP->getType() == Type::FloatTy)
+ if (CFP->getType() == Type::getFloatTy(CFP->getContext()))
emitWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
- else if (CFP->getType() == Type::DoubleTy)
+ else if (CFP->getType() == Type::getDoubleTy(CFP->getContext()))
emitDWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
else {
llvm_unreachable("Unable to handle this constantpool entry!");
diff --git a/lib/Target/ARM/ARMConstantPoolValue.cpp b/lib/Target/ARM/ARMConstantPoolValue.cpp
index 8e85d3dec6a..9697422c6dc 100644
--- a/lib/Target/ARM/ARMConstantPoolValue.cpp
+++ b/lib/Target/ARM/ARMConstantPoolValue.cpp
@@ -29,19 +29,20 @@ ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
GV(gv), S(NULL), LabelId(id), Kind(k), PCAdjust(PCAdj),
Modifier(Modif), AddCurrentAddress(AddCA) {}
-ARMConstantPoolValue::ARMConstantPoolValue(const char *s, unsigned id,
+ARMConstantPoolValue::ARMConstantPoolValue(LLVMContext &C,
+ const char *s, unsigned id,
ARMCP::ARMCPKind k,
unsigned char PCAdj,
const char *Modif,
bool AddCA)
- : MachineConstantPoolValue((const Type*)Type::Int32Ty),
+ : MachineConstantPoolValue((const Type*)Type::getInt32Ty(C)),
GV(NULL), S(strdup(s)), LabelId(id), Kind(k), PCAdjust(PCAdj),
Modifier(Modif), AddCurrentAddress(AddCA) {}
ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv,
ARMCP::ARMCPKind k,
const char *Modif)
- : MachineConstantPoolValue((const Type*)Type::Int32Ty),
+ : MachineConstantPoolValue((const Type*)Type::getInt32Ty(gv->getContext())),
GV(gv), S(NULL), LabelId(0), Kind(k), PCAdjust(0),
Modifier(Modif) {}
diff --git a/lib/Target/ARM/ARMConstantPoolValue.h b/lib/Target/ARM/ARMConstantPoolValue.h
index 77516e58e0d..13683a30078 100644
--- a/lib/Target/ARM/ARMConstantPoolValue.h
+++ b/lib/Target/ARM/ARMConstantPoolValue.h
@@ -20,6 +20,7 @@
namespace llvm {
class GlobalValue;
+class LLVMContext;
namespace ARMCP {
enum ARMCPKind {
@@ -47,7 +48,7 @@ public:
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
unsigned char PCAdj = 0, const char *Modifier = NULL,
bool AddCurrentAddress = false);
- ARMConstantPoolValue(const char *s, unsigned id,
+ ARMConstantPoolValue(LLVMContext &C, const char *s, unsigned id,
ARMCP::ARMCPKind Kind = ARMCP::CPValue,
unsigned char PCAdj = 0, const char *Modifier = NULL,
bool AddCurrentAddress = false);
diff --git a/lib/Target/ARM/ARMISelDAGToDAG.cpp b/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 608488397e4..9ca80ae1b91 100644
--- a/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -952,7 +952,8 @@ SDNode *ARMDAGToDAGISel::Select(SDValue Op) {
!ARM_AM::isSOImmTwoPartVal(Val)); // two instrs.
if (UseCP) {
SDValue CPIdx =
- CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
+ CurDAG->getTargetConstantPool(ConstantInt::get(
+ Type::getInt32Ty(*CurDAG->getContext()), Val),
TLI.getPointerTy());
SDNode *ResNode;
diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp
index 14cab0986b9..a36fdbf2474 100644
--- a/lib/Target/ARM/ARMISelLowering.cpp
+++ b/lib/Target/ARM/ARMISelLowering.cpp
@@ -985,7 +985,8 @@ ARMTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
// tBX takes a register source operand.
const char *Sym = S->getSymbol();
if (isARMFunc && Subtarget->isThumb1Only() && !Subtarget->hasV5TOps()) {
- ARMConstantPoolValue *CPV = new ARMConstantPoolValue(Sym, ARMPCLabelIndex,
+ ARMConstantPoolValue *CPV = new ARMConstantPoolValue(*DAG.getContext(),
+ Sym, ARMPCLabelIndex,
ARMCP::CPStub, 4);
SDValue CPAddr = DAG.getTargetConstantPool(CPV, getPointerTy(), 4);
CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
@@ -1177,11 +1178,11 @@ ARMTargetLowering::LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
ArgListTy Args;
ArgListEntry Entry;
Entry.Node = Argument;
- Entry.Ty = (const Type *) Type::Int32Ty;
+ Entry.Ty = (const Type *) Type::getInt32Ty(*DAG.getContext());
Args.push_back(Entry);
// FIXME: is there useful debug info available here?
std::pair CallResult =
- LowerCallTo(Chain, (const Type *) Type::Int32Ty, false, false, false, false,
+ LowerCallTo(Chain, (const Type *) Type::getInt32Ty(*DAG.getContext()), false, false, false, false,
0, CallingConv::C, false, /*isReturnValueUsed=*/true,
DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG, dl);
return CallResult.first;
@@ -1322,7 +1323,8 @@ SDValue ARMTargetLowering::LowerGLOBAL_OFFSET_TABLE(SDValue Op,
EVT PtrVT = getPointerTy();
DebugLoc dl = Op.getDebugLoc();
unsigned PCAdj = Subtarget->isThumb() ? 4 : 8;
- ARMConstantPoolValue *CPV = new ARMConstantPoolValue("_GLOBAL_OFFSET_TABLE_",
+ ARMConstantPoolValue *CPV = new ARMConstantPoolValue(*DAG.getContext(),
+ "_GLOBAL_OFFSET_TABLE_",
ARMPCLabelIndex,
ARMCP::CPValue, PCAdj);
SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
@@ -1411,7 +1413,8 @@ ARMTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) {
std::string LSDAName = "L_lsda_";
LSDAName += MF.getFunction()->getName();
ARMConstantPoolValue *CPV =
- new ARMConstantPoolValue(LSDAName.c_str(), ARMPCLabelIndex, Kind, PCAdj);
+ new ARMConstantPoolValue(*DAG.getContext(), LSDAName.c_str(),
+ ARMPCLabelIndex, Kind, PCAdj);
CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, 4);
CPAddr = DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
SDValue Result =
diff --git a/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
index 11d4887e259..3c6778fe8cd 100644
--- a/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ b/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -19,6 +19,7 @@
#include "ARMMachineFunctionInfo.h"
#include "ARMRegisterInfo.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
@@ -1183,7 +1184,9 @@ ARMPreAllocLoadStoreOpt::CanFormLdStDWord(MachineInstr *Op0, MachineInstr *Op1,
unsigned Align = Op0->memoperands_begin()->getAlignment();
unsigned ReqAlign = STI->hasV6Ops()
- ? TD->getPrefTypeAlignment(Type::Int64Ty) : 8; // Pre-v6 need 8-byte align
+ ? TD->getPrefTypeAlignment(
+ Type::getInt64Ty(Op0->getParent()->getParent()->getFunction()->getContext()))
+ : 8; // Pre-v6 need 8-byte align
if (Align < ReqAlign)
return false;
diff --git a/lib/Target/ARM/Thumb1RegisterInfo.cpp b/lib/Target/ARM/Thumb1RegisterInfo.cpp
index b11d4c35ac0..796057f9c53 100644
--- a/lib/Target/ARM/Thumb1RegisterInfo.cpp
+++ b/lib/Target/ARM/Thumb1RegisterInfo.cpp
@@ -58,7 +58,8 @@ void Thumb1RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB,
unsigned PredReg) const {
MachineFunction &MF = *MBB.getParent();
MachineConstantPool *ConstantPool = MF.getConstantPool();
- Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+ Constant *C = ConstantInt::get(
+ Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Val);
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
BuildMI(MBB, MBBI, dl, TII.get(ARM::tLDRcp))
diff --git a/lib/Target/ARM/Thumb2RegisterInfo.cpp b/lib/Target/ARM/Thumb2RegisterInfo.cpp
index 98be2041fd3..6c4c15dfe35 100644
--- a/lib/Target/ARM/Thumb2RegisterInfo.cpp
+++ b/lib/Target/ARM/Thumb2RegisterInfo.cpp
@@ -52,7 +52,8 @@ void Thumb2RegisterInfo::emitLoadConstPool(MachineBasicBlock &MBB,
unsigned PredReg) const {
MachineFunction &MF = *MBB.getParent();
MachineConstantPool *ConstantPool = MF.getConstantPool();
- Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+ Constant *C = ConstantInt::get(
+ Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Val);
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
BuildMI(MBB, MBBI, dl, TII.get(ARM::t2LDRpci))
diff --git a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
index c72e0f04815..ff1eefb8ce2 100644
--- a/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
+++ b/lib/Target/Alpha/AlphaISelDAGToDAG.cpp
@@ -305,7 +305,8 @@ SDNode *AlphaDAGToDAGISel::Select(SDValue Op) {
// val32 >= IMM_LOW + IMM_LOW * IMM_MULT) //always true
break; //(zext (LDAH (LDA)))
//Else use the constant pool
- ConstantInt *C = ConstantInt::get(Type::Int64Ty, uval);
+ ConstantInt *C = ConstantInt::get(
+ Type::getInt64Ty(*CurDAG->getContext()), uval);
SDValue CPI = CurDAG->getTargetConstantPool(C, MVT::i64);
SDNode *Tmp = CurDAG->getTargetNode(Alpha::LDAHr, dl, MVT::i64, CPI,
SDValue(getGlobalBaseReg(), 0));
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 937a93f18a1..f4418040e18 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -236,7 +236,7 @@ namespace {
// Must be an expression, must be used exactly once. If it is dead, we
// emit it inline where it would go.
- if (I.getType() == Type::VoidTy || !I.hasOneUse() ||
+ if (I.getType() == Type::getVoidTy(I.getContext()) || !I.hasOneUse() ||
isa(I) || isa(I) || isa(I) ||
isa(I) || isa(I) || isa(I) ||
isa(I))
@@ -772,7 +772,8 @@ void CWriter::printConstantArray(ConstantArray *CPA, bool Static) {
// ubytes or an array of sbytes with positive values.
//
const Type *ETy = CPA->getType()->getElementType();
- bool isString = (ETy == Type::Int8Ty || ETy == Type::Int8Ty);
+ bool isString = (ETy == Type::getInt8Ty(CPA->getContext()) ||
+ ETy == Type::getInt8Ty(CPA->getContext()));
// Make sure the last character is a null char, as automatically added by C
if (isString && (CPA->getNumOperands() == 0 ||
@@ -858,10 +859,11 @@ void CWriter::printConstantVector(ConstantVector *CP, bool Static) {
static bool isFPCSafeToPrint(const ConstantFP *CFP) {
bool ignored;
// Do long doubles in hex for now.
- if (CFP->getType() != Type::FloatTy && CFP->getType() != Type::DoubleTy)
+ if (CFP->getType() != Type::getFloatTy(CFP->getContext()) &&
+ CFP->getType() != Type::getDoubleTy(CFP->getContext()))
return false;
APFloat APF = APFloat(CFP->getValueAPF()); // copy
- if (CFP->getType() == Type::FloatTy)
+ if (CFP->getType() == Type::getFloatTy(CFP->getContext()))
APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &ignored);
#if HAVE_PRINTF_A && ENABLE_CBE_PRINTF_A
char Buffer[100];
@@ -973,12 +975,12 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
Out << "(";
printCast(CE->getOpcode(), CE->getOperand(0)->getType(), CE->getType());
if (CE->getOpcode() == Instruction::SExt &&
- CE->getOperand(0)->getType() == Type::Int1Ty) {
+ CE->getOperand(0)->getType() == Type::getInt1Ty(CPV->getContext())) {
// Make sure we really sext from bool here by subtracting from 0
Out << "0-";
}
printConstant(CE->getOperand(0), Static);
- if (CE->getType() == Type::Int1Ty &&
+ if (CE->getType() == Type::getInt1Ty(CPV->getContext()) &&
(CE->getOpcode() == Instruction::Trunc ||
CE->getOpcode() == Instruction::FPToUI ||
CE->getOpcode() == Instruction::FPToSI ||
@@ -1127,9 +1129,9 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
if (ConstantInt *CI = dyn_cast(CPV)) {
const Type* Ty = CI->getType();
- if (Ty == Type::Int1Ty)
+ if (Ty == Type::getInt1Ty(CPV->getContext()))
Out << (CI->getZExtValue() ? '1' : '0');
- else if (Ty == Type::Int32Ty)
+ else if (Ty == Type::getInt32Ty(CPV->getContext()))
Out << CI->getZExtValue() << 'u';
else if (Ty->getPrimitiveSizeInBits() > 32)
Out << CI->getZExtValue() << "ull";
@@ -1156,15 +1158,17 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
if (I != FPConstantMap.end()) {
// Because of FP precision problems we must load from a stack allocated
// value that holds the value in hex.
- Out << "(*(" << (FPC->getType() == Type::FloatTy ? "float" :
- FPC->getType() == Type::DoubleTy ? "double" :
+ Out << "(*(" << (FPC->getType() == Type::getFloatTy(CPV->getContext()) ?
+ "float" :
+ FPC->getType() == Type::getDoubleTy(CPV->getContext()) ?
+ "double" :
"long double")
<< "*)&FPConstant" << I->second << ')';
} else {
double V;
- if (FPC->getType() == Type::FloatTy)
+ if (FPC->getType() == Type::getFloatTy(CPV->getContext()))
V = FPC->getValueAPF().convertToFloat();
- else if (FPC->getType() == Type::DoubleTy)
+ else if (FPC->getType() == Type::getDoubleTy(CPV->getContext()))
V = FPC->getValueAPF().convertToDouble();
else {
// Long double. Convert the number to double, discarding precision.
@@ -1194,7 +1198,7 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
std::string Num(&Buffer[0], &Buffer[6]);
unsigned long Val = strtoul(Num.c_str(), 0, 16);
- if (FPC->getType() == Type::FloatTy)
+ if (FPC->getType() == Type::getFloatTy(FPC->getContext()))
Out << "LLVM_NAN" << (Val == QuietNaN ? "" : "S") << "F(\""
<< Buffer << "\") /*nan*/ ";
else
@@ -1203,7 +1207,8 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
} else if (IsInf(V)) {
// The value is Inf
if (V < 0) Out << '-';
- Out << "LLVM_INF" << (FPC->getType() == Type::FloatTy ? "F" : "")
+ Out << "LLVM_INF" <<
+ (FPC->getType() == Type::getFloatTy(FPC->getContext()) ? "F" : "")
<< " /*inf*/ ";
} else {
std::string Num;
@@ -1366,7 +1371,7 @@ bool CWriter::printConstExprCast(const ConstantExpr* CE, bool Static) {
}
if (NeedsExplicitCast) {
Out << "((";
- if (Ty->isInteger() && Ty != Type::Int1Ty)
+ if (Ty->isInteger() && Ty != Type::getInt1Ty(Ty->getContext()))
printSimpleType(Out, Ty, TypeIsSigned);
else
printType(Out, Ty); // not integer, sign doesn't matter
@@ -1464,8 +1469,11 @@ void CWriter::writeInstComputationInline(Instruction &I) {
// We can't currently support integer types other than 1, 8, 16, 32, 64.
// Validate this.
const Type *Ty = I.getType();
- if (Ty->isInteger() && (Ty!=Type::Int1Ty && Ty!=Type::Int8Ty &&
- Ty!=Type::Int16Ty && Ty!=Type::Int32Ty && Ty!=Type::Int64Ty)) {
+ if (Ty->isInteger() && (Ty!=Type::getInt1Ty(I.getContext()) &&
+ Ty!=Type::getInt8Ty(I.getContext()) &&
+ Ty!=Type::getInt16Ty(I.getContext()) &&
+ Ty!=Type::getInt32Ty(I.getContext()) &&
+ Ty!=Type::getInt64Ty(I.getContext()))) {
llvm_report_error("The C backend does not currently support integer "
"types of widths other than 1, 8, 16, 32, 64.\n"
"This is being tracked as PR 4158.");
@@ -1475,7 +1483,8 @@ void CWriter::writeInstComputationInline(Instruction &I) {
// a 1 bit value. This is important because we want "add i1 x, y" to return
// "0" when x and y are true, not "2" for example.
bool NeedBoolTrunc = false;
- if (I.getType() == Type::Int1Ty && !isa(I) && !isa(I))
+ if (I.getType() == Type::getInt1Ty(I.getContext()) &&
+ !isa(I) && !isa(I))
NeedBoolTrunc = true;
if (NeedBoolTrunc)
@@ -1624,7 +1633,7 @@ void CWriter::writeOperandWithCast(Value* Operand, const ICmpInst &Cmp) {
// If the operand was a pointer, convert to a large integer type.
const Type* OpTy = Operand->getType();
if (isa(OpTy))
- OpTy = TD->getIntPtrType();
+ OpTy = TD->getIntPtrType(Operand->getContext());
Out << "((";
printSimpleType(Out, OpTy, castIsSigned);
@@ -2143,20 +2152,20 @@ void CWriter::printFloatingPointConstants(const Constant *C) {
FPConstantMap[FPC] = FPCounter; // Number the FP constants
- if (FPC->getType() == Type::DoubleTy) {
+ if (FPC->getType() == Type::getDoubleTy(FPC->getContext())) {
double Val = FPC->getValueAPF().convertToDouble();
uint64_t i = FPC->getValueAPF().bitcastToAPInt().getZExtValue();
Out << "static const ConstantDoubleTy FPConstant" << FPCounter++
<< " = 0x" << utohexstr(i)
<< "ULL; /* " << Val << " */\n";
- } else if (FPC->getType() == Type::FloatTy) {
+ } else if (FPC->getType() == Type::getFloatTy(FPC->getContext())) {
float Val = FPC->getValueAPF().convertToFloat();
uint32_t i = (uint32_t)FPC->getValueAPF().bitcastToAPInt().
getZExtValue();
Out << "static const ConstantFloatTy FPConstant" << FPCounter++
<< " = 0x" << utohexstr(i)
<< "U; /* " << Val << " */\n";
- } else if (FPC->getType() == Type::X86_FP80Ty) {
+ } else if (FPC->getType() == Type::getX86_FP80Ty(FPC->getContext())) {
// api needed to prevent premature destruction
APInt api = FPC->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
@@ -2164,7 +2173,7 @@ void CWriter::printFloatingPointConstants(const Constant *C) {
<< " = { 0x" << utohexstr(p[0])
<< "ULL, 0x" << utohexstr((uint16_t)p[1]) << ",{0,0,0}"
<< "}; /* Long double constant */\n";
- } else if (FPC->getType() == Type::PPC_FP128Ty) {
+ } else if (FPC->getType() == Type::getPPC_FP128Ty(FPC->getContext())) {
APInt api = FPC->getValueAPF().bitcastToAPInt();
const uint64_t *p = api.getRawData();
Out << "static const ConstantFP128Ty FPConstant" << FPCounter++
@@ -2409,7 +2418,8 @@ void CWriter::printFunction(Function &F) {
printType(Out, AI->getAllocatedType(), false, GetValueName(AI));
Out << "; /* Address-exposed local */\n";
PrintedVar = true;
- } else if (I->getType() != Type::VoidTy && !isInlinableInst(*I)) {
+ } else if (I->getType() != Type::getVoidTy(F.getContext()) &&
+ !isInlinableInst(*I)) {
Out << " ";
printType(Out, I->getType(), false, GetValueName(&*I));
Out << ";\n";
@@ -2486,7 +2496,8 @@ void CWriter::printBasicBlock(BasicBlock *BB) {
for (BasicBlock::iterator II = BB->begin(), E = --BB->end(); II != E;
++II) {
if (!isInlinableInst(*II) && !isDirectAlloca(II)) {
- if (II->getType() != Type::VoidTy && !isInlineAsm(*II))
+ if (II->getType() != Type::getVoidTy(BB->getContext()) &&
+ !isInlineAsm(*II))
outputLValue(II);
else
Out << " ";
@@ -2661,8 +2672,9 @@ void CWriter::visitBinaryOperator(Instruction &I) {
// We must cast the results of binary operations which might be promoted.
bool needsCast = false;
- if ((I.getType() == Type::Int8Ty) || (I.getType() == Type::Int16Ty)
- || (I.getType() == Type::FloatTy)) {
+ if ((I.getType() == Type::getInt8Ty(I.getContext())) ||
+ (I.getType() == Type::getInt16Ty(I.getContext()))
+ || (I.getType() == Type::getFloatTy(I.getContext()))) {
needsCast = true;
Out << "((";
printType(Out, I.getType(), false);
@@ -2681,9 +2693,9 @@ void CWriter::visitBinaryOperator(Instruction &I) {
Out << ")";
} else if (I.getOpcode() == Instruction::FRem) {
// Output a call to fmod/fmodf instead of emitting a%b
- if (I.getType() == Type::FloatTy)
+ if (I.getType() == Type::getFloatTy(I.getContext()))
Out << "fmodf(";
- else if (I.getType() == Type::DoubleTy)
+ else if (I.getType() == Type::getDoubleTy(I.getContext()))
Out << "fmod(";
else // all 3 flavors of long double
Out << "fmodl(";
@@ -2850,12 +2862,13 @@ void CWriter::visitCastInst(CastInst &I) {
printCast(I.getOpcode(), SrcTy, DstTy);
// Make a sext from i1 work by subtracting the i1 from 0 (an int).
- if (SrcTy == Type::Int1Ty && I.getOpcode() == Instruction::SExt)
+ if (SrcTy == Type::getInt1Ty(I.getContext()) &&
+ I.getOpcode() == Instruction::SExt)
Out << "0-";
writeOperand(I.getOperand(0));
- if (DstTy == Type::Int1Ty &&
+ if (DstTy == Type::getInt1Ty(I.getContext()) &&
(I.getOpcode() == Instruction::Trunc ||
I.getOpcode() == Instruction::FPToUI ||
I.getOpcode() == Instruction::FPToSI ||
@@ -3280,7 +3293,7 @@ void CWriter::visitInlineAsm(CallInst &CI) {
std::vector Constraints = as->ParseConstraints();
std::vector > ResultVals;
- if (CI.getType() == Type::VoidTy)
+ if (CI.getType() == Type::getVoidTy(CI.getContext()))
;
else if (const StructType *ST = dyn_cast(CI.getType())) {
for (unsigned i = 0, e = ST->getNumElements(); i != e; ++i)
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index c467ead8bb4..98baa95e863 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -221,7 +221,7 @@ namespace {
void CppWriter::printCFP(const ConstantFP *CFP) {
bool ignored;
APFloat APF = APFloat(CFP->getValueAPF()); // copy
- if (CFP->getType() == Type::FloatTy)
+ if (CFP->getType() == Type::getFloatTy(CFP->getContext()))
APF.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &ignored);
Out << "ConstantFP::get(";
Out << "APFloat(";
@@ -232,7 +232,7 @@ namespace {
!strncmp(Buffer, "-0x", 3) ||
!strncmp(Buffer, "+0x", 3)) &&
APF.bitwiseIsEqual(APFloat(atof(Buffer)))) {
- if (CFP->getType() == Type::DoubleTy)
+ if (CFP->getType() == Type::getDoubleTy(CFP->getContext()))
Out << "BitsToDouble(" << Buffer << ")";
else
Out << "BitsToFloat((float)" << Buffer << ")";
@@ -250,11 +250,11 @@ namespace {
((StrVal[0] == '-' || StrVal[0] == '+') &&
(StrVal[1] >= '0' && StrVal[1] <= '9'))) &&
(CFP->isExactlyValue(atof(StrVal.c_str())))) {
- if (CFP->getType() == Type::DoubleTy)
+ if (CFP->getType() == Type::getDoubleTy(CFP->getContext()))
Out << StrVal;
else
Out << StrVal << "f";
- } else if (CFP->getType() == Type::DoubleTy)
+ } else if (CFP->getType() == Type::getDoubleTy(CFP->getContext()))
Out << "BitsToDouble(0x"
<< utohexstr(CFP->getValueAPF().bitcastToAPInt().getZExtValue())
<< "ULL) /* " << StrVal << " */";
@@ -764,7 +764,9 @@ namespace {
printCFP(CFP);
Out << ";";
} else if (const ConstantArray *CA = dyn_cast(CV)) {
- if (CA->isString() && CA->getType()->getElementType() == Type::Int8Ty) {
+ if (CA->isString() &&
+ CA->getType()->getElementType() ==
+ Type::getInt8Ty(CA->getContext())) {
Out << "Constant* " << constName << " = ConstantArray::get(\"";
std::string tmp = CA->getAsString();
bool nullTerminate = false;
diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp
index 226d146a0e3..93e59f71d4c 100644
--- a/lib/Target/MSIL/MSILWriter.cpp
+++ b/lib/Target/MSIL/MSILWriter.cpp
@@ -820,7 +820,8 @@ void MSILWriter::printIntrinsicCall(const IntrinsicInst* Inst) {
// Save as pointer type "void*"
printValueLoad(Inst->getOperand(1));
printSimpleInstruction("ldloca",Name.c_str());
- printIndirectSave(PointerType::getUnqual(IntegerType::get(8)));
+ printIndirectSave(PointerType::getUnqual(
+ IntegerType::get(Inst->getContext(), 8)));
break;
case Intrinsic::vaend:
// Close argument list handle.
@@ -1041,7 +1042,8 @@ void MSILWriter::printVAArgInstruction(const VAArgInst* Inst) {
"instance typedref [mscorlib]System.ArgIterator::GetNextArg()");
printSimpleInstruction("refanyval","void*");
std::string Name =
- "ldind."+getTypePostfix(PointerType::getUnqual(IntegerType::get(8)),false);
+ "ldind."+getTypePostfix(PointerType::getUnqual(
+ IntegerType::get(Inst->getContext(), 8)),false);
printSimpleInstruction(Name.c_str());
}
@@ -1237,7 +1239,7 @@ void MSILWriter::printBasicBlock(const BasicBlock* BB) {
// Print instruction
printInstruction(Inst);
// Save result
- if (Inst->getType()!=Type::VoidTy) {
+ if (Inst->getType()!=Type::getVoidTy(BB->getContext())) {
// Do not save value after invoke, it done in "try" block
if (Inst->getOpcode()==Instruction::Invoke) continue;
printValueSave(Inst);
@@ -1266,7 +1268,7 @@ void MSILWriter::printLocalVariables(const Function& F) {
Ty = PointerType::getUnqual(AI->getAllocatedType());
Name = getValueName(AI);
Out << "\t.locals (" << getTypeName(Ty) << Name << ")\n";
- } else if (I->getType()!=Type::VoidTy) {
+ } else if (I->getType()!=Type::getVoidTy(F.getContext())) {
// Operation result.
Ty = I->getType();
Name = getValueName(&*I);
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
index 11c4093634c..569026fbb7c 100644
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -1269,7 +1269,8 @@ SDValue PPCTargetLowering::LowerTRAMPOLINE(SDValue Op, SelectionDAG &DAG) {
EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy();
bool isPPC64 = (PtrVT == MVT::i64);
const Type *IntPtrTy =
- DAG.getTargetLoweringInfo().getTargetData()->getIntPtrType();
+ DAG.getTargetLoweringInfo().getTargetData()->getIntPtrType(
+ *DAG.getContext());
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp
index ed544b73eae..cc6be9fa7ab 100644
--- a/lib/Target/Target.cpp
+++ b/lib/Target/Target.cpp
@@ -41,7 +41,7 @@ unsigned LLVMPointerSize(LLVMTargetDataRef TD) {
}
LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD) {
- return wrap(unwrap(TD)->getIntPtrType());
+ return wrap(unwrap(TD)->getIntPtrType(getGlobalContext()));
}
unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 3f1979bc29b..838c675d1b7 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -541,8 +541,8 @@ unsigned char TargetData::getPreferredTypeAlignmentShift(const Type *Ty) const {
/// getIntPtrType - Return an unsigned integer type that is the same size or
/// greater to the host pointer size.
-const IntegerType *TargetData::getIntPtrType() const {
- return IntegerType::get(getPointerSizeInBits());
+const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const {
+ return IntegerType::get(C, getPointerSizeInBits());
}
@@ -556,7 +556,8 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, Value* const* Indices,
TI = gep_type_begin(ptrTy, Indices, Indices+NumIndices);
for (unsigned CurIDX = 0; CurIDX != NumIndices; ++CurIDX, ++TI) {
if (const StructType *STy = dyn_cast(*TI)) {
- assert(Indices[CurIDX]->getType() == Type::Int32Ty &&
+ assert(Indices[CurIDX]->getType() ==
+ Type::getInt32Ty(ptrTy->getContext()) &&
"Illegal struct idx");
unsigned FieldNo = cast(Indices[CurIDX])->getZExtValue();
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index b98a9738c64..5e9a39f0562 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -272,7 +272,7 @@ bool X86FastISel::X86FastEmitStore(EVT VT, Value *Val,
const X86AddressMode &AM) {
// Handle 'null' like i32/i64 0.
if (isa(Val))
- Val = Constant::getNullValue(TD.getIntPtrType());
+ Val = Constant::getNullValue(TD.getIntPtrType(Val->getContext()));
// If this is a store of a simple constant, fold the constant into the store.
if (ConstantInt *CI = dyn_cast(Val)) {
@@ -672,7 +672,7 @@ bool X86FastISel::X86FastEmitCompare(Value *Op0, Value *Op1, EVT VT) {
// Handle 'null' like i32/i64 0.
if (isa(Op1))
- Op1 = Constant::getNullValue(TD.getIntPtrType());
+ Op1 = Constant::getNullValue(TD.getIntPtrType(Op0->getContext()));
// We have two options: compare with register or immediate. If the RHS of
// the compare is an immediate that we can fold into this compare, use
@@ -773,8 +773,8 @@ bool X86FastISel::X86SelectCmp(Instruction *I) {
bool X86FastISel::X86SelectZExt(Instruction *I) {
// Handle zero-extension from i1 to i8, which is common.
- if (I->getType() == Type::Int8Ty &&
- I->getOperand(0)->getType() == Type::Int1Ty) {
+ if (I->getType() == Type::getInt8Ty(I->getContext()) &&
+ I->getOperand(0)->getType() == Type::getInt1Ty(I->getContext())) {
unsigned ResultReg = getRegForValue(I->getOperand(0));
if (ResultReg == 0) return false;
// Set the high bits to zero.
@@ -935,7 +935,7 @@ bool X86FastISel::X86SelectBranch(Instruction *I) {
bool X86FastISel::X86SelectShift(Instruction *I) {
unsigned CReg = 0, OpReg = 0, OpImm = 0;
const TargetRegisterClass *RC = NULL;
- if (I->getType() == Type::Int8Ty) {
+ if (I->getType() == Type::getInt8Ty(I->getContext())) {
CReg = X86::CL;
RC = &X86::GR8RegClass;
switch (I->getOpcode()) {
@@ -944,7 +944,7 @@ bool X86FastISel::X86SelectShift(Instruction *I) {
case Instruction::Shl: OpReg = X86::SHL8rCL; OpImm = X86::SHL8ri; break;
default: return false;
}
- } else if (I->getType() == Type::Int16Ty) {
+ } else if (I->getType() == Type::getInt16Ty(I->getContext())) {
CReg = X86::CX;
RC = &X86::GR16RegClass;
switch (I->getOpcode()) {
@@ -953,7 +953,7 @@ bool X86FastISel::X86SelectShift(Instruction *I) {
case Instruction::Shl: OpReg = X86::SHL16rCL; OpImm = X86::SHL16ri; break;
default: return false;
}
- } else if (I->getType() == Type::Int32Ty) {
+ } else if (I->getType() == Type::getInt32Ty(I->getContext())) {
CReg = X86::ECX;
RC = &X86::GR32RegClass;
switch (I->getOpcode()) {
@@ -962,7 +962,7 @@ bool X86FastISel::X86SelectShift(Instruction *I) {
case Instruction::Shl: OpReg = X86::SHL32rCL; OpImm = X86::SHL32ri; break;
default: return false;
}
- } else if (I->getType() == Type::Int64Ty) {
+ } else if (I->getType() == Type::getInt64Ty(I->getContext())) {
CReg = X86::RCX;
RC = &X86::GR64RegClass;
switch (I->getOpcode()) {
@@ -1044,9 +1044,10 @@ bool X86FastISel::X86SelectSelect(Instruction *I) {
bool X86FastISel::X86SelectFPExt(Instruction *I) {
// fpext from float to double.
- if (Subtarget->hasSSE2() && I->getType() == Type::DoubleTy) {
+ if (Subtarget->hasSSE2() &&
+ I->getType() == Type::getDoubleTy(I->getContext())) {
Value *V = I->getOperand(0);
- if (V->getType() == Type::FloatTy) {
+ if (V->getType() == Type::getFloatTy(I->getContext())) {
unsigned OpReg = getRegForValue(V);
if (OpReg == 0) return false;
unsigned ResultReg = createResultReg(X86::FR64RegisterClass);
@@ -1061,9 +1062,9 @@ bool X86FastISel::X86SelectFPExt(Instruction *I) {
bool X86FastISel::X86SelectFPTrunc(Instruction *I) {
if (Subtarget->hasSSE2()) {
- if (I->getType() == Type::FloatTy) {
+ if (I->getType() == Type::getFloatTy(I->getContext())) {
Value *V = I->getOperand(0);
- if (V->getType() == Type::DoubleTy) {
+ if (V->getType() == Type::getDoubleTy(I->getContext())) {
unsigned OpReg = getRegForValue(V);
if (OpReg == 0) return false;
unsigned ResultReg = createResultReg(X86::FR32RegisterClass);
@@ -1230,7 +1231,7 @@ bool X86FastISel::X86SelectCall(Instruction *I) {
// Handle *simple* calls for now.
const Type *RetTy = CS.getType();
EVT RetVT;
- if (RetTy == Type::VoidTy)
+ if (RetTy == Type::getVoidTy(I->getContext()))
RetVT = MVT::isVoid;
else if (!isTypeLegal(RetTy, RetVT, true))
return false;
diff --git a/lib/Target/X86/X86FloatingPointRegKill.cpp b/lib/Target/X86/X86FloatingPointRegKill.cpp
index 292f8f432d6..3e0385c79c1 100644
--- a/lib/Target/X86/X86FloatingPointRegKill.cpp
+++ b/lib/Target/X86/X86FloatingPointRegKill.cpp
@@ -118,9 +118,10 @@ bool FPRegKiller::runOnMachineFunction(MachineFunction &MF) {
!ContainsFPCode && SI != E; ++SI) {
for (BasicBlock::const_iterator II = SI->begin();
(PN = dyn_cast(II)); ++II) {
- if (PN->getType()==Type::X86_FP80Ty ||
+ if (PN->getType()==Type::getX86_FP80Ty(LLVMBB->getContext()) ||
(!Subtarget.hasSSE1() && PN->getType()->isFloatingPoint()) ||
- (!Subtarget.hasSSE2() && PN->getType()==Type::DoubleTy)) {
+ (!Subtarget.hasSSE2() &&
+ PN->getType()==Type::getDoubleTy(LLVMBB->getContext()))) {
ContainsFPCode = true;
break;
}
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 7507eb2a1bb..ca6ff929a77 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -5831,7 +5831,7 @@ X86TargetLowering::EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,
if (const char *bzeroEntry = V &&
V->isNullValue() ? Subtarget->getBZeroEntry() : 0) {
EVT IntPtr = getPointerTy();
- const Type *IntPtrTy = TD->getIntPtrType();
+ const Type *IntPtrTy = TD->getIntPtrType(*DAG.getContext());
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Entry.Node = Dst;
@@ -5840,7 +5840,8 @@ X86TargetLowering::EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl,
Entry.Node = Size;
Args.push_back(Entry);
std::pair CallResult =
- LowerCallTo(Chain, Type::VoidTy, false, false, false, false,
+ LowerCallTo(Chain, Type::getVoidTy(*DAG.getContext()),
+ false, false, false, false,
0, CallingConv::C, false, /*isReturnValueUsed=*/false,
DAG.getExternalSymbol(bzeroEntry, IntPtr), Args, DAG, dl);
return CallResult.second;
@@ -7159,7 +7160,8 @@ bool X86TargetLowering::isTruncateFree(EVT VT1, EVT VT2) const {
bool X86TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const {
// x86-64 implicitly zero-extends 32-bit results in 64-bit registers.
- return Ty1 == Type::Int32Ty && Ty2 == Type::Int64Ty && Subtarget->is64Bit();
+ return Ty1 == Type::getInt32Ty(Ty1->getContext()) &&
+ Ty2 == Type::getInt64Ty(Ty1->getContext()) && Subtarget->is64Bit();
}
bool X86TargetLowering::isZExtFree(EVT VT1, EVT VT2) const {
@@ -8768,7 +8770,7 @@ bool X86TargetLowering::ExpandInlineAsm(CallInst *CI) const {
return LowerToBSwap(CI);
}
// rorw $$8, ${0:w} --> llvm.bswap.i16
- if (CI->getType() == Type::Int16Ty &&
+ if (CI->getType() == Type::getInt16Ty(CI->getContext()) &&
AsmPieces.size() == 3 &&
AsmPieces[0] == "rorw" &&
AsmPieces[1] == "$$8," &&
@@ -8778,7 +8780,8 @@ bool X86TargetLowering::ExpandInlineAsm(CallInst *CI) const {
}
break;
case 3:
- if (CI->getType() == Type::Int64Ty && Constraints.size() >= 2 &&
+ if (CI->getType() == Type::getInt64Ty(CI->getContext()) &&
+ Constraints.size() >= 2 &&
Constraints[0].Codes.size() == 1 && Constraints[0].Codes[0] == "A" &&
Constraints[1].Codes.size() == 1 && Constraints[1].Codes[0] == "0") {
// bswap %eax / bswap %edx / xchgl %eax, %edx -> llvm.bswap.i64
@@ -8896,7 +8899,8 @@ void X86TargetLowering::LowerAsmOperandForConstraint(SDValue Op,
// 32-bit signed value
if (ConstantSDNode *C = dyn_cast(Op)) {
const ConstantInt *CI = C->getConstantIntValue();
- if (CI->isValueValidForType(Type::Int32Ty, C->getSExtValue())) {
+ if (CI->isValueValidForType(Type::getInt32Ty(*DAG.getContext()),
+ C->getSExtValue())) {
// Widen to 64 bits here to get it sign extended.
Result = DAG.getTargetConstant(C->getSExtValue(), MVT::i64);
break;
@@ -8910,7 +8914,8 @@ void X86TargetLowering::LowerAsmOperandForConstraint(SDValue Op,
// 32-bit unsigned value
if (ConstantSDNode *C = dyn_cast(Op)) {
const ConstantInt *CI = C->getConstantIntValue();
- if (CI->isValueValidForType(Type::Int32Ty, C->getZExtValue())) {
+ if (CI->isValueValidForType(Type::getInt32Ty(*DAG.getContext()),
+ C->getZExtValue())) {
Result = DAG.getTargetConstant(C->getZExtValue(), Op.getValueType());
break;
}
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp
index 297c4dd175c..6e8561d8e44 100644
--- a/lib/Target/X86/X86InstrInfo.cpp
+++ b/lib/Target/X86/X86InstrInfo.cpp
@@ -2299,7 +2299,8 @@ MachineInstr* X86InstrInfo::foldMemoryOperandImpl(MachineFunction &MF,
// Create a v4i32 constant-pool entry.
MachineConstantPool &MCP = *MF.getConstantPool();
- const VectorType *Ty = VectorType::get(Type::Int32Ty, 4);
+ const VectorType *Ty =
+ VectorType::get(Type::getInt32Ty(MF.getFunction()->getContext()), 4);
Constant *C = LoadMI->getOpcode() == X86::V_SET0 ?
Constant::getNullValue(Ty) :
Constant::getAllOnesValue(Ty);
diff --git a/lib/Target/XCore/XCoreISelDAGToDAG.cpp b/lib/Target/XCore/XCoreISelDAGToDAG.cpp
index 5d6702b4dad..1a5f10291f5 100644
--- a/lib/Target/XCore/XCoreISelDAGToDAG.cpp
+++ b/lib/Target/XCore/XCoreISelDAGToDAG.cpp
@@ -174,7 +174,8 @@ SDNode *XCoreDAGToDAGISel::Select(SDValue Op) {
else if (! Predicate_immU16(N)) {
unsigned Val = cast(N)->getZExtValue();
SDValue CPIdx =
- CurDAG->getTargetConstantPool(ConstantInt::get(Type::Int32Ty, Val),
+ CurDAG->getTargetConstantPool(ConstantInt::get(
+ Type::getInt32Ty(*CurDAG->getContext()), Val),
TLI.getPointerTy());
return CurDAG->getTargetNode(XCore::LDWCP_lru6, dl, MVT::i32,
MVT::Other, CPIdx,
diff --git a/lib/Target/XCore/XCoreISelLowering.cpp b/lib/Target/XCore/XCoreISelLowering.cpp
index e9ca3f59830..0174778a1d4 100644
--- a/lib/Target/XCore/XCoreISelLowering.cpp
+++ b/lib/Target/XCore/XCoreISelLowering.cpp
@@ -438,7 +438,7 @@ LowerLOAD(SDValue Op, SelectionDAG &DAG)
}
// Lower to a call to __misaligned_load(BasePtr).
- const Type *IntPtrTy = getTargetData()->getIntPtrType();
+ const Type *IntPtrTy = getTargetData()->getIntPtrType(*DAG.getContext());
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
@@ -496,7 +496,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG)
}
// Lower to a call to __misaligned_store(BasePtr, Value).
- const Type *IntPtrTy = getTargetData()->getIntPtrType();
+ const Type *IntPtrTy = getTargetData()->getIntPtrType(*DAG.getContext());
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
@@ -508,7 +508,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG)
Args.push_back(Entry);
std::pair CallResult =
- LowerCallTo(Chain, Type::VoidTy, false, false,
+ LowerCallTo(Chain, Type::getVoidTy(*DAG.getContext()), false, false,
false, false, 0, CallingConv::C, false,
/*isReturnValueUsed=*/true,
DAG.getExternalSymbol("__misaligned_store", getPointerTy()),
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index f3e0b18573c..e40372b04a1 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -582,7 +582,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
bool ExtraArgHack = false;
if (Params.empty() && FTy->isVarArg()) {
ExtraArgHack = true;
- Params.push_back(Type::Int32Ty);
+ Params.push_back(Type::getInt32Ty(F->getContext()));
}
// Construct the new function type using the new arguments.
@@ -637,9 +637,10 @@ Function *ArgPromotion::DoPromotion(Function *F,
// Emit a GEP and load for each element of the struct.
const Type *AgTy = cast(I->getType())->getElementType();
const StructType *STy = cast(AgTy);
- Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 };
+ Value *Idxs[2] = {
+ ConstantInt::get(Type::getInt32Ty(F->getContext()), 0), 0 };
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
+ Idxs[1] = ConstantInt::get(Type::getInt32Ty(F->getContext()), i);
Value *Idx = GetElementPtrInst::Create(*AI, Idxs, Idxs+2,
(*AI)->getName()+"."+utostr(i),
Call);
@@ -663,7 +664,9 @@ Function *ArgPromotion::DoPromotion(Function *F,
IE = SI->end(); II != IE; ++II) {
// Use i32 to index structs, and i64 for others (pointers/arrays).
// This satisfies GEP constraints.
- const Type *IdxTy = (isa(ElTy) ? Type::Int32Ty : Type::Int64Ty);
+ const Type *IdxTy = (isa(ElTy) ?
+ Type::getInt32Ty(F->getContext()) :
+ Type::getInt64Ty(F->getContext()));
Ops.push_back(ConstantInt::get(IdxTy, *II));
// Keep track of the type we're currently indexing
ElTy = cast(ElTy)->getTypeAtIndex(*II);
@@ -680,7 +683,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
}
if (ExtraArgHack)
- Args.push_back(Constant::getNullValue(Type::Int32Ty));
+ Args.push_back(Constant::getNullValue(Type::getInt32Ty(F->getContext())));
// Push any varargs arguments on the list
for (; AI != CS.arg_end(); ++AI, ++ArgIndex) {
@@ -757,10 +760,11 @@ Function *ArgPromotion::DoPromotion(Function *F,
const Type *AgTy = cast(I->getType())->getElementType();
Value *TheAlloca = new AllocaInst(AgTy, 0, "", InsertPt);
const StructType *STy = cast(AgTy);
- Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 };
+ Value *Idxs[2] = {
+ ConstantInt::get(Type::getInt32Ty(F->getContext()), 0), 0 };
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
- Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
+ Idxs[1] = ConstantInt::get(Type::getInt32Ty(F->getContext()), i);
Value *Idx =
GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
TheAlloca->getName()+"."+Twine(i),
@@ -844,7 +848,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
// Notify the alias analysis implementation that we inserted a new argument.
if (ExtraArgHack)
- AA.copyValue(Constant::getNullValue(Type::Int32Ty), NF->arg_begin());
+ AA.copyValue(Constant::getNullValue(Type::getInt32Ty(F->getContext())),
+ NF->arg_begin());
// Tell the alias analysis that the old function is about to disappear.
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 06121196181..ad99eb4bf22 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -281,7 +281,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
/// for void functions and 1 for functions not returning a struct. It returns
/// the number of struct elements for functions returning a struct.
static unsigned NumRetVals(const Function *F) {
- if (F->getReturnType() == Type::VoidTy)
+ if (F->getReturnType() == Type::getVoidTy(F->getContext()))
return 0;
else if (const StructType *STy = dyn_cast(F->getReturnType()))
return STy->getNumElements();
@@ -604,8 +604,8 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// -1 means unused, other numbers are the new index
SmallVector NewRetIdxs(RetCount, -1);
std::vector RetTypes;
- if (RetTy == Type::VoidTy) {
- NRetTy = Type::VoidTy;
+ if (RetTy == Type::getVoidTy(F->getContext())) {
+ NRetTy = Type::getVoidTy(F->getContext());
} else {
const StructType *STy = dyn_cast(RetTy);
if (STy)
@@ -645,7 +645,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
NRetTy = RetTypes.front();
else if (RetTypes.size() == 0)
// No return types? Make it void, but only if we didn't use to return {}.
- NRetTy = Type::VoidTy;
+ NRetTy = Type::getVoidTy(F->getContext());
}
assert(NRetTy && "No new return type found?");
@@ -654,7 +654,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// values. Otherwise, ensure that we don't have any conflicting attributes
// here. Currently, this should not be possible, but special handling might be
// required when new return value attributes are added.
- if (NRetTy == Type::VoidTy)
+ if (NRetTy == Type::getVoidTy(F->getContext()))
RAttrs &= ~Attribute::typeIncompatible(NRetTy);
else
assert((RAttrs & Attribute::typeIncompatible(NRetTy)) == 0
@@ -702,7 +702,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
bool ExtraArgHack = false;
if (Params.empty() && FTy->isVarArg() && FTy->getNumParams() != 0) {
ExtraArgHack = true;
- Params.push_back(Type::Int32Ty);
+ Params.push_back(Type::getInt32Ty(F->getContext()));
}
// Create the new function type based on the recomputed parameters.
@@ -756,7 +756,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
if (ExtraArgHack)
- Args.push_back(UndefValue::get(Type::Int32Ty));
+ Args.push_back(UndefValue::get(Type::getInt32Ty(F->getContext())));
// Push any varargs arguments on the list. Don't forget their attributes.
for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) {
@@ -792,7 +792,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Return type not changed? Just replace users then.
Call->replaceAllUsesWith(New);
New->takeName(Call);
- } else if (New->getType() == Type::VoidTy) {
+ } else if (New->getType() == Type::getVoidTy(F->getContext())) {
// Our return value has uses, but they will get removed later on.
// Replace by null for now.
Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
@@ -868,7 +868,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
if (ReturnInst *RI = dyn_cast(BB->getTerminator())) {
Value *RetVal;
- if (NFTy->getReturnType() == Type::VoidTy) {
+ if (NFTy->getReturnType() == Type::getVoidTy(F->getContext())) {
RetVal = 0;
} else {
assert (isa(RetTy));
@@ -899,7 +899,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
// Replace the return instruction with one returning the new return
// value (possibly 0 if we became void).
- ReturnInst::Create(RetVal, RI);
+ ReturnInst::Create(F->getContext(), RetVal, RI);
BB->getInstList().erase(RI);
}
diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp
index f80a087c7c1..3dd3a80a15b 100644
--- a/lib/Transforms/IPO/ExtractGV.cpp
+++ b/lib/Transforms/IPO/ExtractGV.cpp
@@ -101,7 +101,8 @@ namespace {
// by putting them in the used array
{
std::vector AUGs;
- const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
+ const Type *SBP=
+ PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
for (std::vector::iterator GI = Named.begin(),
GE = Named.end(); GI != GE; ++GI) {
(*GI)->setLinkage(GlobalValue::ExternalLinkage);
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 82af99a7f99..ae3acad96ff 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -488,7 +488,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
const StructLayout &Layout = *TD.getStructLayout(STy);
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Constant *In = getAggregateConstantElement(Init,
- ConstantInt::get(Type::Int32Ty, i),
+ ConstantInt::get(Type::getInt32Ty(Context), i),
Context);
assert(In && "Couldn't get element of initializer?");
GlobalVariable *NGV = new GlobalVariable(Context,
@@ -523,7 +523,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
unsigned EltAlign = TD.getABITypeAlignment(STy->getElementType());
for (unsigned i = 0, e = NumElements; i != e; ++i) {
Constant *In = getAggregateConstantElement(Init,
- ConstantInt::get(Type::Int32Ty, i),
+ ConstantInt::get(Type::getInt32Ty(Context), i),
Context);
assert(In && "Couldn't get element of initializer?");
@@ -550,7 +550,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD,
DOUT << "PERFORMING GLOBAL SRA ON: " << *GV;
- Constant *NullInt = Constant::getNullValue(Type::Int32Ty);
+ Constant *NullInt = Constant::getNullValue(Type::getInt32Ty(Context));
// Loop over all of the uses of the global, replacing the constantexpr geps,
// with smaller constantexpr geps or direct references.
@@ -828,10 +828,10 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
Type *NewTy = ArrayType::get(MI->getAllocatedType(),
NElements->getZExtValue());
MallocInst *NewMI =
- new MallocInst(NewTy, Constant::getNullValue(Type::Int32Ty),
+ new MallocInst(NewTy, Constant::getNullValue(Type::getInt32Ty(Context)),
MI->getAlignment(), MI->getName(), MI);
Value* Indices[2];
- Indices[0] = Indices[1] = Constant::getNullValue(Type::Int32Ty);
+ Indices[0] = Indices[1] = Constant::getNullValue(Type::getInt32Ty(Context));
Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2,
NewMI->getName()+".el0", MI);
MI->replaceAllUsesWith(NewGEP);
@@ -863,7 +863,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
// If there is a comparison against null, we will insert a global bool to
// keep track of whether the global was initialized yet or not.
GlobalVariable *InitBool =
- new GlobalVariable(Context, Type::Int1Ty, false,
+ new GlobalVariable(Context, Type::getInt1Ty(Context), false,
GlobalValue::InternalLinkage,
ConstantInt::getFalse(Context), GV->getName()+".init",
GV->isThreadLocal());
@@ -1326,7 +1326,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
// Create the block to check the first condition. Put all these blocks at the
// end of the function as they are unlikely to be executed.
- BasicBlock *NullPtrBlock = BasicBlock::Create("malloc_ret_null",
+ BasicBlock *NullPtrBlock = BasicBlock::Create(Context, "malloc_ret_null",
OrigBB->getParent());
// Remove the uncond branch from OrigBB to ContBB, turning it into a cond
@@ -1341,8 +1341,10 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
Value *Cmp = new ICmpInst(*NullPtrBlock, ICmpInst::ICMP_NE, GVVal,
Constant::getNullValue(GVVal->getType()),
"tmp");
- BasicBlock *FreeBlock = BasicBlock::Create("free_it", OrigBB->getParent());
- BasicBlock *NextBlock = BasicBlock::Create("next", OrigBB->getParent());
+ BasicBlock *FreeBlock = BasicBlock::Create(Context, "free_it",
+ OrigBB->getParent());
+ BasicBlock *NextBlock = BasicBlock::Create(Context, "next",
+ OrigBB->getParent());
BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock);
// Fill in FreeBlock.
@@ -1508,7 +1510,8 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV,
if (const ArrayType *AT = dyn_cast(MI->getAllocatedType())) {
MallocInst *NewMI =
new MallocInst(AllocSTy,
- ConstantInt::get(Type::Int32Ty, AT->getNumElements()),
+ ConstantInt::get(Type::getInt32Ty(Context),
+ AT->getNumElements()),
"", MI);
NewMI->takeName(MI);
Value *Cast = new BitCastInst(NewMI, MI->getType(), "tmp", MI);
@@ -1569,7 +1572,7 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal,
// between them is very expensive and unlikely to lead to later
// simplification. In these cases, we typically end up with "cond ? v1 : v2"
// where v1 and v2 both require constant pool loads, a big loss.
- if (GVElType == Type::Int1Ty || GVElType->isFloatingPoint() ||
+ if (GVElType == Type::getInt1Ty(Context) || GVElType->isFloatingPoint() ||
isa(GVElType) || isa(GVElType))
return false;
@@ -1582,14 +1585,16 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal,
DOUT << " *** SHRINKING TO BOOL: " << *GV;
// Create the new global, initializing it to false.
- GlobalVariable *NewGV = new GlobalVariable(Context, Type::Int1Ty, false,
+ GlobalVariable *NewGV = new GlobalVariable(Context,
+ Type::getInt1Ty(Context), false,
GlobalValue::InternalLinkage, ConstantInt::getFalse(Context),
GV->getName()+".b",
GV->isThreadLocal());
GV->getParent()->getGlobalList().insert(GV, NewGV);
Constant *InitVal = GV->getInitializer();
- assert(InitVal->getType() != Type::Int1Ty && "No reason to shrink to bool!");
+ assert(InitVal->getType() != Type::getInt1Ty(Context) &&
+ "No reason to shrink to bool!");
// If initialized to zero and storing one into the global, we can use a cast
// instead of a select to synthesize the desired value.
@@ -1605,7 +1610,7 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal,
// Only do this if we weren't storing a loaded value.
Value *StoreVal;
if (StoringOther || SI->getOperand(0) == InitVal)
- StoreVal = ConstantInt::get(Type::Int1Ty, StoringOther);
+ StoreVal = ConstantInt::get(Type::getInt1Ty(Context), StoringOther);
else {
// Otherwise, we are storing a previously loaded copy. To do this,
// change the copy from copying the original value to just copying the
@@ -1893,12 +1898,12 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) {
if (!ATy) return 0;
const StructType *STy = dyn_cast(ATy->getElementType());
if (!STy || STy->getNumElements() != 2 ||
- STy->getElementType(0) != Type::Int32Ty) return 0;
+ STy->getElementType(0) != Type::getInt32Ty(M.getContext())) return 0;
const PointerType *PFTy = dyn_cast(STy->getElementType(1));
if (!PFTy) return 0;
const FunctionType *FTy = dyn_cast(PFTy->getElementType());
- if (!FTy || FTy->getReturnType() != Type::VoidTy || FTy->isVarArg() ||
- FTy->getNumParams() != 0)
+ if (!FTy || FTy->getReturnType() != Type::getVoidTy(M.getContext()) ||
+ FTy->isVarArg() || FTy->getNumParams() != 0)
return 0;
// Verify that the initializer is simple enough for us to handle.
@@ -1947,7 +1952,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
LLVMContext &Context) {
// If we made a change, reassemble the initializer list.
std::vector CSVals;
- CSVals.push_back(ConstantInt::get(Type::Int32Ty, 65535));
+ CSVals.push_back(ConstantInt::get(Type::getInt32Ty(Context), 65535));
CSVals.push_back(0);
// Create the new init list.
@@ -1956,10 +1961,10 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
if (Ctors[i]) {
CSVals[1] = Ctors[i];
} else {
- const Type *FTy = FunctionType::get(Type::VoidTy, false);
+ const Type *FTy = FunctionType::get(Type::getVoidTy(Context), false);
const PointerType *PFTy = PointerType::getUnqual(FTy);
CSVals[1] = Constant::getNullValue(PFTy);
- CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
+ CSVals[0] = ConstantInt::get(Type::getInt32Ty(Context), 2147483647);
}
CAList.push_back(ConstantStruct::get(Context, CSVals));
}
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index 4edecc2b23c..bb2448610f2 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -152,7 +152,7 @@ bool IPCP::PropagateConstantsIntoArguments(Function &F) {
// callers will be updated to use the value they pass in directly instead of
// using the return value.
bool IPCP::PropagateConstantReturn(Function &F) {
- if (F.getReturnType() == Type::VoidTy)
+ if (F.getReturnType() == Type::getVoidTy(F.getContext()))
return false; // No return value.
// If this function could be overridden later in the link stage, we can't
diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp
index 2086a166833..e7884ec634b 100644
--- a/lib/Transforms/IPO/IndMemRemoval.cpp
+++ b/lib/Transforms/IPO/IndMemRemoval.cpp
@@ -55,8 +55,8 @@ bool IndMemRemPass::runOnModule(Module &M) {
Function* FN = Function::Create(F->getFunctionType(),
GlobalValue::LinkOnceAnyLinkage,
"free_llvm_bounce", &M);
- BasicBlock* bb = BasicBlock::Create("entry",FN);
- Instruction* R = ReturnInst::Create(bb);
+ BasicBlock* bb = BasicBlock::Create(M.getContext(), "entry",FN);
+ Instruction* R = ReturnInst::Create(M.getContext(), bb);
new FreeInst(FN->arg_begin(), R);
++NumBounce;
NumBounceSites += F->getNumUses();
@@ -70,11 +70,12 @@ bool IndMemRemPass::runOnModule(Module &M) {
GlobalValue::LinkOnceAnyLinkage,
"malloc_llvm_bounce", &M);
FN->setDoesNotAlias(0);
- BasicBlock* bb = BasicBlock::Create("entry",FN);
+ BasicBlock* bb = BasicBlock::Create(M.getContext(), "entry",FN);
Instruction* c = CastInst::CreateIntegerCast(
- FN->arg_begin(), Type::Int32Ty, false, "c", bb);
- Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb);
- ReturnInst::Create(a, bb);
+ FN->arg_begin(), Type::getInt32Ty(M.getContext()), false, "c", bb);
+ Instruction* a = new MallocInst(Type::getInt8Ty(M.getContext()),
+ c, "m", bb);
+ ReturnInst::Create(M.getContext(), a, bb);
++NumBounce;
NumBounceSites += F->getNumUses();
F->replaceAllUsesWith(FN);
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index 568798bd3af..5dff47aa81e 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -201,7 +201,7 @@ bool LowerSetJmp::runOnModule(Module& M) {
// This function is always successful, unless it isn't.
bool LowerSetJmp::doInitialization(Module& M)
{
- const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type *SBPTy = PointerType::getUnqual(Type::getInt8Ty(M.getContext()));
const Type *SBPPTy = PointerType::getUnqual(SBPTy);
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
@@ -209,33 +209,40 @@ bool LowerSetJmp::doInitialization(Module& M)
// void __llvm_sjljeh_init_setjmpmap(void**)
InitSJMap = M.getOrInsertFunction("__llvm_sjljeh_init_setjmpmap",
- Type::VoidTy, SBPPTy, (Type *)0);
+ Type::getVoidTy(M.getContext()),
+ SBPPTy, (Type *)0);
// void __llvm_sjljeh_destroy_setjmpmap(void**)
DestroySJMap = M.getOrInsertFunction("__llvm_sjljeh_destroy_setjmpmap",
- Type::VoidTy, SBPPTy, (Type *)0);
+ Type::getVoidTy(M.getContext()),
+ SBPPTy, (Type *)0);
// void __llvm_sjljeh_add_setjmp_to_map(void**, void*, unsigned)
AddSJToMap = M.getOrInsertFunction("__llvm_sjljeh_add_setjmp_to_map",
- Type::VoidTy, SBPPTy, SBPTy,
- Type::Int32Ty, (Type *)0);
+ Type::getVoidTy(M.getContext()),
+ SBPPTy, SBPTy,
+ Type::getInt32Ty(M.getContext()),
+ (Type *)0);
// void __llvm_sjljeh_throw_longjmp(int*, int)
ThrowLongJmp = M.getOrInsertFunction("__llvm_sjljeh_throw_longjmp",
- Type::VoidTy, SBPTy, Type::Int32Ty,
+ Type::getVoidTy(M.getContext()), SBPTy,
+ Type::getInt32Ty(M.getContext()),
(Type *)0);
// unsigned __llvm_sjljeh_try_catching_longjmp_exception(void **)
TryCatchLJ =
M.getOrInsertFunction("__llvm_sjljeh_try_catching_longjmp_exception",
- Type::Int32Ty, SBPPTy, (Type *)0);
+ Type::getInt32Ty(M.getContext()), SBPPTy, (Type *)0);
// bool __llvm_sjljeh_is_longjmp_exception()
IsLJException = M.getOrInsertFunction("__llvm_sjljeh_is_longjmp_exception",
- Type::Int1Ty, (Type *)0);
+ Type::getInt1Ty(M.getContext()),
+ (Type *)0);
// int __llvm_sjljeh_get_longjmp_value()
GetLJValue = M.getOrInsertFunction("__llvm_sjljeh_get_longjmp_value",
- Type::Int32Ty, (Type *)0);
+ Type::getInt32Ty(M.getContext()),
+ (Type *)0);
return true;
}
@@ -258,7 +265,8 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
// throwing the exception for us.
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
{
- const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type* SBPTy =
+ PointerType::getUnqual(Type::getInt8Ty(Inst->getContext()));
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
// same parameters as "longjmp", except that the buffer is cast to a
@@ -279,7 +287,7 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
if (SVP.first)
BranchInst::Create(SVP.first->getParent(), Inst);
else
- new UnwindInst(Inst);
+ new UnwindInst(Inst->getContext(), Inst);
// Remove all insts after the branch/unwind inst. Go from back to front to
// avoid replaceAllUsesWith if possible.
@@ -310,7 +318,8 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func)
assert(Inst && "Couldn't find even ONE instruction in entry block!");
// Fill in the alloca and call to initialize the SJ map.
- const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type *SBPTy =
+ PointerType::getUnqual(Type::getInt8Ty(Func->getContext()));
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
CallInst::Create(InitSJMap, Map, "", Inst);
return SJMap[Func] = Map;
@@ -325,12 +334,13 @@ BasicBlock* LowerSetJmp::GetRethrowBB(Function* Func)
// The basic block we're going to jump to if we need to rethrow the
// exception.
- BasicBlock* Rethrow = BasicBlock::Create("RethrowExcept", Func);
+ BasicBlock* Rethrow =
+ BasicBlock::Create(Func->getContext(), "RethrowExcept", Func);
// Fill in the "Rethrow" BB with a call to rethrow the exception. This
// is the last instruction in the BB since at this point the runtime
// should exit this function and go to the next function.
- new UnwindInst(Rethrow);
+ new UnwindInst(Func->getContext(), Rethrow);
return RethrowBBMap[Func] = Rethrow;
}
@@ -341,7 +351,8 @@ LowerSetJmp::SwitchValuePair LowerSetJmp::GetSJSwitch(Function* Func,
{
if (SwitchValMap[Func].first) return SwitchValMap[Func];
- BasicBlock* LongJmpPre = BasicBlock::Create("LongJmpBlkPre", Func);
+ BasicBlock* LongJmpPre =
+ BasicBlock::Create(Func->getContext(), "LongJmpBlkPre", Func);
// Keep track of the preliminary basic block for some of the other
// transformations.
@@ -353,7 +364,8 @@ LowerSetJmp::SwitchValuePair LowerSetJmp::GetSJSwitch(Function* Func,
// The "decision basic block" gets the number associated with the
// setjmp call returning to switch on and the value returned by
// longjmp.
- BasicBlock* DecisionBB = BasicBlock::Create("LJDecisionBB", Func);
+ BasicBlock* DecisionBB =
+ BasicBlock::Create(Func->getContext(), "LJDecisionBB", Func);
BranchInst::Create(DecisionBB, Rethrow, Cond, LongJmpPre);
@@ -376,12 +388,14 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
Function* Func = ABlock->getParent();
// Add this setjmp to the setjmp map.
- const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type* SBPTy =
+ PointerType::getUnqual(Type::getInt8Ty(Inst->getContext()));
CastInst* BufPtr =
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
std::vector Args =
make_vector(GetSetJmpMap(Func), BufPtr,
- ConstantInt::get(Type::Int32Ty,SetJmpIDMap[Func]++), 0);
+ ConstantInt::get(Type::getInt32Ty(Inst->getContext()),
+ SetJmpIDMap[Func]++), 0);
CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst);
// We are guaranteed that there are no values live across basic blocks
@@ -424,14 +438,17 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
// This PHI node will be in the new block created from the
// splitBasicBlock call.
- PHINode* PHI = PHINode::Create(Type::Int32Ty, "SetJmpReturn", Inst);
+ PHINode* PHI = PHINode::Create(Type::getInt32Ty(Inst->getContext()),
+ "SetJmpReturn", Inst);
// Coming from a call to setjmp, the return is 0.
- PHI->addIncoming(Constant::getNullValue(Type::Int32Ty), ABlock);
+ PHI->addIncoming(Constant::getNullValue(Type::getInt32Ty(Inst->getContext())),
+ ABlock);
// Add the case for this setjmp's number...
SwitchValuePair SVP = GetSJSwitch(Func, GetRethrowBB(Func));
- SVP.first->addCase(ConstantInt::get(Type::Int32Ty, SetJmpIDMap[Func] - 1),
+ SVP.first->addCase(ConstantInt::get(Type::getInt32Ty(Inst->getContext()),
+ SetJmpIDMap[Func] - 1),
SetJmpContBlock);
// Value coming from the handling of the exception.
@@ -503,7 +520,8 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II)
BasicBlock* ExceptBB = II.getUnwindDest();
Function* Func = BB->getParent();
- BasicBlock* NewExceptBB = BasicBlock::Create("InvokeExcept", Func);
+ BasicBlock* NewExceptBB = BasicBlock::Create(II.getContext(),
+ "InvokeExcept", Func);
// If this is a longjmp exception, then branch to the preliminary BB of
// the longjmp exception handling. Otherwise, go to the old exception.
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index cb51bc3903f..74a903b0212 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -479,7 +479,7 @@ static LinkageCategory categorize(const Function *F) {
static void ThunkGToF(Function *F, Function *G) {
Function *NewG = Function::Create(G->getFunctionType(), G->getLinkage(), "",
G->getParent());
- BasicBlock *BB = BasicBlock::Create("", NewG);
+ BasicBlock *BB = BasicBlock::Create(F->getContext(), "", NewG);
std::vector Args;
unsigned i = 0;
@@ -498,13 +498,13 @@ static void ThunkGToF(Function *F, Function *G) {
CallInst *CI = CallInst::Create(F, Args.begin(), Args.end(), "", BB);
CI->setTailCall();
CI->setCallingConv(F->getCallingConv());
- if (NewG->getReturnType() == Type::VoidTy) {
- ReturnInst::Create(BB);
+ if (NewG->getReturnType() == Type::getVoidTy(F->getContext())) {
+ ReturnInst::Create(F->getContext(), BB);
} else if (CI->getType() != NewG->getReturnType()) {
Value *BCI = new BitCastInst(CI, NewG->getReturnType(), "", BB);
- ReturnInst::Create(BCI, BB);
+ ReturnInst::Create(F->getContext(), BCI, BB);
} else {
- ReturnInst::Create(CI, BB);
+ ReturnInst::Create(F->getContext(), CI, BB);
}
NewG->copyAttributesFrom(G);
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index d2a6530cd9e..5cc43a5fe44 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -215,7 +215,7 @@ bool PruneEH::SimplifyFunction(Function *F) {
// Remove the uncond branch and add an unreachable.
BB->getInstList().pop_back();
- new UnreachableInst(BB);
+ new UnreachableInst(BB->getContext(), BB);
DeleteBasicBlock(New); // Delete the new BB.
MadeChange = true;
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 0ef09916379..7b4ad276941 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -77,22 +77,26 @@ void RaiseAllocations::doInitialization(Module &M) {
// Get the expected prototype for malloc
const FunctionType *Malloc1Type =
- FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
- std::vector(1, Type::Int64Ty), false);
+ FunctionType::get(PointerType::getUnqual(Type::getInt8Ty(M.getContext())),
+ std::vector(1,
+ Type::getInt64Ty(M.getContext())), false);
// Chck to see if we got the expected malloc
if (TyWeHave != Malloc1Type) {
// Check to see if the prototype is wrong, giving us i8*(i32) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);'
const FunctionType *Malloc2Type =
- FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
- std::vector(1, Type::Int32Ty), false);
+ FunctionType::get(PointerType::getUnqual(
+ Type::getInt8Ty(M.getContext())),
+ std::vector(1,
+ Type::getInt32Ty(M.getContext())), false);
if (TyWeHave != Malloc2Type) {
// Check to see if the prototype is missing, giving us
// i8*(...) * malloc
// This handles the common declaration of: 'void *malloc();'
const FunctionType *Malloc3Type =
- FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(
+ Type::getInt8Ty(M.getContext())),
true);
if (TyWeHave != Malloc3Type)
// Give up
@@ -106,22 +110,24 @@ void RaiseAllocations::doInitialization(Module &M) {
const FunctionType* TyWeHave = FreeFunc->getFunctionType();
// Get the expected prototype for void free(i8*)
- const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
- std::vector(1, PointerType::getUnqual(Type::Int8Ty)),
- false);
+ const FunctionType *Free1Type =
+ FunctionType::get(Type::getVoidTy(M.getContext()),
+ std::vector(1, PointerType::getUnqual(
+ Type::getInt8Ty(M.getContext()))),
+ false);
if (TyWeHave != Free1Type) {
// Check to see if the prototype was forgotten, giving us
// void (...) * free
// This handles the common forward declaration of: 'void free();'
- const FunctionType* Free2Type = FunctionType::get(Type::VoidTy,
- true);
+ const FunctionType* Free2Type =
+ FunctionType::get(Type::getVoidTy(M.getContext()), true);
if (TyWeHave != Free2Type) {
// One last try, check to see if we can find free as
// int (...)* free. This handles the case where NOTHING was declared.
- const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
- true);
+ const FunctionType* Free3Type =
+ FunctionType::get(Type::getInt32Ty(M.getContext()), true);
if (TyWeHave != Free3Type) {
// Give up.
@@ -163,12 +169,15 @@ bool RaiseAllocations::runOnModule(Module &M) {
// If no prototype was provided for malloc, we may need to cast the
// source size.
- if (Source->getType() != Type::Int32Ty)
+ if (Source->getType() != Type::getInt32Ty(M.getContext()))
Source =
- CastInst::CreateIntegerCast(Source, Type::Int32Ty, false/*ZExt*/,
+ CastInst::CreateIntegerCast(Source,
+ Type::getInt32Ty(M.getContext()),
+ false/*ZExt*/,
"MallocAmtCast", I);
- MallocInst *MI = new MallocInst(Type::Int8Ty, Source, "", I);
+ MallocInst *MI = new MallocInst(Type::getInt8Ty(M.getContext()),
+ Source, "", I);
MI->takeName(I);
I->replaceAllUsesWith(MI);
@@ -220,7 +229,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
Value *Source = *CS.arg_begin();
if (!isa(Source->getType()))
Source = new IntToPtrInst(Source,
- PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::getInt8Ty(M.getContext())),
"FreePtrCast", I);
new FreeInst(Source, I);
@@ -230,7 +239,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
BranchInst::Create(II->getNormalDest(), I);
// Delete the old call site
- if (I->getType() != Type::VoidTy)
+ if (I->getType() != Type::getVoidTy(M.getContext()))
I->replaceAllUsesWith(UndefValue::get(I->getType()));
I->eraseFromParent();
Changed = true;
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index a2413597a3e..743dbf7fa26 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -94,7 +94,8 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
DEBUG(errs() << "SretPromotion: Looking at sret function "
<< F->getName() << "\n");
- assert (F->getReturnType() == Type::VoidTy && "Invalid function return type");
+ assert (F->getReturnType() == Type::getVoidTy(F->getContext()) &&
+ "Invalid function return type");
Function::arg_iterator AI = F->arg_begin();
const llvm::PointerType *FArgType = dyn_cast(AI->getType());
assert (FArgType && "Invalid sret parameter type");
@@ -124,7 +125,7 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
++BI;
if (isa(I)) {
Value *NV = new LoadInst(TheAlloca, "mrv.ld", I);
- ReturnInst *NR = ReturnInst::Create(NV, I);
+ ReturnInst *NR = ReturnInst::Create(F->getContext(), NV, I);
I->replaceAllUsesWith(NR);
I->eraseFromParent();
}
@@ -347,7 +348,7 @@ bool SRETPromotion::nestedStructType(const StructType *STy) {
unsigned Num = STy->getNumElements();
for (unsigned i = 0; i < Num; i++) {
const Type *Ty = STy->getElementType(i);
- if (!Ty->isSingleValueType() && Ty != Type::VoidTy)
+ if (!Ty->isSingleValueType() && Ty != Type::getVoidTy(STy->getContext()))
return true;
}
return false;
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp
index 91020755c21..029b8fe0b9d 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -63,7 +63,8 @@ bool FunctionProfiler::runOnModule(Module &M) {
if (!I->isDeclaration())
++NumFunctions;
- const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions);
+ const Type *ATy = ArrayType::get(Type::getInt32Ty(M.getContext()),
+ NumFunctions);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "FuncProfCounters");
@@ -109,7 +110,7 @@ bool BlockProfiler::runOnModule(Module &M) {
if (!I->isDeclaration())
NumBlocks += I->size();
- const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks);
+ const Type *ATy = ArrayType::get(Type::getInt32Ty(M.getContext()), NumBlocks);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "BlockProfCounters");
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index 283f863dc3d..2220bbfbe99 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -68,7 +68,7 @@ bool EdgeProfiler::runOnModule(Module &M) {
}
}
- const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
+ const Type *ATy = ArrayType::get(Type::getInt32Ty(M.getContext()), NumEdges);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "EdgeProfCounters");
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index dc34bf70a31..88a1d2a07c3 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -23,18 +23,22 @@
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
GlobalValue *Array) {
+ LLVMContext &Context = MainFn->getContext();
const Type *ArgVTy =
- PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
- const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty);
+ PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(Context)));
+ const PointerType *UIntPtr =
+ PointerType::getUnqual(Type::getInt32Ty(Context));
Module &M = *MainFn->getParent();
- Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
- ArgVTy, UIntPtr, Type::Int32Ty,
+ Constant *InitFn = M.getOrInsertFunction(FnName, Type::getInt32Ty(Context),
+ Type::getInt32Ty(Context),
+ ArgVTy, UIntPtr,
+ Type::getInt32Ty(Context),
(Type *)0);
// This could force argc and argv into programs that wouldn't otherwise have
// them, but instead we just pass null values in.
std::vector Args(4);
- Args[0] = Constant::getNullValue(Type::Int32Ty);
+ Args[0] = Constant::getNullValue(Type::getInt32Ty(Context));
Args[1] = Constant::getNullValue(ArgVTy);
// Skip over any allocas in the entry block.
@@ -42,7 +46,8 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
BasicBlock::iterator InsertPos = Entry->begin();
while (isa(InsertPos)) ++InsertPos;
- std::vector GEPIndices(2, Constant::getNullValue(Type::Int32Ty));
+ std::vector GEPIndices(2,
+ Constant::getNullValue(Type::getInt32Ty(Context)));
unsigned NumElements = 0;
if (Array) {
Args[2] = ConstantExpr::getGetElementPtr(Array, &GEPIndices[0],
@@ -54,7 +59,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
// pass null.
Args[2] = ConstantPointerNull::get(UIntPtr);
}
- Args[3] = ConstantInt::get(Type::Int32Ty, NumElements);
+ Args[3] = ConstantInt::get(Type::getInt32Ty(Context), NumElements);
Instruction *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(),
"newargc", InsertPos);
@@ -79,16 +84,18 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
AI = MainFn->arg_begin();
// If the program looked at argc, have it look at the return value of the
// init call instead.
- if (AI->getType() != Type::Int32Ty) {
+ if (AI->getType() != Type::getInt32Ty(Context)) {
Instruction::CastOps opcode;
if (!AI->use_empty()) {
opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true);
AI->replaceAllUsesWith(
CastInst::Create(opcode, InitCall, AI->getType(), "", InsertPos));
}
- opcode = CastInst::getCastOpcode(AI, true, Type::Int32Ty, true);
+ opcode = CastInst::getCastOpcode(AI, true,
+ Type::getInt32Ty(Context), true);
InitCall->setOperand(1,
- CastInst::Create(opcode, AI, Type::Int32Ty, "argc.cast", InitCall));
+ CastInst::Create(opcode, AI, Type::getInt32Ty(Context),
+ "argc.cast", InitCall));
} else {
AI->replaceAllUsesWith(InitCall);
InitCall->setOperand(1, AI);
@@ -105,10 +112,12 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
while (isa(InsertPos))
++InsertPos;
+ LLVMContext &Context = BB->getContext();
+
// Create the getelementptr constant expression
std::vector Indices(2);
- Indices[0] = Constant::getNullValue(Type::Int32Ty);
- Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
+ Indices[0] = Constant::getNullValue(Type::getInt32Ty(Context));
+ Indices[1] = ConstantInt::get(Type::getInt32Ty(Context), CounterNum);
Constant *ElementPtr =
ConstantExpr::getGetElementPtr(CounterArray, &Indices[0],
Indices.size());
@@ -116,7 +125,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum,
// Load, increment and store the value back.
Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos);
Value *NewVal = BinaryOperator::Create(Instruction::Add, OldVal,
- ConstantInt::get(Type::Int32Ty, 1),
+ ConstantInt::get(Type::getInt32Ty(Context), 1),
"NewFuncCounter", InsertPos);
new StoreInst(NewVal, ElementPtr, InsertPos);
}
diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp
index e2aa10924c1..9997d9dca98 100644
--- a/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -225,7 +225,8 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) {
//reset counter
BasicBlock* oldnext = t->getSuccessor(0);
- BasicBlock* resetblock = BasicBlock::Create("reset", oldnext->getParent(),
+ BasicBlock* resetblock = BasicBlock::Create(bb->getContext(),
+ "reset", oldnext->getParent(),
oldnext);
TerminatorInst* t2 = BranchInst::Create(oldnext, resetblock);
t->setSuccessor(0, resetblock);
@@ -298,7 +299,8 @@ void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) {
//reset counter
BasicBlock* oldnext = t->getSuccessor(0);
- BasicBlock* resetblock = BasicBlock::Create("reset", oldnext->getParent(),
+ BasicBlock* resetblock = BasicBlock::Create(bb->getContext(),
+ "reset", oldnext->getParent(),
oldnext);
TerminatorInst* t2 = BranchInst::Create(oldnext, resetblock);
t->setSuccessor(0, resetblock);
@@ -320,11 +322,12 @@ void CycleCounter::ProcessChoicePoint(BasicBlock* bb) {
CallInst* c = CallInst::Create(F, "rdcc", t);
BinaryOperator* b =
- BinaryOperator::CreateAnd(c, ConstantInt::get(Type::Int64Ty, rm),
+ BinaryOperator::CreateAnd(c,
+ ConstantInt::get(Type::getInt64Ty(bb->getContext()), rm),
"mrdcc", t);
ICmpInst *s = new ICmpInst(t, ICmpInst::ICMP_EQ, b,
- ConstantInt::get(Type::Int64Ty, 0),
+ ConstantInt::get(Type::getInt64Ty(bb->getContext()), 0),
"mrdccc");
t->setCondition(s);
@@ -350,8 +353,8 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu
// Create the getelementptr constant expression
std::vector Indices(2);
- Indices[0] = Constant::getNullValue(Type::Int32Ty);
- Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum);
+ Indices[0] = Constant::getNullValue(Type::getInt32Ty(BB->getContext()));
+ Indices[1] = ConstantInt::get(Type::getInt32Ty(BB->getContext()), CounterNum);
Constant *ElementPtr =ConstantExpr::getGetElementPtr(CounterArray,
&Indices[0], 2);
@@ -359,7 +362,7 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu
Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos);
profcode.insert(OldVal);
Value *NewVal = BinaryOperator::CreateAdd(OldVal,
- ConstantInt::get(Type::Int32Ty, 1),
+ ConstantInt::get(Type::getInt32Ty(BB->getContext()), 1),
"NewCounter", InsertPos);
profcode.insert(NewVal);
profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos));
@@ -382,7 +385,8 @@ Value* ProfilerRS::Translate(Value* v) {
if (bb == &bb->getParent()->getEntryBlock())
TransCache[bb] = bb; //don't translate entry block
else
- TransCache[bb] = BasicBlock::Create("dup_" + bb->getName(),
+ TransCache[bb] = BasicBlock::Create(v->getContext(),
+ "dup_" + bb->getName(),
bb->getParent(), NULL);
return TransCache[bb];
} else if (Instruction* i = dyn_cast(v)) {
@@ -471,16 +475,16 @@ void ProfilerRS::ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F)
//a:
Function::iterator BBN = src; ++BBN;
- BasicBlock* bbC = BasicBlock::Create("choice", &F, BBN);
+ BasicBlock* bbC = BasicBlock::Create(F.getContext(), "choice", &F, BBN);
//ChoicePoints.insert(bbC);
BBN = cast(Translate(src));
- BasicBlock* bbCp = BasicBlock::Create("choice", &F, ++BBN);
+ BasicBlock* bbCp = BasicBlock::Create(F.getContext(), "choice", &F, ++BBN);
ChoicePoints.insert(bbCp);
//b:
BranchInst::Create(cast(Translate(dst)), bbC);
BranchInst::Create(dst, cast(Translate(dst)),
- ConstantInt::get(Type::Int1Ty, true), bbCp);
+ ConstantInt::get(Type::getInt1Ty(src->getContext()), true), bbCp);
//c:
{
TerminatorInst* iB = src->getTerminator();
@@ -536,8 +540,8 @@ bool ProfilerRS::runOnFunction(Function& F) {
TerminatorInst* T = F.getEntryBlock().getTerminator();
ReplaceInstWithInst(T, BranchInst::Create(T->getSuccessor(0),
cast(
- Translate(T->getSuccessor(0))),
- ConstantInt::get(Type::Int1Ty, true)));
+ Translate(T->getSuccessor(0))),
+ ConstantInt::get(Type::getInt1Ty(F.getContext()), true)));
//do whatever is needed now that the function is duplicated
c->PrepFunction(&F);
@@ -560,10 +564,12 @@ bool ProfilerRS::runOnFunction(Function& F) {
bool ProfilerRS::doInitialization(Module &M) {
switch (RandomMethod) {
case GBV:
- c = new GlobalRandomCounter(M, Type::Int32Ty, (1 << 14) - 1);
+ c = new GlobalRandomCounter(M, Type::getInt32Ty(M.getContext()),
+ (1 << 14) - 1);
break;
case GBVO:
- c = new GlobalRandomCounterOpt(M, Type::Int32Ty, (1 << 14) - 1);
+ c = new GlobalRandomCounterOpt(M, Type::getInt32Ty(M.getContext()),
+ (1 << 14) - 1);
break;
case HOSTCC:
c = new CycleCounter(M, (1 << 14) - 1);
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 4fe9bcf17ef..9a59dca412f 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -599,7 +599,8 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
} else {
DEBUG(errs() << "CGP: SINKING nonlocal addrmode: " << AddrMode << " for "
<< *MemoryInst);
- const Type *IntPtrTy = TLI->getTargetData()->getIntPtrType();
+ const Type *IntPtrTy =
+ TLI->getTargetData()->getIntPtrType(AccessTy->getContext());
Value *Result = 0;
// Start with the scale value.
diff --git a/lib/Transforms/Scalar/CondPropagate.cpp b/lib/Transforms/Scalar/CondPropagate.cpp
index c85d0317d65..88b56527269 100644
--- a/lib/Transforms/Scalar/CondPropagate.cpp
+++ b/lib/Transforms/Scalar/CondPropagate.cpp
@@ -124,7 +124,7 @@ void CondProp::SimplifyBlock(BasicBlock *BB) {
// Succ is now dead, but we cannot delete it without potentially
// invalidating iterators elsewhere. Just insert an unreachable
// instruction in it and delete this block later on.
- new UnreachableInst(Succ);
+ new UnreachableInst(BB->getContext(), Succ);
DeadBlocks.push_back(Succ);
MadeChange = true;
}
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 21a52891933..c782f7da700 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1562,7 +1562,8 @@ bool GVN::performPRE(Function& F) {
Instruction *CurInst = BI++;
if (isa(CurInst) || isa(CurInst) ||
- isa(CurInst) || (CurInst->getType() == Type::VoidTy) ||
+ isa(CurInst) ||
+ (CurInst->getType() == Type::getVoidTy(F.getContext())) ||
CurInst->mayReadFromMemory() || CurInst->mayHaveSideEffects() ||
isa(CurInst))
continue;
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index b33c805903b..0f8a878376c 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -634,7 +634,8 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
// Check incoming value.
ConstantFP *InitValue = dyn_cast(PH->getIncomingValue(IncomingEdge));
if (!InitValue) return;
- uint64_t newInitValue = Type::Int32Ty->getPrimitiveSizeInBits();
+ uint64_t newInitValue =
+ Type::getInt32Ty(PH->getContext())->getPrimitiveSizeInBits();
if (!convertToInt(InitValue->getValueAPF(), &newInitValue))
return;
@@ -650,7 +651,8 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
IncrVIndex = 0;
IncrValue = dyn_cast(Incr->getOperand(IncrVIndex));
if (!IncrValue) return;
- uint64_t newIncrValue = Type::Int32Ty->getPrimitiveSizeInBits();
+ uint64_t newIncrValue =
+ Type::getInt32Ty(PH->getContext())->getPrimitiveSizeInBits();
if (!convertToInt(IncrValue->getValueAPF(), &newIncrValue))
return;
@@ -681,7 +683,7 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
EVIndex = 0;
EV = dyn_cast(EC->getOperand(EVIndex));
if (!EV) return;
- uint64_t intEV = Type::Int32Ty->getPrimitiveSizeInBits();
+ uint64_t intEV = Type::getInt32Ty(PH->getContext())->getPrimitiveSizeInBits();
if (!convertToInt(EV->getValueAPF(), &intEV))
return;
@@ -714,20 +716,22 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) {
if (NewPred == CmpInst::BAD_ICMP_PREDICATE) return;
// Insert new integer induction variable.
- PHINode *NewPHI = PHINode::Create(Type::Int32Ty,
+ PHINode *NewPHI = PHINode::Create(Type::getInt32Ty(PH->getContext()),
PH->getName()+".int", PH);
- NewPHI->addIncoming(ConstantInt::get(Type::Int32Ty, newInitValue),
+ NewPHI->addIncoming(ConstantInt::get(Type::getInt32Ty(PH->getContext()),
+ newInitValue),
PH->getIncomingBlock(IncomingEdge));
Value *NewAdd = BinaryOperator::CreateAdd(NewPHI,
- ConstantInt::get(Type::Int32Ty,
+ ConstantInt::get(Type::getInt32Ty(PH->getContext()),
newIncrValue),
Incr->getName()+".int", Incr);
NewPHI->addIncoming(NewAdd, PH->getIncomingBlock(BackEdge));
// The back edge is edge 1 of newPHI, whatever it may have been in the
// original PHI.
- ConstantInt *NewEV = ConstantInt::get(Type::Int32Ty, intEV);
+ ConstantInt *NewEV = ConstantInt::get(Type::getInt32Ty(PH->getContext()),
+ intEV);
Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV);
Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1));
ICmpInst *NewEC = new ICmpInst(EC->getParent()->getTerminator(),
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 04c225f7460..7a98b482a2e 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -435,7 +435,7 @@ static bool isOnlyUse(Value *V) {
static const Type *getPromotedType(const Type *Ty) {
if (const IntegerType* ITy = dyn_cast(Ty)) {
if (ITy->getBitWidth() < 32)
- return Type::Int32Ty;
+ return Type::getInt32Ty(Ty->getContext());
}
return Ty;
}
@@ -473,12 +473,14 @@ isEliminableCastPair(
unsigned Res = CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy,
DstTy,
- TD ? TD->getIntPtrType() : 0);
+ TD ? TD->getIntPtrType(CI->getContext()) : 0);
// We don't want to form an inttoptr or ptrtoint that converts to an integer
// type that differs from the pointer size.
- if ((Res == Instruction::IntToPtr && SrcTy != TD->getIntPtrType()) ||
- (Res == Instruction::PtrToInt && DstTy != TD->getIntPtrType()))
+ if ((Res == Instruction::IntToPtr &&
+ SrcTy != TD->getIntPtrType(CI->getContext())) ||
+ (Res == Instruction::PtrToInt &&
+ DstTy != TD->getIntPtrType(CI->getContext())))
Res = 0;
return Instruction::CastOps(Res);
@@ -1587,9 +1589,9 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
std::vector Elts;
for (unsigned i = 0; i < VWidth; ++i) {
if (UndefElts[i])
- Elts.push_back(UndefValue::get(Type::Int32Ty));
+ Elts.push_back(UndefValue::get(Type::getInt32Ty(*Context)));
else
- Elts.push_back(ConstantInt::get(Type::Int32Ty,
+ Elts.push_back(ConstantInt::get(Type::getInt32Ty(*Context),
Shuffle->getMaskValue(i)));
}
I->setOperand(2, ConstantVector::get(Elts));
@@ -1720,9 +1722,9 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
Value *RHS = II->getOperand(2);
// Extract the element as scalars.
LHS = InsertNewInstBefore(ExtractElementInst::Create(LHS,
- ConstantInt::get(Type::Int32Ty, 0U, false), "tmp"), *II);
+ ConstantInt::get(Type::getInt32Ty(*Context), 0U, false), "tmp"), *II);
RHS = InsertNewInstBefore(ExtractElementInst::Create(RHS,
- ConstantInt::get(Type::Int32Ty, 0U, false), "tmp"), *II);
+ ConstantInt::get(Type::getInt32Ty(*Context), 0U, false), "tmp"), *II);
switch (II->getIntrinsicID()) {
default: llvm_unreachable("Case stmts out of sync!");
@@ -1741,7 +1743,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts,
Instruction *New =
InsertElementInst::Create(
UndefValue::get(II->getType()), TmpV,
- ConstantInt::get(Type::Int32Ty, 0U, false), II->getName());
+ ConstantInt::get(Type::getInt32Ty(*Context), 0U, false), II->getName());
InsertNewInstBefore(New, *II);
AddSoonDeadInstToWorklist(*II, 0);
return New;
@@ -1912,7 +1914,7 @@ static Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
if (isa(TV) || isa(FV)) {
// Bool selects with constant operands can be folded to logical ops.
- if (SI->getType() == Type::Int1Ty) return 0;
+ if (SI->getType() == Type::getInt1Ty(*IC->getContext())) return 0;
Value *SelectTrueVal = FoldOperationIntoSelectOperand(Op, TV, IC);
Value *SelectFalseVal = FoldOperationIntoSelectOperand(Op, FV, IC);
@@ -2066,7 +2068,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
// zext(bool) + C -> bool ? C + 1 : C
if (ZExtInst *ZI = dyn_cast(LHS))
- if (ZI->getSrcTy() == Type::Int1Ty)
+ if (ZI->getSrcTy() == Type::getInt1Ty(*Context))
return SelectInst::Create(ZI->getOperand(0), AddOne(CI), CI);
}
@@ -2109,9 +2111,9 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
const Type *MiddleType = 0;
switch (Size) {
default: break;
- case 32: MiddleType = Type::Int32Ty; break;
- case 16: MiddleType = Type::Int16Ty; break;
- case 8: MiddleType = Type::Int8Ty; break;
+ case 32: MiddleType = Type::getInt32Ty(*Context); break;
+ case 16: MiddleType = Type::getInt16Ty(*Context); break;
+ case 8: MiddleType = Type::getInt8Ty(*Context); break;
}
if (MiddleType) {
Instruction *NewTrunc = new TruncInst(XorLHS, MiddleType, "sext");
@@ -2121,7 +2123,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
}
}
- if (I.getType() == Type::Int1Ty)
+ if (I.getType() == Type::getInt1Ty(*Context))
return BinaryOperator::CreateXor(LHS, RHS);
// X + X --> X << 1
@@ -2466,11 +2468,11 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
// C - zext(bool) -> bool ? C - 1 : C
if (ZExtInst *ZI = dyn_cast(Op1))
- if (ZI->getSrcTy() == Type::Int1Ty)
+ if (ZI->getSrcTy() == Type::getInt1Ty(*Context))
return SelectInst::Create(ZI->getOperand(0), SubOne(C), C);
}
- if (I.getType() == Type::Int1Ty)
+ if (I.getType() == Type::getInt1Ty(*Context))
return BinaryOperator::CreateXor(Op0, Op1);
if (BinaryOperator *Op1I = dyn_cast(Op1)) {
@@ -2726,7 +2728,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
}
}
- if (I.getType() == Type::Int1Ty)
+ if (I.getType() == Type::getInt1Ty(*Context))
return BinaryOperator::CreateAnd(Op0, I.getOperand(1));
// If one of the operands of the multiply is a cast from a boolean value, then
@@ -2735,11 +2737,11 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) {
// formed.
CastInst *BoolCast = 0;
if (ZExtInst *CI = dyn_cast(Op0))
- if (CI->getOperand(0)->getType() == Type::Int1Ty)
+ if (CI->getOperand(0)->getType() == Type::getInt1Ty(*Context))
BoolCast = CI;
if (!BoolCast)
if (ZExtInst *CI = dyn_cast(I.getOperand(1)))
- if (CI->getOperand(0)->getType() == Type::Int1Ty)
+ if (CI->getOperand(0)->getType() == Type::getInt1Ty(*Context))
BoolCast = CI;
if (BoolCast) {
if (ICmpInst *SCI = dyn_cast(BoolCast->getOperand(0))) {
@@ -2974,7 +2976,7 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) {
return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType()));
// It can't be division by zero, hence it must be division by one.
- if (I.getType() == Type::Int1Ty)
+ if (I.getType() == Type::getInt1Ty(*Context))
return ReplaceInstUsesWith(I, Op0);
if (ConstantVector *Op1V = dyn_cast(Op1)) {
@@ -5335,7 +5337,7 @@ static bool AddWithOverflow(Constant *&Result, Constant *In1,
if (const VectorType *VTy = dyn_cast(In1->getType())) {
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
- Constant *Idx = ConstantInt::get(Type::Int32Ty, i);
+ Constant *Idx = ConstantInt::get(Type::getInt32Ty(*Context), i);
if (HasAddOverflow(ExtractElement(Result, Idx, Context),
ExtractElement(In1, Idx, Context),
ExtractElement(In2, Idx, Context),
@@ -5371,7 +5373,7 @@ static bool SubWithOverflow(Constant *&Result, Constant *In1,
if (const VectorType *VTy = dyn_cast(In1->getType())) {
for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
- Constant *Idx = ConstantInt::get(Type::Int32Ty, i);
+ Constant *Idx = ConstantInt::get(Type::getInt32Ty(*Context), i);
if (HasSubOverflow(ExtractElement(Result, Idx, Context),
ExtractElement(In1, Idx, Context),
ExtractElement(In2, Idx, Context),
@@ -5392,7 +5394,7 @@ static bool SubWithOverflow(Constant *&Result, Constant *In1,
static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
TargetData &TD = *IC.getTargetData();
gep_type_iterator GTI = gep_type_begin(GEP);
- const Type *IntPtrTy = TD.getIntPtrType();
+ const Type *IntPtrTy = TD.getIntPtrType(I.getContext());
LLVMContext *Context = IC.getContext();
Value *Result = Constant::getNullValue(IntPtrTy);
@@ -5542,7 +5544,8 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I,
// we don't need to bother extending: the extension won't affect where the
// computation crosses zero.
if (VariableIdx->getType()->getPrimitiveSizeInBits() > IntPtrWidth)
- VariableIdx = new TruncInst(VariableIdx, TD.getIntPtrType(),
+ VariableIdx = new TruncInst(VariableIdx,
+ TD.getIntPtrType(VariableIdx->getContext()),
VariableIdx->getName(), &I);
return VariableIdx;
}
@@ -5563,7 +5566,7 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I,
return 0;
// Okay, we can do this evaluation. Start by converting the index to intptr.
- const Type *IntPtrTy = TD.getIntPtrType();
+ const Type *IntPtrTy = TD.getIntPtrType(VariableIdx->getContext());
if (VariableIdx->getType() != IntPtrTy)
VariableIdx = CastInst::CreateIntegerCast(VariableIdx, IntPtrTy,
true /*SExt*/,
@@ -5661,7 +5664,7 @@ Instruction *InstCombiner::FoldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
if (NumDifferences == 0) // SAME GEP?
return ReplaceInstUsesWith(I, // No comparison is needed here.
- ConstantInt::get(Type::Int1Ty,
+ ConstantInt::get(Type::getInt1Ty(*Context),
ICmpInst::isTrueWhenEqual(Cond)));
else if (NumDifferences == 1) {
@@ -5923,7 +5926,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) {
}
if (isa(Op1)) // fcmp pred X, undef -> undef
- return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
+ return ReplaceInstUsesWith(I, UndefValue::get(Type::getInt1Ty(*Context)));
// Handle fcmp with constant RHS
if (Constant *RHSC = dyn_cast(Op1)) {
@@ -5993,11 +5996,11 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// icmp X, X
if (Op0 == Op1)
- return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
+ return ReplaceInstUsesWith(I, ConstantInt::get(Type::getInt1Ty(*Context),
I.isTrueWhenEqual()));
if (isa(Op1)) // X icmp undef -> undef
- return ReplaceInstUsesWith(I, UndefValue::get(Type::Int1Ty));
+ return ReplaceInstUsesWith(I, UndefValue::get(Type::getInt1Ty(*Context)));
// icmp , - Global/Stack value
// addresses never equal each other! We already know that Op0 != Op1.
@@ -6005,11 +6008,11 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
isa(Op0)) &&
(isa(Op1) || isa(Op1) ||
isa(Op1)))
- return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
+ return ReplaceInstUsesWith(I, ConstantInt::get(Type::getInt1Ty(*Context),
!I.isTrueWhenEqual()));
// icmp's with boolean values can always be turned into bitwise operations
- if (Ty == Type::Int1Ty) {
+ if (Ty == Type::getInt1Ty(*Context)) {
switch (I.getPredicate()) {
default: llvm_unreachable("Invalid icmp instruction!");
case ICmpInst::ICMP_EQ: { // icmp eq i1 A, B -> ~(A^B)
@@ -6348,7 +6351,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
// can assume it is successful and remove the malloc.
if (LHSI->hasOneUse() && isa(RHSC)) {
AddToWorkList(LHSI);
- return ReplaceInstUsesWith(I, ConstantInt::get(Type::Int1Ty,
+ return ReplaceInstUsesWith(I, ConstantInt::get(Type::getInt1Ty(*Context),
!I.isTrueWhenEqual()));
}
break;
@@ -6933,7 +6936,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
ShAmt);
if (Comp != RHS) {// Comparing against a bit that we know is zero.
bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
- Constant *Cst = ConstantInt::get(Type::Int1Ty, IsICMP_NE);
+ Constant *Cst = ConstantInt::get(Type::getInt1Ty(*Context), IsICMP_NE);
return ReplaceInstUsesWith(ICI, Cst);
}
@@ -6997,7 +7000,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
if (Comp != RHSV) { // Comparing against a bit that we know is zero.
bool IsICMP_NE = ICI.getPredicate() == ICmpInst::ICMP_NE;
- Constant *Cst = ConstantInt::get(Type::Int1Ty, IsICMP_NE);
+ Constant *Cst = ConstantInt::get(Type::getInt1Ty(*Context), IsICMP_NE);
return ReplaceInstUsesWith(ICI, Cst);
}
@@ -7139,7 +7142,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
Constant *NotCI = ConstantExpr::getNot(RHS);
if (!ConstantExpr::getAnd(BOC, NotCI)->isNullValue())
return ReplaceInstUsesWith(ICI,
- ConstantInt::get(Type::Int1Ty,
+ ConstantInt::get(Type::getInt1Ty(*Context),
isICMP_NE));
}
break;
@@ -7150,7 +7153,7 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
// comparison can never succeed!
if ((RHSV & ~BOC->getValue()) != 0)
return ReplaceInstUsesWith(ICI,
- ConstantInt::get(Type::Int1Ty,
+ ConstantInt::get(Type::getInt1Ty(*Context),
isICMP_NE));
// If we have ((X & C) == C), turn it into ((X & C) != 0).
@@ -7692,7 +7695,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
case 32 :
case 64 :
case 128:
- SExtType = IntegerType::get(Ty->getBitWidth() - ShiftAmt1);
+ SExtType = IntegerType::get(*Context, Ty->getBitWidth() - ShiftAmt1);
break;
default: break;
}
@@ -7774,11 +7777,11 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
///
static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
int &Offset, LLVMContext *Context) {
- assert(Val->getType() == Type::Int32Ty && "Unexpected allocation size type!");
+ assert(Val->getType() == Type::getInt32Ty(*Context) && "Unexpected allocation size type!");
if (ConstantInt *CI = dyn_cast(Val)) {
Offset = CI->getZExtValue();
Scale = 0;
- return ConstantInt::get(Type::Int32Ty, 0);
+ return ConstantInt::get(Type::getInt32Ty(*Context), 0);
} else if (BinaryOperator *I = dyn_cast(Val)) {
if (ConstantInt *RHS = dyn_cast(I->getOperand(1))) {
if (I->getOpcode() == Instruction::Shl) {
@@ -7875,7 +7878,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
Amt = NumElements;
} else {
// If the allocation size is constant, form a constant mul expression
- Amt = ConstantInt::get(Type::Int32Ty, Scale);
+ Amt = ConstantInt::get(Type::getInt32Ty(*Context), Scale);
if (isa(NumElements))
Amt = ConstantExpr::getMul(cast(NumElements),
cast(Amt));
@@ -7887,7 +7890,7 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI,
}
if (int Offset = (AllocElTySize*ArrayOffset)/CastElTySize) {
- Value *Off = ConstantInt::get(Type::Int32Ty, Offset, true);
+ Value *Off = ConstantInt::get(Type::getInt32Ty(*Context), Offset, true);
Instruction *Tmp = BinaryOperator::CreateAdd(Amt, Off, "tmp");
Amt = InsertNewInstBefore(Tmp, AI);
}
@@ -8173,7 +8176,7 @@ static const Type *FindElementAtOffset(const Type *Ty, int64_t Offset,
// Start with the index over the outer type. Note that the type size
// might be zero (even if the offset isn't zero) if the indexed type
// is something like [0 x {int, int}]
- const Type *IntPtrTy = TD->getIntPtrType();
+ const Type *IntPtrTy = TD->getIntPtrType(*Context);
int64_t FirstIdx = 0;
if (int64_t TySize = TD->getTypeAllocSize(Ty)) {
FirstIdx = Offset/TySize;
@@ -8202,7 +8205,7 @@ static const Type *FindElementAtOffset(const Type *Ty, int64_t Offset,
"Offset must stay within the indexed type");
unsigned Elt = SL->getElementContainingOffset(Offset);
- NewIndices.push_back(ConstantInt::get(Type::Int32Ty, Elt));
+ NewIndices.push_back(ConstantInt::get(Type::getInt32Ty(*Context), Elt));
Offset -= SL->getElementOffset(Elt);
Ty = STy->getElementType(Elt);
@@ -8579,7 +8582,7 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *ICI, Instruction &CI,
if (Op1CV != 0 && (Op1CV != KnownZeroMask)) {
// (X&4) == 2 --> false
// (X&4) != 2 --> true
- Constant *Res = ConstantInt::get(Type::Int1Ty, isNE);
+ Constant *Res = ConstantInt::get(Type::getInt1Ty(*Context), isNE);
Res = ConstantExpr::getZExt(Res, CI.getType());
return ReplaceInstUsesWith(CI, Res);
}
@@ -8708,7 +8711,7 @@ Instruction *InstCombiner::visitSExt(SExtInst &CI) {
Value *Src = CI.getOperand(0);
// Canonicalize sign-extend from i1 to a select.
- if (Src->getType() == Type::Int1Ty)
+ if (Src->getType() == Type::getInt1Ty(*Context))
return SelectInst::Create(Src,
Constant::getAllOnesValue(CI.getType()),
Constant::getNullValue(CI.getType()));
@@ -8796,12 +8799,12 @@ static Value *LookThroughFPExtensions(Value *V, LLVMContext *Context) {
// that can accurately represent it. This allows us to turn
// (float)((double)X+2.0) into x+2.0f.
if (ConstantFP *CFP = dyn_cast(V)) {
- if (CFP->getType() == Type::PPC_FP128Ty)
+ if (CFP->getType() == Type::getPPC_FP128Ty(*Context))
return V; // No constant folding of this.
// See if the value can be truncated to float and then reextended.
if (Value *V = FitsInFPType(CFP, APFloat::IEEEsingle, Context))
return V;
- if (CFP->getType() == Type::DoubleTy)
+ if (CFP->getType() == Type::getDoubleTy(*Context))
return V; // Won't shrink.
if (Value *V = FitsInFPType(CFP, APFloat::IEEEdouble, Context))
return V;
@@ -8912,7 +8915,7 @@ Instruction *InstCombiner::visitPtrToInt(PtrToIntInst &CI) {
if (TD &&
CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
Value *P = InsertNewInstBefore(new PtrToIntInst(CI.getOperand(0),
- TD->getIntPtrType(),
+ TD->getIntPtrType(CI.getContext()),
"tmp"), CI);
return new TruncInst(P, CI.getType());
}
@@ -8930,7 +8933,7 @@ Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) {
CI.getOperand(0)->getType()->getScalarSizeInBits() >
TD->getPointerSizeInBits()) {
Value *P = InsertNewInstBefore(new TruncInst(CI.getOperand(0),
- TD->getIntPtrType(),
+ TD->getIntPtrType(CI.getContext()),
"tmp"), CI);
return new IntToPtrInst(P, CI.getType());
}
@@ -8981,7 +8984,7 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
// If the source and destination are pointers, and this cast is equivalent
// to a getelementptr X, 0, 0, 0... turn it into the appropriate gep.
// This can enhance SROA and other transforms that want type-safe pointers.
- Constant *ZeroUInt = Constant::getNullValue(Type::Int32Ty);
+ Constant *ZeroUInt = Constant::getNullValue(Type::getInt32Ty(*Context));
unsigned NumZeros = 0;
while (SrcElTy != DstElTy &&
isa(SrcElTy) && !isa(SrcElTy) &&
@@ -9007,7 +9010,7 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
Value *Elem = InsertCastBefore(Instruction::BitCast, Src,
DestVTy->getElementType(), CI);
return InsertElementInst::Create(UndefValue::get(DestTy), Elem,
- Constant::getNullValue(Type::Int32Ty));
+ Constant::getNullValue(Type::getInt32Ty(*Context)));
}
// FIXME: Canonicalize bitcast(insertelement) -> insertelement(bitcast)
}
@@ -9017,7 +9020,7 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) {
if (SrcVTy->getNumElements() == 1) {
if (!isa(DestTy)) {
Instruction *Elem =
- ExtractElementInst::Create(Src, Constant::getNullValue(Type::Int32Ty));
+ ExtractElementInst::Create(Src, Constant::getNullValue(Type::getInt32Ty(*Context)));
InsertNewInstBefore(Elem, CI);
return CastInst::Create(Instruction::BitCast, Elem, DestTy);
}
@@ -9401,7 +9404,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
return ReplaceInstUsesWith(SI, FalseVal);
}
- if (SI.getType() == Type::Int1Ty) {
+ if (SI.getType() == Type::getInt1Ty(*Context)) {
if (ConstantInt *C = dyn_cast(TrueVal)) {
if (C->getZExtValue()) {
// Change: A = select B, true, C --> A = or B, C
@@ -9708,7 +9711,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
// Use an integer load+store unless we can find something better.
Type *NewPtrTy =
- PointerType::getUnqual(IntegerType::get(Size<<3));
+ PointerType::getUnqual(IntegerType::get(*Context, Size<<3));
// Memcpy forces the use of i8* for the source and destination. That means
// that if you're using memcpy to move one double around, you'll get a cast
@@ -9769,7 +9772,7 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
// Extract the length and alignment and fill if they are constant.
ConstantInt *LenC = dyn_cast(MI->getLength());
ConstantInt *FillC = dyn_cast(MI->getValue());
- if (!LenC || !FillC || FillC->getType() != Type::Int8Ty)
+ if (!LenC || !FillC || FillC->getType() != Type::getInt8Ty(*Context))
return 0;
uint64_t Len = LenC->getZExtValue();
Alignment = MI->getAlignment();
@@ -9779,7 +9782,7 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
// memset(s,c,n) -> store s, c (for n=1,2,4,8)
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
- const Type *ITy = IntegerType::get(Len*8); // n=1 -> i8.
+ const Type *ITy = IntegerType::get(*Context, Len*8); // n=1 -> i8.
Value *Dest = MI->getDest();
Dest = InsertBitCastBefore(Dest, PointerType::getUnqual(ITy), *MI);
@@ -9962,14 +9965,14 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
if (ExtractedElts[Idx] == 0) {
Instruction *Elt =
ExtractElementInst::Create(Idx < 16 ? Op0 : Op1,
- ConstantInt::get(Type::Int32Ty, Idx&15, false), "tmp");
+ ConstantInt::get(Type::getInt32Ty(*Context), Idx&15, false), "tmp");
InsertNewInstBefore(Elt, CI);
ExtractedElts[Idx] = Elt;
}
// Insert this value into the result vector.
Result = InsertElementInst::Create(Result, ExtractedElts[Idx],
- ConstantInt::get(Type::Int32Ty, i, false),
+ ConstantInt::get(Type::getInt32Ty(*Context), i, false),
"tmp");
InsertNewInstBefore(cast