aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp9
-rw-r--r--lib/AsmParser/LLParser.cpp4
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp6
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp3
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp83
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp3
-rw-r--r--lib/CodeGen/ShadowStackGC.cpp56
-rw-r--r--lib/CodeGen/StackProtector.cpp2
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp18
-rw-r--r--lib/Target/ARM/ARMBaseRegisterInfo.cpp5
-rw-r--r--lib/Target/ARM/ARMISelDAGToDAG.cpp4
-rw-r--r--lib/Target/ARM/Thumb1RegisterInfo.cpp5
-rw-r--r--lib/Target/ARM/Thumb2RegisterInfo.cpp5
-rw-r--r--lib/Target/Alpha/AlphaISelDAGToDAG.cpp3
-rw-r--r--lib/Target/CBackend/CBackend.cpp2
-rw-r--r--lib/Target/XCore/XCoreISelDAGToDAG.cpp4
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp9
-rw-r--r--lib/Transforms/IPO/IndMemRemoval.cpp8
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp4
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp3
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp2
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp2
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp28
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp2
-rw-r--r--lib/Transforms/Scalar/LICM.cpp5
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp2
-rw-r--r--lib/Transforms/Scalar/Reg2Mem.cpp4
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp11
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp2
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp5
-rw-r--r--lib/Transforms/Utils/DemoteRegToStack.cpp16
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp5
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp24
-rw-r--r--lib/VMCore/Constants.cpp53
-rw-r--r--lib/VMCore/Instructions.cpp94
-rw-r--r--lib/VMCore/LLVMContext.cpp49
37 files changed, 264 insertions, 278 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 0c17f14892..7c68f8920e 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -196,7 +196,8 @@ const SCEV *ScalarEvolution::getConstant(const APInt& Val) {
const SCEV *
ScalarEvolution::getConstant(const Type *Ty, uint64_t V, bool isSigned) {
- return getConstant(ConstantInt::get(cast<IntegerType>(Ty), V, isSigned));
+ return getConstant(
+ Context->getConstantInt(cast<IntegerType>(Ty), V, isSigned));
}
const Type *SCEVConstant::getType() const { return V->getType(); }
@@ -2115,7 +2116,7 @@ const SCEV *ScalarEvolution::getSCEV(Value *V) {
/// specified signed integer value and return a SCEV for the constant.
const SCEV *ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) {
const IntegerType *ITy = cast<IntegerType>(getEffectiveSCEVType(Ty));
- return getConstant(ConstantInt::get(ITy, Val));
+ return getConstant(Context->getConstantInt(ITy, Val));
}
/// getNegativeSCEV - Return a SCEV corresponding to -V = -1*V
@@ -3537,8 +3538,8 @@ ScalarEvolution::ComputeLoadConstantCompareBackedgeTakenCount(
unsigned MaxSteps = MaxBruteForceIterations;
for (unsigned IterationNum = 0; IterationNum != MaxSteps; ++IterationNum) {
- ConstantInt *ItCst =
- ConstantInt::get(cast<IntegerType>(IdxExpr->getType()), IterationNum);
+ ConstantInt *ItCst = Context->getConstantInt(
+ cast<IntegerType>(IdxExpr->getType()), IterationNum);
ConstantInt *Val = EvaluateConstantChrecAtConstant(IdxExpr, ItCst, *this);
// Form the GEP offset.
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 080575df84..1c8156adcf 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -3182,9 +3182,9 @@ bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS,
return Error(SizeLoc, "element count must be i32");
if (Opc == Instruction::Malloc)
- Inst = new MallocInst(Ty, Size, Alignment);
+ Inst = new MallocInst(Context, Ty, Size, Alignment);
else
- Inst = new AllocaInst(Ty, Size, Alignment);
+ Inst = new AllocaInst(Context, Ty, Size, Alignment);
return false;
}
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index e4d3c5e1ad..b15355a8ca 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1817,7 +1817,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
Value *Size = getFnValueByID(Record[1], Type::Int32Ty);
unsigned Align = Record[2];
if (!Ty || !Size) return Error("Invalid MALLOC record");
- I = new MallocInst(Ty->getElementType(), Size, (1 << Align) >> 1);
+ I = new MallocInst(Context, Ty->getElementType(), Size,
+ (1 << Align) >> 1);
break;
}
case bitc::FUNC_CODE_INST_FREE: { // FREE: [op, opty]
@@ -1837,7 +1838,8 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
Value *Size = getFnValueByID(Record[1], Type::Int32Ty);
unsigned Align = Record[2];
if (!Ty || !Size) return Error("Invalid ALLOCA record");
- I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
+ I = new AllocaInst(Context, Ty->getElementType(), Size,
+ (1 << Align) >> 1);
break;
}
case bitc::FUNC_CODE_INST_LOAD: { // LOAD: [opty, op, align, vol]
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index 4ef43fde50..5fa8dcea34 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -354,7 +354,8 @@ Instruction *DwarfEHPrepare::CreateValueLoad(BasicBlock *BB) {
// Create the temporary if we didn't already.
if (!ExceptionValueVar) {
- ExceptionValueVar = new AllocaInst(PointerType::getUnqual(Type::Int8Ty),
+ ExceptionValueVar = new AllocaInst(*Context,
+ PointerType::getUnqual(Type::Int8Ty),
"eh.value", F->begin()->begin());
++NumStackTempsIntroduced;
}
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 6ec3a629fb..455adc44a1 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -149,7 +149,7 @@ void IntrinsicLowering::AddPrototypes(Module &M) {
/// LowerBSWAP - Emit the code to lower bswap of V before the specified
/// instruction IP.
-static Value *LowerBSWAP(Value *V, Instruction *IP) {
+static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) {
assert(V->getType()->isInteger() && "Can't bswap a non-integer type!");
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
@@ -159,25 +159,27 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) {
switch(BitSize) {
default: llvm_unreachable("Unhandled type size of value to byteswap!");
case 16: {
- Value *Tmp1 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
+ Value *Tmp1 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
"bswap.2");
- Value *Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
+ Value *Tmp2 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
"bswap.1");
V = Builder.CreateOr(Tmp1, Tmp2, "bswap.i16");
break;
}
case 32: {
- Value *Tmp4 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 24),
+ Value *Tmp4 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 24),
"bswap.4");
- Value *Tmp3 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
+ Value *Tmp3 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
"bswap.3");
- Value *Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
+ Value *Tmp2 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
"bswap.2");
- Value *Tmp1 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 24),
+ Value *Tmp1 = Builder.CreateLShr(V,Context.getConstantInt(V->getType(), 24),
"bswap.1");
- Tmp3 = Builder.CreateAnd(Tmp3, ConstantInt::get(Type::Int32Ty, 0xFF0000),
+ Tmp3 = Builder.CreateAnd(Tmp3,
+ Context.getConstantInt(Type::Int32Ty, 0xFF0000),
"bswap.and3");
- Tmp2 = Builder.CreateAnd(Tmp2, ConstantInt::get(Type::Int32Ty, 0xFF00),
+ Tmp2 = Builder.CreateAnd(Tmp2,
+ Context.getConstantInt(Type::Int32Ty, 0xFF00),
"bswap.and2");
Tmp4 = Builder.CreateOr(Tmp4, Tmp3, "bswap.or1");
Tmp2 = Builder.CreateOr(Tmp2, Tmp1, "bswap.or2");
@@ -185,41 +187,44 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) {
break;
}
case 64: {
- Value *Tmp8 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 56),
+ Value *Tmp8 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 56),
"bswap.8");
- Value *Tmp7 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 40),
+ Value *Tmp7 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 40),
"bswap.7");
- Value *Tmp6 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 24),
+ Value *Tmp6 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 24),
"bswap.6");
- Value *Tmp5 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
+ Value *Tmp5 = Builder.CreateShl(V, Context.getConstantInt(V->getType(), 8),
"bswap.5");
- Value* Tmp4 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 8),
+ Value* Tmp4 = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 8),
"bswap.4");
- Value* Tmp3 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 24),
+ Value* Tmp3 = Builder.CreateLShr(V,
+ Context.getConstantInt(V->getType(), 24),
"bswap.3");
- Value* Tmp2 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 40),
+ Value* Tmp2 = Builder.CreateLShr(V,
+ Context.getConstantInt(V->getType(), 40),
"bswap.2");
- Value* Tmp1 = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 56),
+ Value* Tmp1 = Builder.CreateLShr(V,
+ Context.getConstantInt(V->getType(), 56),
"bswap.1");
Tmp7 = Builder.CreateAnd(Tmp7,
- ConstantInt::get(Type::Int64Ty,
+ Context.getConstantInt(Type::Int64Ty,
0xFF000000000000ULL),
"bswap.and7");
Tmp6 = Builder.CreateAnd(Tmp6,
- ConstantInt::get(Type::Int64Ty,
+ Context.getConstantInt(Type::Int64Ty,
0xFF0000000000ULL),
"bswap.and6");
Tmp5 = Builder.CreateAnd(Tmp5,
- ConstantInt::get(Type::Int64Ty, 0xFF00000000ULL),
+ Context.getConstantInt(Type::Int64Ty, 0xFF00000000ULL),
"bswap.and5");
Tmp4 = Builder.CreateAnd(Tmp4,
- ConstantInt::get(Type::Int64Ty, 0xFF000000ULL),
+ Context.getConstantInt(Type::Int64Ty, 0xFF000000ULL),
"bswap.and4");
Tmp3 = Builder.CreateAnd(Tmp3,
- ConstantInt::get(Type::Int64Ty, 0xFF0000ULL),
+ Context.getConstantInt(Type::Int64Ty, 0xFF0000ULL),
"bswap.and3");
Tmp2 = Builder.CreateAnd(Tmp2,
- ConstantInt::get(Type::Int64Ty, 0xFF00ULL),
+ Context.getConstantInt(Type::Int64Ty, 0xFF00ULL),
"bswap.and2");
Tmp8 = Builder.CreateOr(Tmp8, Tmp7, "bswap.or1");
Tmp6 = Builder.CreateOr(Tmp6, Tmp5, "bswap.or2");
@@ -236,7 +241,7 @@ static Value *LowerBSWAP(Value *V, Instruction *IP) {
/// LowerCTPOP - Emit the code to lower ctpop of V before the specified
/// instruction IP.
-static Value *LowerCTPOP(Value *V, Instruction *IP) {
+static Value *LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP) {
assert(V->getType()->isInteger() && "Can't ctpop a non-integer type!");
static const uint64_t MaskValues[6] = {
@@ -249,23 +254,23 @@ static Value *LowerCTPOP(Value *V, Instruction *IP) {
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
unsigned WordSize = (BitSize + 63) / 64;
- Value *Count = ConstantInt::get(V->getType(), 0);
+ Value *Count = Context.getConstantInt(V->getType(), 0);
for (unsigned n = 0; n < WordSize; ++n) {
Value *PartValue = V;
for (unsigned i = 1, ct = 0; i < (BitSize>64 ? 64 : BitSize);
i <<= 1, ++ct) {
- Value *MaskCst = ConstantInt::get(V->getType(), MaskValues[ct]);
+ Value *MaskCst = Context.getConstantInt(V->getType(), MaskValues[ct]);
Value *LHS = Builder.CreateAnd(PartValue, MaskCst, "cppop.and1");
Value *VShift = Builder.CreateLShr(PartValue,
- ConstantInt::get(V->getType(), i),
+ Context.getConstantInt(V->getType(), i),
"ctpop.sh");
Value *RHS = Builder.CreateAnd(VShift, MaskCst, "cppop.and2");
PartValue = Builder.CreateAdd(LHS, RHS, "ctpop.step");
}
Count = Builder.CreateAdd(PartValue, Count, "ctpop.part");
if (BitSize > 64) {
- V = Builder.CreateLShr(V, ConstantInt::get(V->getType(), 64),
+ V = Builder.CreateLShr(V, Context.getConstantInt(V->getType(), 64),
"ctpop.part.sh");
BitSize -= 64;
}
@@ -276,19 +281,19 @@ static Value *LowerCTPOP(Value *V, Instruction *IP) {
/// LowerCTLZ - Emit the code to lower ctlz of V before the specified
/// instruction IP.
-static Value *LowerCTLZ(Value *V, Instruction *IP) {
+static Value *LowerCTLZ(LLVMContext &Context, Value *V, Instruction *IP) {
IRBuilder<> Builder(IP->getParent(), IP);
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
for (unsigned i = 1; i < BitSize; i <<= 1) {
- Value *ShVal = ConstantInt::get(V->getType(), i);
+ Value *ShVal = Context.getConstantInt(V->getType(), i);
ShVal = Builder.CreateLShr(V, ShVal, "ctlz.sh");
V = Builder.CreateOr(V, ShVal, "ctlz.step");
}
V = Builder.CreateNot(V);
- return LowerCTPOP(V, IP);
+ return LowerCTPOP(Context, V, IP);
}
static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
@@ -357,15 +362,15 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break;
}
case Intrinsic::ctpop:
- CI->replaceAllUsesWith(LowerCTPOP(CI->getOperand(1), CI));
+ CI->replaceAllUsesWith(LowerCTPOP(*Context, CI->getOperand(1), CI));
break;
case Intrinsic::bswap:
- CI->replaceAllUsesWith(LowerBSWAP(CI->getOperand(1), CI));
+ CI->replaceAllUsesWith(LowerBSWAP(*Context, CI->getOperand(1), CI));
break;
case Intrinsic::ctlz:
- CI->replaceAllUsesWith(LowerCTLZ(CI->getOperand(1), CI));
+ CI->replaceAllUsesWith(LowerCTLZ(*Context, CI->getOperand(1), CI));
break;
case Intrinsic::cttz: {
@@ -373,9 +378,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
Value *Src = CI->getOperand(1);
Value *NotSrc = Builder.CreateNot(Src);
NotSrc->setName(Src->getName() + ".not");
- Value *SrcM1 = ConstantInt::get(Src->getType(), 1);
+ Value *SrcM1 = Context->getConstantInt(Src->getType(), 1);
SrcM1 = Builder.CreateSub(Src, SrcM1);
- Src = LowerCTPOP(Builder.CreateAnd(NotSrc, SrcM1), CI);
+ Src = LowerCTPOP(*Context, Builder.CreateAnd(NotSrc, SrcM1), CI);
CI->replaceAllUsesWith(Src);
break;
}
@@ -409,7 +414,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(Context->getConstantInt(Type::Int64Ty, 0));
break;
}
@@ -429,7 +434,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::eh_typeid_for_i32:
case Intrinsic::eh_typeid_for_i64:
// Return something different to eh_selector.
- CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
+ CI->replaceAllUsesWith(Context->getConstantInt(CI->getType(), 1));
break;
case Intrinsic::var_annotation:
@@ -501,7 +506,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::flt_rounds:
// Lower to "round to the nearest"
if (CI->getType() != Type::VoidTy)
- CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
+ CI->replaceAllUsesWith(Context->getConstantInt(CI->getType(), 1));
break;
}
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 01f3cc7af1..9343b965c4 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -30,6 +30,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/GlobalVariable.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
@@ -2035,7 +2036,7 @@ 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 = DAG.getContext()->getConstantInt(Type::Int64Ty, FF);
SDValue CPIdx = DAG.getConstantPool(FudgeFactor, TLI.getPointerTy());
unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();
diff --git a/lib/CodeGen/ShadowStackGC.cpp b/lib/CodeGen/ShadowStackGC.cpp
index 13fa758c24..77ec9c6131 100644
--- a/lib/CodeGen/ShadowStackGC.cpp
+++ b/lib/CodeGen/ShadowStackGC.cpp
@@ -62,9 +62,11 @@ namespace {
Constant *GetFrameMap(Function &F);
const Type* GetConcreteStackEntryType(Function &F);
void CollectRoots(Function &F);
- static GetElementPtrInst *CreateGEP(IRBuilder<> &B, Value *BasePtr,
+ static GetElementPtrInst *CreateGEP(LLVMContext *Context,
+ IRBuilder<> &B, Value *BasePtr,
int Idx1, const char *Name);
- static GetElementPtrInst *CreateGEP(IRBuilder<> &B, Value *BasePtr,
+ static GetElementPtrInst *CreateGEP(LLVMContext *Context,
+ IRBuilder<> &B, Value *BasePtr,
int Idx1, int Idx2, const char *Name);
};
@@ -186,6 +188,7 @@ ShadowStackGC::ShadowStackGC() : Head(0), StackEntryTy(0) {
Constant *ShadowStackGC::GetFrameMap(Function &F) {
// doInitialization creates the abstract type of this value.
+ LLVMContext *Context = F.getContext();
Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
@@ -200,17 +203,17 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
}
Constant *BaseElts[] = {
- ConstantInt::get(Type::Int32Ty, Roots.size(), false),
- ConstantInt::get(Type::Int32Ty, NumMeta, false),
+ Context->getConstantInt(Type::Int32Ty, Roots.size(), false),
+ Context->getConstantInt(Type::Int32Ty, NumMeta, false),
};
Constant *DescriptorElts[] = {
- ConstantStruct::get(BaseElts, 2),
- ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
+ Context->getConstantStruct(BaseElts, 2),
+ Context->getConstantArray(Context->getArrayType(VoidPtr, NumMeta),
Metadata.begin(), NumMeta)
};
- Constant *FrameMap = ConstantStruct::get(DescriptorElts, 2);
+ Constant *FrameMap = Context->getConstantStruct(DescriptorElts, 2);
std::string TypeName("gc_map.");
TypeName += utostr(NumMeta);
@@ -233,9 +236,9 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
GlobalVariable::InternalLinkage,
FrameMap, "__gc_" + F.getName());
- Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0),
- ConstantInt::get(Type::Int32Ty, 0) };
- return ConstantExpr::getGetElementPtr(GV, GEPIndices, 2);
+ Constant *GEPIndices[2] = { Context->getConstantInt(Type::Int32Ty, 0),
+ Context->getConstantInt(Type::Int32Ty, 0) };
+ return Context->getConstantExprGetElementPtr(GV, GEPIndices, 2);
}
const Type* ShadowStackGC::GetConcreteStackEntryType(Function &F) {
@@ -337,11 +340,11 @@ void ShadowStackGC::CollectRoots(Function &F) {
}
GetElementPtrInst *
-ShadowStackGC::CreateGEP(IRBuilder<> &B, Value *BasePtr,
+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[] = { Context->getConstantInt(Type::Int32Ty, 0),
+ Context->getConstantInt(Type::Int32Ty, Idx),
+ Context->getConstantInt(Type::Int32Ty, Idx2) };
Value* Val = B.CreateGEP(BasePtr, Indices, Indices + 3, Name);
assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -350,10 +353,10 @@ ShadowStackGC::CreateGEP(IRBuilder<> &B, Value *BasePtr,
}
GetElementPtrInst *
-ShadowStackGC::CreateGEP(IRBuilder<> &B, Value *BasePtr,
+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[] = { Context->getConstantInt(Type::Int32Ty, 0),
+ Context->getConstantInt(Type::Int32Ty, Idx) };
Value *Val = B.CreateGEP(BasePtr, Indices, Indices + 2, Name);
assert(isa<GetElementPtrInst>(Val) && "Unexpected folded constant");
@@ -363,6 +366,8 @@ ShadowStackGC::CreateGEP(IRBuilder<> &B, Value *BasePtr,
/// runOnFunction - Insert code to maintain the shadow stack.
bool ShadowStackGC::performCustomLowering(Function &F) {
+ LLVMContext *Context = F.getContext();
+
// Find calls to llvm.gcroot.
CollectRoots(F);
@@ -387,13 +392,14 @@ bool ShadowStackGC::performCustomLowering(Function &F) {
// Initialize the map pointer and load the current head of the shadow stack.
Instruction *CurrentHead = AtEntry.CreateLoad(Head, "gc_currhead");
- Instruction *EntryMapPtr = CreateGEP(AtEntry, StackEntry,0,1,"gc_frame.map");
+ Instruction *EntryMapPtr = CreateGEP(Context, AtEntry, StackEntry,
+ 0,1,"gc_frame.map");
AtEntry.CreateStore(FrameMap, EntryMapPtr);
// After all the allocas...
for (unsigned I = 0, E = Roots.size(); I != E; ++I) {
// For each root, find the corresponding slot in the aggregate...
- Value *SlotPtr = CreateGEP(AtEntry, StackEntry, 1 + I, "gc_root");
+ Value *SlotPtr = CreateGEP(Context, AtEntry, StackEntry, 1 + I, "gc_root");
// And use it in lieu of the alloca.
AllocaInst *OriginalAlloca = Roots[I].second;
@@ -409,17 +415,19 @@ bool ShadowStackGC::performCustomLowering(Function &F) {
AtEntry.SetInsertPoint(IP->getParent(), IP);
// Push the entry onto the shadow stack.
- Instruction *EntryNextPtr = CreateGEP(AtEntry,StackEntry,0,0,"gc_frame.next");
- Instruction *NewHeadVal = CreateGEP(AtEntry,StackEntry, 0, "gc_newhead");
- AtEntry.CreateStore(CurrentHead, EntryNextPtr);
- AtEntry.CreateStore(NewHeadVal, Head);
+ Instruction *EntryNextPtr = CreateGEP(Context, AtEntry,
+ StackEntry,0,0,"gc_frame.next");
+ Instruction *NewHeadVal = CreateGEP(Context, AtEntry,
+ StackEntry, 0, "gc_newhead");
+ AtEntry.CreateStore(CurrentHead, EntryNextPtr);
+ AtEntry.CreateStore(NewHeadVal, Head);
// For each instruction that escapes...
EscapeEnumerator EE(F, "gc_cleanup");
while (IRBuilder<> *AtExit = EE.Next()) {
// Pop the entry from the shadow stack. Don't reuse CurrentHead from
// AtEntry, since that would make the value live for the entire function.
- Instruction *EntryNextPtr2 = CreateGEP(*AtExit, StackEntry, 0, 0,
+ Instruction *EntryNextPtr2 = CreateGEP(Context, *AtExit, StackEntry, 0, 0,
"gc_frame.next");
Value *SavedHead = AtExit->CreateLoad(EntryNextPtr2, "gc_savedhead");
AtExit->CreateStore(SavedHead, Head);
diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp
index 9043b89e35..3dce50b1a8 100644
--- a/lib/CodeGen/StackProtector.cpp
+++ b/lib/CodeGen/StackProtector.cpp
@@ -154,7 +154,7 @@ bool StackProtector::InsertStackProtectors() {
BasicBlock &Entry = F->getEntryBlock();
Instruction *InsPt = &Entry.front();
- AI = new AllocaInst(PtrTy, "StackGuardSlot", InsPt);
+ AI = new AllocaInst(*Context, PtrTy, "StackGuardSlot", InsPt);
LoadInst *LI = new LoadInst(StackGuardVar, "StackGuard", false, InsPt);
Value *Args[] = { LI, AI };
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index baa8a47452..58ff71b846 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -351,6 +351,7 @@ void JIT::deleteModuleProvider(ModuleProvider *MP, std::string *E) {
GenericValue JIT::runFunction(Function *F,
const std::vector<GenericValue> &ArgValues) {
assert(F && "Function *F was null at entry to run()");
+ LLVMContext *Context = F->getContext();
void *FPtr = getPointerToFunction(F);
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
@@ -452,7 +453,7 @@ GenericValue JIT::runFunction(Function *F,
// arguments. Make this function and return.
// First, create the function.
- FunctionType *STy=FunctionType::get(RetTy, false);
+ FunctionType *STy=Context->getFunctionType(RetTy, false);
Function *Stub = Function::Create(STy, Function::InternalLinkage, "",
F->getParent());
@@ -469,26 +470,27 @@ GenericValue JIT::runFunction(Function *F,
switch (ArgTy->getTypeID()) {
default: llvm_unreachable("Unknown argument type for function call!");
case Type::IntegerTyID:
- C = ConstantInt::get(AV.IntVal);
+ C = Context->getConstantInt(AV.IntVal);
break;
case Type::FloatTyID:
- C = ConstantFP::get(APFloat(AV.FloatVal));
+ C = Context->getConstantFP(APFloat(AV.FloatVal));
break;
case Type::DoubleTyID:
- C = ConstantFP::get(APFloat(AV.DoubleVal));
+ C = Context->getConstantFP(APFloat(AV.DoubleVal));
break;
case Type::PPC_FP128TyID:
case Type::X86_FP80TyID:
case Type::FP128TyID:
- C = ConstantFP::get(APFloat(AV.IntVal));
+ C = Context->getConstantFP(APFloat(AV.IntVal));
break;
case Type::PointerTyID:
void *ArgPtr = GVTOP(AV);
if (sizeof(void*) == 4)
- C = ConstantInt::get(Type::Int32Ty, (int)(intptr_t)ArgPtr);
+ C = Context->getConstantInt(Type::Int32Ty, (int)(intptr_t)ArgPtr);
else
- C = ConstantInt::get(Type::Int64Ty, (intptr_t)ArgPtr);
- C = ConstantExpr::getIntToPtr(C, ArgTy); // Cast the integer to pointer
+ C = Context->getConstantInt(Type::Int64Ty, (intptr_t)ArgPtr);
+ // Cast the integer to pointer
+ C = Context->getConstantExprIntToPtr(C, ArgTy);
break;
}
Args.push_back(C);
diff --git a/lib/Target/ARM/ARMBaseRegisterInfo.cpp b/lib/Target/ARM/ARMBaseRegisterInfo.cpp
index 53ce753412..37ba0efae7 100644
--- a/lib/Target/ARM/ARMBaseRegisterInfo.cpp
+++ b/lib/Target/ARM/ARMBaseRegisterInfo.cpp
@@ -20,6 +20,8 @@
#include "ARMSubtarget.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
+#include "llvm/LLVMContext.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
@@ -890,7 +892,8 @@ emitLoadConstPool(MachineBasicBlock &MBB,
unsigned PredReg) const {
MachineFunction &MF = *MBB.getParent();
MachineConstantPool *ConstantPool = MF.getConstantPool();
- Constant *C = ConstantInt::get(Type::Int32Ty, Val);
+ Constant *C =
+ MF.getFunction()->getContext()->getConstantInt(Type::Int32Ty, Val);
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
BuildMI(MBB, MBBI, dl, TII.get(ARM::LDRcp), DestReg)
diff --git a/lib/Target/ARM/ARMISelDAGToDAG.cpp b/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 8023f45c1e..a102021e42 100644
--- a/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -21,6 +21,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/Intrinsics.h"
+#include "llvm/LLVMContext.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -865,7 +866,8 @@ SDNode *ARMDAGToDAGISel::Select(SDValue Op) {
!ARM_AM::isSOImmTwoPartVal(Val)); // two instrs.
if (UseCP) {
SD