Move types back to the 2.5 API.

llvm-svn: 77516
This commit is contained in:
Owen Anderson 2009-07-29 22:17:13 +00:00
parent 9793f0e4d7
commit 4056ca9568
71 changed files with 287 additions and 439 deletions

View File

@ -308,7 +308,7 @@ bodies and external function declarations. The code starts with:</p>
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy); std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
</pre> </pre>
@ -1082,7 +1082,7 @@ Value *CallExprAST::Codegen() {
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy); std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

View File

@ -917,7 +917,7 @@ Value *CallExprAST::Codegen() {
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy); std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

View File

@ -1551,7 +1551,7 @@ Value *ForExprAST::Codegen() {
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy); std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

View File

@ -1576,7 +1576,7 @@ Value *ForExprAST::Codegen() {
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy); std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

View File

@ -1911,7 +1911,7 @@ Value *VarExprAST::Codegen() {
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy); std::vector&lt;const Type*&gt; Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false); FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

View File

@ -138,7 +138,7 @@ void BrainF::header(LLVMContext& C) {
//declare i32 @puts(i8 *) //declare i32 @puts(i8 *)
Function *puts_func = cast<Function>(module-> Function *puts_func = cast<Function>(module->
getOrInsertFunction("puts", IntegerType::Int32Ty, getOrInsertFunction("puts", IntegerType::Int32Ty,
C.getPointerTypeUnqual(IntegerType::Int8Ty), NULL)); PointerType::getUnqual(IntegerType::Int8Ty), NULL));
//brainf.aberror: //brainf.aberror:
aberrorbb = BasicBlock::Create(label, brainf_func); aberrorbb = BasicBlock::Create(label, brainf_func);
@ -284,7 +284,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
// Make part of PHI instruction now, wait until end of loop to finish // Make part of PHI instruction now, wait until end of loop to finish
PHINode *phi_0 = PHINode *phi_0 =
PHINode::Create(C.getPointerTypeUnqual(IntegerType::Int8Ty), PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty),
headreg, testbb); headreg, testbb);
phi_0->reserveOperandSpace(2); phi_0->reserveOperandSpace(2);
phi_0->addIncoming(curhead, bb_0); phi_0->addIncoming(curhead, bb_0);
@ -440,7 +440,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
//%head.%d = phi i8 *[%head.%d, %main.%d] //%head.%d = phi i8 *[%head.%d, %main.%d]
PHINode *phi_1 = builder-> PHINode *phi_1 = builder->
CreatePHI(C.getPointerTypeUnqual(IntegerType::Int8Ty), headreg); CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
phi_1->reserveOperandSpace(1); phi_1->reserveOperandSpace(1);
phi_1->addIncoming(head_0, testbb); phi_1->addIncoming(head_0, testbb);
curhead = phi_1; curhead = phi_1;

View File

@ -909,8 +909,7 @@ Value *VarExprAST::Codegen() {
Function *PrototypeAST::Codegen() { Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc. // Make the function type: double(double,double) etc.
std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy); std::vector<const Type*> Doubles(Args.size(), Type::DoubleTy);
FunctionType *FT = FunctionType *FT = FunctionType::get(Type::DoubleTy, Doubles, false);
getGlobalContext().getFunctionType(Type::DoubleTy, Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule); Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);

View File

@ -31,7 +31,7 @@ int main() {
// Create the main function: first create the type 'int ()' // Create the main function: first create the type 'int ()'
FunctionType *FT = FunctionType *FT =
Context.getFunctionType(Type::Int32Ty, /*not vararg*/false); FunctionType::get(Type::Int32Ty, /*not vararg*/false);
// By passing a module as the last parameter to the Function constructor, // By passing a module as the last parameter to the Function constructor,
// it automatically gets appended to the Module. // it automatically gets appended to the Module.

View File

@ -477,7 +477,7 @@ namespace llvm {
/// getTypeForMVT - This method returns an LLVM type corresponding to the /// getTypeForMVT - This method returns an LLVM type corresponding to the
/// specified MVT. For integer types, this returns an unsigned type. Note /// specified MVT. For integer types, this returns an unsigned type. Note
/// that this will abort for types that cannot be represented. /// that this will abort for types that cannot be represented.
const Type *getTypeForMVT(LLVMContext &Context) const; const Type *getTypeForMVT() const;
/// getMVT - Return the value type corresponding to the specified type. /// getMVT - Return the value type corresponding to the specified type.
/// This returns all pointers as iPTR. If HandleUnknown is true, unknown /// This returns all pointers as iPTR. If HandleUnknown is true, unknown

View File

@ -667,6 +667,14 @@ public:
static inline bool classof(const Value *V) { static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V)); return isa<Instruction>(V) && classof(cast<Instruction>(V));
} }
/// @brief Create a result type for fcmp/icmp
static const Type* makeCmpResultType(const Type* opnd_type) {
if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) {
return VectorType::get(Type::Int1Ty, vt->getNumElements());
}
return Type::Int1Ty;
}
}; };

View File

@ -645,7 +645,7 @@ public:
Value *LHS, ///< The left-hand-side of the expression Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr, Instruction::ICmp, pred, LHS, RHS, NameStr,
InsertBefore) { InsertBefore) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@ -666,7 +666,7 @@ public:
Value *LHS, ///< The left-hand-side of the expression Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr, Instruction::ICmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) { &InsertAtEnd) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
@ -687,7 +687,7 @@ public:
Value *LHS, ///< The left-hand-side of the expression Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(Context.makeCmpResultType(LHS->getType()), ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::ICmp, pred, LHS, RHS, NameStr) { Instruction::ICmp, pred, LHS, RHS, NameStr) {
assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && assert(pred >= CmpInst::FIRST_ICMP_PREDICATE &&
pred <= CmpInst::LAST_ICMP_PREDICATE && pred <= CmpInst::LAST_ICMP_PREDICATE &&
@ -820,7 +820,7 @@ public:
Value *LHS, ///< The left-hand-side of the expression Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertBefore->getContext().makeCmpResultType(LHS->getType()), ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr, Instruction::FCmp, pred, LHS, RHS, NameStr,
InsertBefore) { InsertBefore) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@ -839,7 +839,7 @@ public:
Value *LHS, ///< The left-hand-side of the expression Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(InsertAtEnd.getContext().makeCmpResultType(LHS->getType()), ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr, Instruction::FCmp, pred, LHS, RHS, NameStr,
&InsertAtEnd) { &InsertAtEnd) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
@ -858,7 +858,7 @@ public:
Value *LHS, ///< The left-hand-side of the expression Value *LHS, ///< The left-hand-side of the expression
Value *RHS, ///< The right-hand-side of the expression Value *RHS, ///< The right-hand-side of the expression
const Twine &NameStr = "" ///< Name of the instruction const Twine &NameStr = "" ///< Name of the instruction
) : CmpInst(Context.makeCmpResultType(LHS->getType()), ) : CmpInst(makeCmpResultType(LHS->getType()),
Instruction::FCmp, pred, LHS, RHS, NameStr) { Instruction::FCmp, pred, LHS, RHS, NameStr) {
assert(pred <= FCmpInst::LAST_FCMP_PREDICATE && assert(pred <= FCmpInst::LAST_FCMP_PREDICATE &&
"Invalid FCmp predicate value"); "Invalid FCmp predicate value");
@ -910,7 +910,6 @@ public:
static inline bool classof(const Value *V) { static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V)); return isa<Instruction>(V) && classof(cast<Instruction>(V));
} }
}; };
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -91,40 +91,6 @@ public:
// MDString accessors // MDString accessors
MDString* getMDString(const StringRef &Str); MDString* getMDString(const StringRef &Str);
// FunctionType accessors
FunctionType* getFunctionType(const Type* Result, bool isVarArg);
FunctionType* getFunctionType(const Type* Result,
const std::vector<const Type*>& Params,
bool isVarArg);
// IntegerType accessors
const IntegerType* getIntegerType(unsigned NumBits);
// OpaqueType accessors
OpaqueType* getOpaqueType();
// StructType accessors
StructType* getStructType(bool isPacked=false);
StructType* getStructType(const std::vector<const Type*>& Params,
bool isPacked = false);
StructType* getStructType(const Type* type, ...);
// ArrayType accessors
ArrayType* getArrayType(const Type* ElementType, uint64_t NumElements);
// PointerType accessors
PointerType* getPointerType(const Type* ElementType, unsigned AddressSpace);
PointerType* getPointerTypeUnqual(const Type* ElementType);
// VectorType accessors
VectorType* getVectorType(const Type* ElementType, unsigned NumElements);
VectorType* getVectorTypeInteger(const VectorType* VTy);
VectorType* getVectorTypeExtendedElement(const VectorType* VTy);
VectorType* getVectorTypeTruncatedElement(const VectorType* VTy);
// Other helpers
/// @brief Create a result type for fcmp/icmp
const Type* makeCmpResultType(const Type* opnd_type);
// Methods for erasing constants // Methods for erasing constants
void erase(MDString *M); void erase(MDString *M);

View File

@ -107,7 +107,7 @@ template<typename T, bool cross> class TypeBuilder<T*, cross> {
public: public:
static const PointerType *get(LLVMContext &Context) { static const PointerType *get(LLVMContext &Context) {
static const PointerType *const result = static const PointerType *const result =
Context.getPointerTypeUnqual(TypeBuilder<T,cross>::get(Context)); PointerType::getUnqual(TypeBuilder<T,cross>::get(Context));
return result; return result;
} }
}; };
@ -120,7 +120,7 @@ template<typename T, size_t N, bool cross> class TypeBuilder<T[N], cross> {
public: public:
static const ArrayType *get(LLVMContext &Context) { static const ArrayType *get(LLVMContext &Context) {
static const ArrayType *const result = static const ArrayType *const result =
Context.getArrayType(TypeBuilder<T, cross>::get(Context), N); ArrayType::get(TypeBuilder<T, cross>::get(Context), N);
return result; return result;
} }
}; };
@ -129,7 +129,7 @@ template<typename T, bool cross> class TypeBuilder<T[], cross> {
public: public:
static const ArrayType *get(LLVMContext &Context) { static const ArrayType *get(LLVMContext &Context) {
static const ArrayType *const result = static const ArrayType *const result =
Context.getArrayType(TypeBuilder<T, cross>::get(Context), 0); ArrayType::get(TypeBuilder<T, cross>::get(Context), 0);
return result; return result;
} }
}; };
@ -161,7 +161,7 @@ template<> class TypeBuilder<T, false> { \
public: \ public: \
static const IntegerType *get(LLVMContext &Context) { \ static const IntegerType *get(LLVMContext &Context) { \
static const IntegerType *const result = \ static const IntegerType *const result = \
Context.getIntegerType(sizeof(T) * CHAR_BIT); \ IntegerType::get(sizeof(T) * CHAR_BIT); \
return result; \ return result; \
} \ } \
}; \ }; \
@ -191,7 +191,7 @@ template<uint32_t num_bits, bool cross>
class TypeBuilder<types::i<num_bits>, cross> { class TypeBuilder<types::i<num_bits>, cross> {
public: public:
static const IntegerType *get(LLVMContext &Context) { static const IntegerType *get(LLVMContext &Context) {
static const IntegerType *const result = Context.getIntegerType(num_bits); static const IntegerType *const result = IntegerType::get(num_bits);
return result; return result;
} }
}; };
@ -254,7 +254,7 @@ public:
private: private:
static const FunctionType *create(LLVMContext &Context) { static const FunctionType *create(LLVMContext &Context) {
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), false); return FunctionType::get(TypeBuilder<R, cross>::get(Context), false);
} }
}; };
template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> { template<typename R, typename A1, bool cross> class TypeBuilder<R(A1), cross> {
@ -269,7 +269,7 @@ private:
std::vector<const Type*> params; std::vector<const Type*> params;
params.reserve(1); params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A1, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false); params, false);
} }
}; };
@ -287,7 +287,7 @@ private:
params.reserve(2); params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false); params, false);
} }
}; };
@ -306,7 +306,7 @@ private:
params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false); params, false);
} }
}; };
@ -328,7 +328,7 @@ private:
params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context)); params.push_back(TypeBuilder<A4, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false); params, false);
} }
}; };
@ -351,7 +351,7 @@ private:
params.push_back(TypeBuilder<A3, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context)); params.push_back(TypeBuilder<A4, cross>::get(Context));
params.push_back(TypeBuilder<A5, cross>::get(Context)); params.push_back(TypeBuilder<A5, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, false); params, false);
} }
}; };
@ -365,7 +365,7 @@ public:
private: private:
static const FunctionType *create(LLVMContext &Context) { static const FunctionType *create(LLVMContext &Context) {
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), true); return FunctionType::get(TypeBuilder<R, cross>::get(Context), true);
} }
}; };
template<typename R, typename A1, bool cross> template<typename R, typename A1, bool cross>
@ -381,8 +381,7 @@ private:
std::vector<const Type*> params; std::vector<const Type*> params;
params.reserve(1); params.reserve(1);
params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A1, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context), params, true);
params, true);
} }
}; };
template<typename R, typename A1, typename A2, bool cross> template<typename R, typename A1, typename A2, bool cross>
@ -399,7 +398,7 @@ private:
params.reserve(2); params.reserve(2);
params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true); params, true);
} }
}; };
@ -418,7 +417,7 @@ private:
params.push_back(TypeBuilder<A1, cross>::get(Context)); params.push_back(TypeBuilder<A1, cross>::get(Context));
params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true); params, true);
} }
}; };
@ -440,7 +439,7 @@ private:
params.push_back(TypeBuilder<A2, cross>::get(Context)); params.push_back(TypeBuilder<A2, cross>::get(Context));
params.push_back(TypeBuilder<A3, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context)); params.push_back(TypeBuilder<A4, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true); params, true);
} }
}; };
@ -463,7 +462,7 @@ private:
params.push_back(TypeBuilder<A3, cross>::get(Context)); params.push_back(TypeBuilder<A3, cross>::get(Context));
params.push_back(TypeBuilder<A4, cross>::get(Context)); params.push_back(TypeBuilder<A4, cross>::get(Context));
params.push_back(TypeBuilder<A5, cross>::get(Context)); params.push_back(TypeBuilder<A5, cross>::get(Context));
return Context.getFunctionType(TypeBuilder<R, cross>::get(Context), return FunctionType::get(TypeBuilder<R, cross>::get(Context),
params, true); params, true);
} }
}; };

View File

@ -184,8 +184,8 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
if (DstEltTy->isFloatingPoint()) { if (DstEltTy->isFloatingPoint()) {
// Fold to an vector of integers with same size as our FP type. // Fold to an vector of integers with same size as our FP type.
unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits(); unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits();
const Type *DestIVTy = Context.getVectorType( const Type *DestIVTy = VectorType::get(
Context.getIntegerType(FPWidth), NumDstElt); IntegerType::get(FPWidth), NumDstElt);
// Recursively handle this integer conversion, if possible. // Recursively handle this integer conversion, if possible.
C = FoldBitCast(C, DestIVTy, TD, Context); C = FoldBitCast(C, DestIVTy, TD, Context);
if (!C) return 0; if (!C) return 0;
@ -198,8 +198,8 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy,
// it to integer first. // it to integer first.
if (SrcEltTy->isFloatingPoint()) { if (SrcEltTy->isFloatingPoint()) {
unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits(); unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits();
const Type *SrcIVTy = Context.getVectorType( const Type *SrcIVTy = VectorType::get(
Context.getIntegerType(FPWidth), NumSrcElt); IntegerType::get(FPWidth), NumSrcElt);
// Ask VMCore to do the conversion now that #elts line up. // Ask VMCore to do the conversion now that #elts line up.
C = ConstantExpr::getBitCast(C, SrcIVTy); C = ConstantExpr::getBitCast(C, SrcIVTy);
CV = dyn_cast<ConstantVector>(C); CV = dyn_cast<ConstantVector>(C);

View File

@ -470,7 +470,7 @@ DIFactory::DIFactory(Module &m)
: M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), : M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0),
RegionStartFn(0), RegionEndFn(0), RegionStartFn(0), RegionEndFn(0),
DeclareFn(0) { DeclareFn(0) {
EmptyStructPtr = VMContext.getPointerTypeUnqual(VMContext.getStructType()); EmptyStructPtr = PointerType::getUnqual(StructType::get());
} }
/// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'. /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'.
@ -493,7 +493,7 @@ Constant *DIFactory::GetStringConstant(const std::string &String) {
// Return Constant if previously defined. // Return Constant if previously defined.
if (Slot) return Slot; if (Slot) return Slot;
const PointerType *DestTy = VMContext.getPointerTypeUnqual(Type::Int8Ty); const PointerType *DestTy = PointerType::getUnqual(Type::Int8Ty);
// If empty string then use a i8* null instead. // If empty string then use a i8* null instead.
if (String.empty()) if (String.empty())
@ -522,7 +522,7 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
for (unsigned i = 0; i != NumTys; ++i) for (unsigned i = 0; i != NumTys; ++i)
Elts.push_back(getCastToEmpty(Tys[i])); Elts.push_back(getCastToEmpty(Tys[i]));
Constant *Init = ConstantArray::get(VMContext.getArrayType(EmptyStructPtr, Constant *Init = ConstantArray::get(ArrayType::get(EmptyStructPtr,
Elts.size()), Elts.size()),
Elts.data(), Elts.size()); Elts.data(), Elts.size());
// If we already have this array, just return the uniqued version. // If we already have this array, just return the uniqued version.
@ -1075,7 +1075,7 @@ namespace llvm {
const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type"); const Type *Ty = M->getTypeByName("llvm.dbg.global_variable.type");
if (!Ty) return 0; if (!Ty) return 0;
Ty = Context.getPointerType(Ty, 0); Ty = PointerType::get(Ty, 0);
Value *Val = V->stripPointerCasts(); Value *Val = V->stripPointerCasts();
for (Value::use_iterator I = Val->use_begin(), E = Val->use_end(); for (Value::use_iterator I = Val->use_begin(), E = Val->use_end();

View File

@ -75,8 +75,8 @@ ConstantRange LoopVR::getRange(const SCEV *S, const SCEV *T, ScalarEvolution &SE
ConstantRange X = getRange(Mul->getOperand(0), T, SE); ConstantRange X = getRange(Mul->getOperand(0), T, SE);
if (X.isFullSet()) return FullSet; if (X.isFullSet()) return FullSet;
const IntegerType *Ty = Context.getIntegerType(X.getBitWidth()); const IntegerType *Ty = IntegerType::get(X.getBitWidth());
const IntegerType *ExTy = Context.getIntegerType(X.getBitWidth() * const IntegerType *ExTy = IntegerType::get(X.getBitWidth() *
Mul->getNumOperands()); Mul->getNumOperands());
ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth()); ConstantRange XExt = X.zeroExtend(ExTy->getBitWidth());

View File

@ -4670,7 +4670,7 @@ const SCEV *ScalarEvolution::getBECount(const SCEV *Start,
// Check Add for unsigned overflow. // Check Add for unsigned overflow.
// TODO: More sophisticated things could be done here. // TODO: More sophisticated things could be done here.
const Type *WideTy = getContext().getIntegerType(getTypeSizeInBits(Ty) + 1); const Type *WideTy = IntegerType::get(getTypeSizeInBits(Ty) + 1);
const SCEV *EDiff = getZeroExtendExpr(Diff, WideTy); const SCEV *EDiff = getZeroExtendExpr(Diff, WideTy);
const SCEV *ERoundUp = getZeroExtendExpr(RoundUp, WideTy); const SCEV *ERoundUp = getZeroExtendExpr(RoundUp, WideTy);
const SCEV *OperandExtendedAdd = getAddExpr(EDiff, ERoundUp); const SCEV *OperandExtendedAdd = getAddExpr(EDiff, ERoundUp);

View File

@ -471,7 +471,7 @@ lltok::Kind LLLexer::LexIdentifier() {
Error("bitwidth for integer type out of range!"); Error("bitwidth for integer type out of range!");
return lltok::Error; return lltok::Error;
} }
TyVal = Context.getIntegerType(NumBits); TyVal = IntegerType::get(NumBits);
return lltok::Type; return lltok::Type;
} }

View File

@ -1104,7 +1104,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
break; break;
case lltok::kw_opaque: case lltok::kw_opaque:
// TypeRec ::= 'opaque' // TypeRec ::= 'opaque'
Result = Context.getOpaqueType(); Result = OpaqueType::get();
Lex.Lex(); Lex.Lex();
break; break;
case lltok::lbrace: case lltok::lbrace:
@ -1134,7 +1134,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
if (const Type *T = M->getTypeByName(Lex.getStrVal())) { if (const Type *T = M->getTypeByName(Lex.getStrVal())) {
Result = T; Result = T;
} else { } else {
Result = Context.getOpaqueType(); Result = OpaqueType::get();
ForwardRefTypes.insert(std::make_pair(Lex.getStrVal(), ForwardRefTypes.insert(std::make_pair(Lex.getStrVal(),
std::make_pair(Result, std::make_pair(Result,
Lex.getLoc()))); Lex.getLoc())));
@ -1153,7 +1153,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
if (I != ForwardRefTypeIDs.end()) if (I != ForwardRefTypeIDs.end())
Result = I->second.first; Result = I->second.first;
else { else {
Result = Context.getOpaqueType(); Result = OpaqueType::get();
ForwardRefTypeIDs.insert(std::make_pair(Lex.getUIntVal(), ForwardRefTypeIDs.insert(std::make_pair(Lex.getUIntVal(),
std::make_pair(Result, std::make_pair(Result,
Lex.getLoc()))); Lex.getLoc())));
@ -1166,7 +1166,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
Lex.Lex(); Lex.Lex();
unsigned Val; unsigned Val;
if (ParseUInt32(Val)) return true; if (ParseUInt32(Val)) return true;
OpaqueType *OT = Context.getOpaqueType(); //Use temporary placeholder. OpaqueType *OT = OpaqueType::get(); //Use temporary placeholder.
UpRefs.push_back(UpRefRecord(Lex.getLoc(), Val, OT)); UpRefs.push_back(UpRefRecord(Lex.getLoc(), Val, OT));
Result = OT; Result = OT;
break; break;
@ -1187,7 +1187,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
return TokError("pointers to void are invalid; use i8* instead"); return TokError("pointers to void are invalid; use i8* instead");
if (!PointerType::isValidElementType(Result.get())) if (!PointerType::isValidElementType(Result.get()))
return TokError("pointer to this type is invalid"); return TokError("pointer to this type is invalid");
Result = HandleUpRefs(Context.getPointerTypeUnqual(Result.get())); Result = HandleUpRefs(PointerType::getUnqual(Result.get()));
Lex.Lex(); Lex.Lex();
break; break;
@ -1204,7 +1204,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
ParseToken(lltok::star, "expected '*' in address space")) ParseToken(lltok::star, "expected '*' in address space"))
return true; return true;
Result = HandleUpRefs(Context.getPointerType(Result.get(), AddrSpace)); Result = HandleUpRefs(PointerType::get(Result.get(), AddrSpace));
break; break;
} }
@ -1365,7 +1365,7 @@ bool LLParser::ParseFunctionType(PATypeHolder &Result) {
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
ArgListTy.push_back(ArgList[i].Type); ArgListTy.push_back(ArgList[i].Type);
Result = HandleUpRefs(Context.getFunctionType(Result.get(), Result = HandleUpRefs(FunctionType::get(Result.get(),
ArgListTy, isVarArg)); ArgListTy, isVarArg));
return false; return false;
} }
@ -1381,7 +1381,7 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
Lex.Lex(); // Consume the '{' Lex.Lex(); // Consume the '{'
if (EatIfPresent(lltok::rbrace)) { if (EatIfPresent(lltok::rbrace)) {
Result = Context.getStructType(Packed); Result = StructType::get(Packed);
return false; return false;
} }
@ -1413,7 +1413,7 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
std::vector<const Type*> ParamsListTy; std::vector<const Type*> ParamsListTy;
for (unsigned i = 0, e = ParamsList.size(); i != e; ++i) for (unsigned i = 0, e = ParamsList.size(); i != e; ++i)
ParamsListTy.push_back(ParamsList[i].get()); ParamsListTy.push_back(ParamsList[i].get());
Result = HandleUpRefs(Context.getStructType(ParamsListTy, Packed)); Result = HandleUpRefs(StructType::get(ParamsListTy, Packed));
return false; return false;
} }
@ -1452,11 +1452,11 @@ bool LLParser::ParseArrayVectorType(PATypeHolder &Result, bool isVector) {
return Error(SizeLoc, "size too large for vector"); return Error(SizeLoc, "size too large for vector");
if (!VectorType::isValidElementType(EltTy)) if (!VectorType::isValidElementType(EltTy))
return Error(TypeLoc, "vector element type must be fp or integer"); return Error(TypeLoc, "vector element type must be fp or integer");
Result = Context.getVectorType(EltTy, unsigned(Size)); Result = VectorType::get(EltTy, unsigned(Size));
} else { } else {
if (!ArrayType::isValidElementType(EltTy)) if (!ArrayType::isValidElementType(EltTy))
return Error(TypeLoc, "invalid array element type"); return Error(TypeLoc, "invalid array element type");
Result = HandleUpRefs(Context.getArrayType(EltTy, Size)); Result = HandleUpRefs(ArrayType::get(EltTy, Size));
} }
return false; return false;
} }
@ -1836,7 +1836,7 @@ bool LLParser::ParseValID(ValID &ID) {
return Error(FirstEltLoc, "invalid array element type: " + return Error(FirstEltLoc, "invalid array element type: " +
Elts[0]->getType()->getDescription()); Elts[0]->getType()->getDescription());
ArrayType *ATy = Context.getArrayType(Elts[0]->getType(), Elts.size()); ArrayType *ATy = ArrayType::get(Elts[0]->getType(), Elts.size());
// Verify all elements are correct type! // Verify all elements are correct type!
for (unsigned i = 0, e = Elts.size(); i != e; ++i) { for (unsigned i = 0, e = Elts.size(); i != e; ++i) {
@ -2417,8 +2417,8 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
return Error(RetTypeLoc, "functions with 'sret' argument must return void"); return Error(RetTypeLoc, "functions with 'sret' argument must return void");
const FunctionType *FT = const FunctionType *FT =
Context.getFunctionType(RetType, ParamTypeList, isVarArg); FunctionType::get(RetType, ParamTypeList, isVarArg);
const PointerType *PFT = Context.getPointerTypeUnqual(FT); const PointerType *PFT = PointerType::getUnqual(FT);
Fn = 0; Fn = 0;
if (!FunctionName.empty()) { if (!FunctionName.empty()) {
@ -2902,8 +2902,8 @@ bool LLParser::ParseInvoke(Instruction *&Inst, PerFunctionState &PFS) {
if (!FunctionType::isValidReturnType(RetType)) if (!FunctionType::isValidReturnType(RetType))
return Error(RetTypeLoc, "Invalid result type for LLVM function"); return Error(RetTypeLoc, "Invalid result type for LLVM function");
Ty = Context.getFunctionType(RetType, ParamTypes, false); Ty = FunctionType::get(RetType, ParamTypes, false);
PFTy = Context.getPointerTypeUnqual(Ty); PFTy = PointerType::getUnqual(Ty);
} }
// Look up the callee. // Look up the callee.
@ -3242,8 +3242,8 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
if (!FunctionType::isValidReturnType(RetType)) if (!FunctionType::isValidReturnType(RetType))
return Error(RetTypeLoc, "Invalid result type for LLVM function"); return Error(RetTypeLoc, "Invalid result type for LLVM function");
Ty = Context.getFunctionType(RetType, ParamTypes, false); Ty = FunctionType::get(RetType, ParamTypes, false);
PFTy = Context.getPointerTypeUnqual(Ty); PFTy = PointerType::getUnqual(Ty);
} }
// Look up the callee. // Look up the callee.

View File

@ -322,7 +322,7 @@ const Type *BitcodeReader::getTypeByID(unsigned ID, bool isTypeTable) {
// The type table allows forward references. Push as many Opaque types as // The type table allows forward references. Push as many Opaque types as
// needed to get up to ID. // needed to get up to ID.
while (TypeList.size() <= ID) while (TypeList.size() <= ID)
TypeList.push_back(Context.getOpaqueType()); TypeList.push_back(OpaqueType::get());
return TypeList.back().get(); return TypeList.back().get();
} }
@ -512,7 +512,7 @@ bool BitcodeReader::ParseTypeTable() {
if (Record.size() < 1) if (Record.size() < 1)
return Error("Invalid Integer type record"); return Error("Invalid Integer type record");
ResultTy = Context.getIntegerType(Record[0]); ResultTy = IntegerType::get(Record[0]);
break; break;
case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or
// [pointee type, address space] // [pointee type, address space]
@ -521,7 +521,7 @@ bool BitcodeReader::ParseTypeTable() {
unsigned AddressSpace = 0; unsigned AddressSpace = 0;
if (Record.size() == 2) if (Record.size() == 2)
AddressSpace = Record[1]; AddressSpace = Record[1];
ResultTy = Context.getPointerType(getTypeByID(Record[0], true), ResultTy = PointerType::get(getTypeByID(Record[0], true),
AddressSpace); AddressSpace);
break; break;
} }
@ -534,7 +534,7 @@ bool BitcodeReader::ParseTypeTable() {
for (unsigned i = 3, e = Record.size(); i != e; ++i) for (unsigned i = 3, e = Record.size(); i != e; ++i)
ArgTys.push_back(getTypeByID(Record[i], true)); ArgTys.push_back(getTypeByID(Record[i], true));
ResultTy = Context.getFunctionType(getTypeByID(Record[2], true), ArgTys, ResultTy = FunctionType::get(getTypeByID(Record[2], true), ArgTys,
Record[0]); Record[0]);
break; break;
} }
@ -544,24 +544,24 @@ bool BitcodeReader::ParseTypeTable() {
std::vector<const Type*> EltTys; std::vector<const Type*> EltTys;
for (unsigned i = 1, e = Record.size(); i != e; ++i) for (unsigned i = 1, e = Record.size(); i != e; ++i)
EltTys.push_back(getTypeByID(Record[i], true)); EltTys.push_back(getTypeByID(Record[i], true));
ResultTy = Context.getStructType(EltTys, Record[0]); ResultTy = StructType::get(EltTys, Record[0]);
break; break;
} }
case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty] case bitc::TYPE_CODE_ARRAY: // ARRAY: [numelts, eltty]
if (Record.size() < 2) if (Record.size() < 2)
return Error("Invalid ARRAY type record"); return Error("Invalid ARRAY type record");
ResultTy = Context.getArrayType(getTypeByID(Record[1], true), Record[0]); ResultTy = ArrayType::get(getTypeByID(Record[1], true), Record[0]);
break; break;
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty] case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
if (Record.size() < 2) if (Record.size() < 2)
return Error("Invalid VECTOR type record"); return Error("Invalid VECTOR type record");
ResultTy = Context.getVectorType(getTypeByID(Record[1], true), Record[0]); ResultTy = VectorType::get(getTypeByID(Record[1], true), Record[0]);
break; break;
} }
if (NumRecords == TypeList.size()) { if (NumRecords == TypeList.size()) {
// If this is a new type slot, just append it. // If this is a new type slot, just append it.
TypeList.push_back(ResultTy ? ResultTy : Context.getOpaqueType()); TypeList.push_back(ResultTy ? ResultTy : OpaqueType::get());
++NumRecords; ++NumRecords;
} else if (ResultTy == 0) { } else if (ResultTy == 0) {
// Otherwise, this was forward referenced, so an opaque type was created, // Otherwise, this was forward referenced, so an opaque type was created,
@ -1046,7 +1046,7 @@ bool BitcodeReader::ParseConstants() {
return Error("Invalid CE_SHUFFLEVEC record"); return Error("Invalid CE_SHUFFLEVEC record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[0], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[1], OpTy);
const Type *ShufTy = Context.getVectorType(Type::Int32Ty, const Type *ShufTy = VectorType::get(Type::Int32Ty,
OpTy->getNumElements()); OpTy->getNumElements());
Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy); Constant *Op2 = ValueList.getConstantFwdRef(Record[2], ShufTy);
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
@ -1059,7 +1059,7 @@ bool BitcodeReader::ParseConstants() {
return Error("Invalid CE_SHUFVEC_EX record"); return Error("Invalid CE_SHUFVEC_EX record");
Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy); Constant *Op0 = ValueList.getConstantFwdRef(Record[1], OpTy);
Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy); Constant *Op1 = ValueList.getConstantFwdRef(Record[2], OpTy);
const Type *ShufTy = Context.getVectorType(Type::Int32Ty, const Type *ShufTy = VectorType::get(Type::Int32Ty,
RTy->getNumElements()); RTy->getNumElements());
Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy); Constant *Op2 = ValueList.getConstantFwdRef(Record[3], ShufTy);
V = ConstantExpr::getShuffleVector(Op0, Op1, Op2); V = ConstantExpr::getShuffleVector(Op0, Op1, Op2);
@ -1940,7 +1940,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
Value *Val, *Ptr; Value *Val, *Ptr;
if (getValueTypePair(Record, OpNum, NextValueNo, Val) || if (getValueTypePair(Record, OpNum, NextValueNo, Val) ||
getValue(Record, OpNum, getValue(Record, OpNum,
Context.getPointerTypeUnqual(Val->getType()), Ptr)|| PointerType::getUnqual(Val->getType()), Ptr)||
OpNum+2 != Record.size()) OpNum+2 != Record.size())
return Error("Invalid STORE record"); return Error("Invalid STORE record");

View File

@ -354,8 +354,7 @@ Instruction *DwarfEHPrepare::CreateValueLoad(BasicBlock *BB) {
// Create the temporary if we didn't already. // Create the temporary if we didn't already.
if (!ExceptionValueVar) { if (!ExceptionValueVar) {
ExceptionValueVar = new AllocaInst( ExceptionValueVar = new AllocaInst(PointerType::getUnqual(Type::Int8Ty),
BB->getContext().getPointerTypeUnqual(Type::Int8Ty),
"eh.value", F->begin()->begin()); "eh.value", F->begin()->begin());
++NumStackTempsIntroduced; ++NumStackTempsIntroduced;
} }

View File

@ -3664,7 +3664,7 @@ SDValue DAGCombiner::CombineConsecutiveLoads(SDNode *N, MVT VT) {
TLI.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1, MFI)) { TLI.isConsecutiveLoad(LD2, LD1, LD1VT.getSizeInBits()/8, 1, MFI)) {
unsigned Align = LD1->getAlignment(); unsigned Align = LD1->getAlignment();
unsigned NewAlign = TLI.getTargetData()-> unsigned NewAlign = TLI.getTargetData()->
getABITypeAlignment(VT.getTypeForMVT(*DAG.getContext())); getABITypeAlignment(VT.getTypeForMVT());
if (NewAlign <= Align && if (NewAlign <= Align &&
(!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) (!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT)))
@ -3722,7 +3722,7 @@ SDValue DAGCombiner::visitBIT_CONVERT(SDNode *N) {
(!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) { (!LegalOperations || TLI.isOperationLegal(ISD::LOAD, VT))) {
LoadSDNode *LN0 = cast<LoadSDNode>(N0); LoadSDNode *LN0 = cast<LoadSDNode>(N0);
unsigned Align = TLI.getTargetData()-> unsigned Align = TLI.getTargetData()->
getABITypeAlignment(VT.getTypeForMVT(*DAG.getContext())); getABITypeAlignment(VT.getTypeForMVT());
unsigned OrigAlign = LN0->getAlignment(); unsigned OrigAlign = LN0->getAlignment();
if (Align <= OrigAlign) { if (Align <= OrigAlign) {
@ -4993,8 +4993,7 @@ SDValue DAGCombiner::ReduceLoadOpStoreWidth(SDNode *N) {
unsigned NewAlign = MinAlign(LD->getAlignment(), PtrOff); unsigned NewAlign = MinAlign(LD->getAlignment(), PtrOff);
if (NewAlign < if (NewAlign <
TLI.getTargetData()->getABITypeAlignment(NewVT.getTypeForMVT( TLI.getTargetData()->getABITypeAlignment(NewVT.getTypeForMVT()))
*DAG.getContext())))
return SDValue(); return SDValue();
SDValue NewPtr = DAG.getNode(ISD::ADD, LD->getDebugLoc(), SDValue NewPtr = DAG.getNode(ISD::ADD, LD->getDebugLoc(),
@ -5049,7 +5048,7 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
unsigned OrigAlign = ST->getAlignment(); unsigned OrigAlign = ST->getAlignment();
MVT SVT = Value.getOperand(0).getValueType(); MVT SVT = Value.getOperand(0).getValueType();
unsigned Align = TLI.getTargetData()-> unsigned Align = TLI.getTargetData()->
getABITypeAlignment(SVT.getTypeForMVT(*DAG.getContext())); getABITypeAlignment(SVT.getTypeForMVT());
if (Align <= OrigAlign && if (Align <= OrigAlign &&
((!LegalOperations && !ST->isVolatile()) || ((!LegalOperations && !ST->isVolatile()) ||
TLI.isOperationLegalOrCustom(ISD::STORE, SVT))) TLI.isOperationLegalOrCustom(ISD::STORE, SVT)))
@ -5329,8 +5328,7 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
// Check the resultant load doesn't need a higher alignment than the // Check the resultant load doesn't need a higher alignment than the
// original load. // original load.
unsigned NewAlign = unsigned NewAlign =
TLI.getTargetData()->getABITypeAlignment(LVT.getTypeForMVT( TLI.getTargetData()->getABITypeAlignment(LVT.getTypeForMVT());
*DAG.getContext()));
if (NewAlign > Align || !TLI.isOperationLegalOrCustom(ISD::LOAD, LVT)) if (NewAlign > Align || !TLI.isOperationLegalOrCustom(ISD::LOAD, LVT))
return SDValue(); return SDValue();
@ -5812,8 +5810,7 @@ SDValue DAGCombiner::SimplifySelectCC(DebugLoc DL, SDValue N0, SDValue N1,
const TargetData &TD = *TLI.getTargetData(); const TargetData &TD = *TLI.getTargetData();
// Create a ConstantArray of the two constants. // Create a ConstantArray of the two constants.
Constant *CA = ConstantArray::get( Constant *CA = ConstantArray::get(ArrayType::get(FPTy, 2), Elts, 2);
DAG.getContext()->getArrayType(FPTy, 2), Elts, 2);
SDValue CPIdx = DAG.getConstantPool(CA, TLI.getPointerTy(), SDValue CPIdx = DAG.getConstantPool(CA, TLI.getPointerTy(),
TD.getPrefTypeAlignment(FPTy)); TD.getPrefTypeAlignment(FPTy));
unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment(); unsigned Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlignment();

View File

@ -361,7 +361,7 @@ static SDValue ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP,
// smaller type. // smaller type.
TLI.isLoadExtLegal(ISD::EXTLOAD, SVT) && TLI.isLoadExtLegal(ISD::EXTLOAD, SVT) &&
TLI.ShouldShrinkFPConstant(OrigVT)) { TLI.ShouldShrinkFPConstant(OrigVT)) {
const Type *SType = SVT.getTypeForMVT(*DAG.getContext()); const Type *SType = SVT.getTypeForMVT();
LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType)); LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType));
VT = SVT; VT = SVT;
Extend = true; Extend = true;
@ -1107,11 +1107,10 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
// expand it. // expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) { if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()-> unsigned ABIAlignment = TLI.getTargetData()->
getABITypeAlignment(LD->getMemoryVT().getTypeForMVT( getABITypeAlignment(LD->getMemoryVT().getTypeForMVT());
*DAG.getContext()));
if (LD->getAlignment() < ABIAlignment){ if (LD->getAlignment() < ABIAlignment){
Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()), DAG, Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()),
TLI); DAG, TLI);
Tmp3 = Result.getOperand(0); Tmp3 = Result.getOperand(0);
Tmp4 = Result.getOperand(1); Tmp4 = Result.getOperand(1);
Tmp3 = LegalizeOp(Tmp3); Tmp3 = LegalizeOp(Tmp3);
@ -1291,11 +1290,10 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
// expand it. // expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) { if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()-> unsigned ABIAlignment = TLI.getTargetData()->
getABITypeAlignment(LD->getMemoryVT().getTypeForMVT( getABITypeAlignment(LD->getMemoryVT().getTypeForMVT());
*DAG.getContext()));
if (LD->getAlignment() < ABIAlignment){ if (LD->getAlignment() < ABIAlignment){
Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()), DAG, Result = ExpandUnalignedLoad(cast<LoadSDNode>(Result.getNode()),
TLI); DAG, TLI);
Tmp1 = Result.getOperand(0); Tmp1 = Result.getOperand(0);
Tmp2 = Result.getOperand(1); Tmp2 = Result.getOperand(1);
Tmp1 = LegalizeOp(Tmp1); Tmp1 = LegalizeOp(Tmp1);
@ -1370,8 +1368,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
// expand it. // expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) { if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()-> unsigned ABIAlignment = TLI.getTargetData()->
getABITypeAlignment(ST->getMemoryVT().getTypeForMVT( getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
*DAG.getContext()));
if (ST->getAlignment() < ABIAlignment) if (ST->getAlignment() < ABIAlignment)
Result = ExpandUnalignedStore(cast<StoreSDNode>(Result.getNode()), DAG, Result = ExpandUnalignedStore(cast<StoreSDNode>(Result.getNode()), DAG,
TLI); TLI);
@ -1470,8 +1467,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
// expand it. // expand it.
if (!TLI.allowsUnalignedMemoryAccesses()) { if (!TLI.allowsUnalignedMemoryAccesses()) {
unsigned ABIAlignment = TLI.getTargetData()-> unsigned ABIAlignment = TLI.getTargetData()->
getABITypeAlignment(ST->getMemoryVT().getTypeForMVT( getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
*DAG.getContext()));
if (ST->getAlignment() < ABIAlignment) if (ST->getAlignment() < ABIAlignment)
Result = ExpandUnalignedStore(cast<StoreSDNode>(Result.getNode()), DAG, Result = ExpandUnalignedStore(cast<StoreSDNode>(Result.getNode()), DAG,
TLI); TLI);
@ -1737,7 +1733,7 @@ SDValue SelectionDAGLegalize::EmitStackConvert(SDValue SrcOp,
// Create the stack frame object. // Create the stack frame object.
unsigned SrcAlign = unsigned SrcAlign =
TLI.getTargetData()->getPrefTypeAlignment(SrcOp.getValueType(). TLI.getTargetData()->getPrefTypeAlignment(SrcOp.getValueType().
getTypeForMVT(*DAG.getContext())); getTypeForMVT());
SDValue FIPtr = DAG.CreateStackTemporary(SlotVT, SrcAlign); SDValue FIPtr = DAG.CreateStackTemporary(SlotVT, SrcAlign);
FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(FIPtr); FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(FIPtr);
@ -1748,8 +1744,7 @@ SDValue SelectionDAGLegalize::EmitStackConvert(SDValue SrcOp,
unsigned SlotSize = SlotVT.getSizeInBits(); unsigned SlotSize = SlotVT.getSizeInBits();
unsigned DestSize = DestVT.getSizeInBits(); unsigned DestSize = DestVT.getSizeInBits();
unsigned DestAlign = unsigned DestAlign =
TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForMVT( TLI.getTargetData()->getPrefTypeAlignment(DestVT.getTypeForMVT());
*DAG.getContext()));
// Emit a store to the stack slot. Use a truncstore if the input value is // Emit a store to the stack slot. Use a truncstore if the input value is
// later than DestVT. // later than DestVT.
@ -1844,7 +1839,7 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
CV.push_back(const_cast<ConstantInt *>(V->getConstantIntValue())); CV.push_back(const_cast<ConstantInt *>(V->getConstantIntValue()));
} else { } else {
assert(Node->getOperand(i).getOpcode() == ISD::UNDEF); assert(Node->getOperand(i).getOpcode() == ISD::UNDEF);
const Type *OpNTy = OpVT.getTypeForMVT(*DAG.getContext()); const Type *OpNTy = OpVT.getTypeForMVT();
CV.push_back(Context->getUndef(OpNTy)); CV.push_back(Context->getUndef(OpNTy));
} }
} }
@ -1898,7 +1893,7 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
TargetLowering::ArgListEntry Entry; TargetLowering::ArgListEntry Entry;
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
MVT ArgVT = Node->getOperand(i).getValueType(); MVT ArgVT = Node->getOperand(i).getValueType();
const Type *ArgTy = ArgVT.getTypeForMVT(*DAG.getContext()); const Type *ArgTy = ArgVT.getTypeForMVT();
Entry.Node = Node->getOperand(i); Entry.Ty = ArgTy; Entry.Node = Node->getOperand(i); Entry.Ty = ArgTy;
Entry.isSExt = isSigned; Entry.isSExt = isSigned;
Entry.isZExt = !isSigned; Entry.isZExt = !isSigned;
@ -1908,7 +1903,7 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
TLI.getPointerTy()); TLI.getPointerTy());
// Splice the libcall in wherever FindInputOutputChains tells us to. // Splice the libcall in wherever FindInputOutputChains tells us to.
const Type *RetTy = Node->getValueType(0).getTypeForMVT(*DAG.getContext()); const Type *RetTy = Node->getValueType(0).getTypeForMVT();
std::pair<SDValue, SDValue> CallInfo = std::pair<SDValue, SDValue> CallInfo =
TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false, TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
0, CallingConv::C, false, Callee, Args, DAG, 0, CallingConv::C, false, Callee, Args, DAG,
@ -2397,8 +2392,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
// Increment the pointer, VAList, to the next vaarg // Increment the pointer, VAList, to the next vaarg
Tmp3 = DAG.getNode(ISD::ADD, dl, TLI.getPointerTy(), VAList, Tmp3 = DAG.getNode(ISD::ADD, dl, TLI.getPointerTy(), VAList,
DAG.getConstant(TLI.getTargetData()-> DAG.getConstant(TLI.getTargetData()->
getTypeAllocSize(VT.getTypeForMVT( getTypeAllocSize(VT.getTypeForMVT()),
*DAG.getContext())),
TLI.getPointerTy())); TLI.getPointerTy()));
// Store the incremented VAList to the legalized pointer // Store the incremented VAList to the legalized pointer
Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Tmp2, V, 0); Tmp3 = DAG.getStore(VAList.getValue(1), dl, Tmp3, Tmp2, V, 0);

View File

@ -1009,7 +1009,7 @@ SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT,
TargetLowering::ArgListEntry Entry; TargetLowering::ArgListEntry Entry;
for (unsigned i = 0; i != NumOps; ++i) { for (unsigned i = 0; i != NumOps; ++i) {
Entry.Node = Ops[i]; Entry.Node = Ops[i];
Entry.Ty = Entry.Node.getValueType().getTypeForMVT(*DAG.getContext()); Entry.Ty = Entry.Node.getValueType().getTypeForMVT();
Entry.isSExt = isSigned; Entry.isSExt = isSigned;
Entry.isZExt = !isSigned; Entry.isZExt = !isSigned;
Args.push_back(Entry); Args.push_back(Entry);
@ -1017,7 +1017,7 @@ SDValue DAGTypeLegalizer::MakeLibCall(RTLIB::Libcall LC, MVT RetVT,
SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC), SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
TLI.getPointerTy()); TLI.getPointerTy());
const Type *RetTy = RetVT.getTypeForMVT(*DAG.getContext()); const Type *RetTy = RetVT.getTypeForMVT();
std::pair<SDValue,SDValue> CallInfo = std::pair<SDValue,SDValue> CallInfo =
TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false, TLI.LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
false, 0, CallingConv::C, false, Callee, Args, DAG, dl); false, 0, CallingConv::C, false, Callee, Args, DAG, dl);

View File

@ -115,8 +115,7 @@ void DAGTypeLegalizer::ExpandRes_BIT_CONVERT(SDNode *N, SDValue &Lo,
// Create the stack frame object. Make sure it is aligned for both // Create the stack frame object. Make sure it is aligned for both
// the source and expanded destination types. // the source and expanded destination types.
unsigned Alignment = unsigned Alignment =
TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForMVT( TLI.getTargetData()->getPrefTypeAlignment(NOutVT.getTypeForMVT());
*DAG.getContext()));
SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment); SDValue StackPtr = DAG.CreateStackTemporary(InVT, Alignment);
int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex(); int SPFI = cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex();
const Value *SV = PseudoSourceValue::getFixedStack(SPFI); const Value *SV = PseudoSourceValue::getFixedStack(SPFI);

View File

@ -667,8 +667,7 @@ void DAGTypeLegalizer::SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo,
// so use a truncating store. // so use a truncating store.
SDValue EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx); SDValue EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx);
unsigned Alignment = unsigned Alignment =
TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForMVT( TLI.getTargetData()->getPrefTypeAlignment(VecVT.getTypeForMVT());
*DAG.getContext()));
Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, NULL, 0, EltVT); Store = DAG.getTruncStore(Store, dl, Elt, EltPtr, NULL, 0, EltVT);
// Load the Lo part from the stack slot. // Load the Lo part from the stack slot.

View File

@ -798,7 +798,7 @@ void SelectionDAG::VerifyNode(SDNode *N) {
unsigned SelectionDAG::getMVTAlignment(MVT VT) const { unsigned SelectionDAG::getMVTAlignment(MVT VT) const {
const Type *Ty = VT == MVT::iPTR ? const Type *Ty = VT == MVT::iPTR ?
PointerType::get(Type::Int8Ty, 0) : PointerType::get(Type::Int8Ty, 0) :
VT.getTypeForMVT(*Context); VT.getTypeForMVT();
return TLI.getTargetData()->getABITypeAlignment(Ty); return TLI.getTargetData()->getABITypeAlignment(Ty);
} }
@ -1389,7 +1389,7 @@ SDValue SelectionDAG::getShiftAmountOperand(SDValue Op) {
SDValue SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) { SDValue SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) {
MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo(); MachineFrameInfo *FrameInfo = getMachineFunction().getFrameInfo();
unsigned ByteSize = VT.getStoreSizeInBits()/8; unsigned ByteSize = VT.getStoreSizeInBits()/8;
const Type *Ty = VT.getTypeForMVT(*Context); const Type *Ty = VT.getTypeForMVT();
unsigned StackAlign = unsigned StackAlign =
std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), minAlign); std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty), minAlign);
@ -1402,8 +1402,8 @@ SDValue SelectionDAG::CreateStackTemporary(MVT VT, unsigned minAlign) {
SDValue SelectionDAG::CreateStackTemporary(MVT VT1, MVT VT2) { SDValue SelectionDAG::CreateStackTemporary(MVT VT1, MVT VT2) {
unsigned Bytes = std::max(VT1.getStoreSizeInBits(), unsigned Bytes = std::max(VT1.getStoreSizeInBits(),
VT2.getStoreSizeInBits())/8; VT2.getStoreSizeInBits())/8;
const Type *Ty1 = VT1.getTypeForMVT(*Context); const Type *Ty1 = VT1.getTypeForMVT();
const Type *Ty2 = VT2.getTypeForMVT(*Context); const Type *Ty2 = VT2.getTypeForMVT();
const TargetData *TD = TLI.getTargetData(); const TargetData *TD = TLI.getTargetData();
unsigned Align = std::max(TD->getPrefTypeAlignment(Ty1), unsigned Align = std::max(TD->getPrefTypeAlignment(Ty1),
TD->getPrefTypeAlignment(Ty2)); TD->getPrefTypeAlignment(Ty2));
@ -3104,8 +3104,7 @@ bool MeetsMaxMemopRequirement(std::vector<MVT> &MemOps,
MVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG); MVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG);
if (VT != MVT::iAny) { if (VT != MVT::iAny) {
unsigned NewAlign = (unsigned) unsigned NewAlign = (unsigned)
TLI.getTargetData()->getABITypeAlignment(VT.getTypeForMVT( TLI.getTargetData()->getABITypeAlignment(VT.getTypeForMVT());
*DAG.getContext()));
// If source is a string constant, this will require an unaligned load. // If source is a string constant, this will require an unaligned load.
if (NewAlign > Align && (isSrcConst || AllowUnalign)) { if (NewAlign > Align && (isSrcConst || AllowUnalign)) {
if (Dst.getOpcode() != ISD::FrameIndex) { if (Dst.getOpcode() != ISD::FrameIndex) {

View File

@ -5516,7 +5516,7 @@ void TargetLowering::LowerArguments(Function &F, SelectionDAG &DAG,
for (unsigned Value = 0, NumValues = ValueVTs.size(); for (unsigned Value = 0, NumValues = ValueVTs.size();
Value != NumValues; ++Value) { Value != NumValues; ++Value) {
MVT VT = ValueVTs[Value]; MVT VT = ValueVTs[Value];
const Type *ArgTy = VT.getTypeForMVT(*DAG.getContext()); const Type *ArgTy = VT.getTypeForMVT();
ISD::ArgFlagsTy Flags; ISD::ArgFlagsTy Flags;
unsigned OriginalAlignment = unsigned OriginalAlignment =
getTargetData()->getABITypeAlignment(ArgTy); getTargetData()->getABITypeAlignment(ArgTy);
@ -5647,7 +5647,7 @@ TargetLowering::LowerCallTo(SDValue Chain, const Type *RetTy,
for (unsigned Value = 0, NumValues = ValueVTs.size(); for (unsigned Value = 0, NumValues = ValueVTs.size();
Value != NumValues; ++Value) { Value != NumValues; ++Value) {
MVT VT = ValueVTs[Value]; MVT VT = ValueVTs[Value];
const Type *ArgTy = VT.getTypeForMVT(*DAG.getContext()); const Type *ArgTy = VT.getTypeForMVT();
SDValue Op = SDValue(Args[i].Node.getNode(), SDValue Op = SDValue(Args[i].Node.getNode(),
Args[i].Node.getResNo() + Value); Args[i].Node.getResNo() + Value);
ISD::ArgFlagsTy Flags; ISD::ArgFlagsTy Flags;

View File

@ -188,8 +188,6 @@ ShadowStackGC::ShadowStackGC() : Head(0), StackEntryTy(0) {
Constant *ShadowStackGC::GetFrameMap(Function &F) { Constant *ShadowStackGC::GetFrameMap(Function &F) {
// doInitialization creates the abstract type of this value. // doInitialization creates the abstract type of this value.
LLVMContext &Context = F.getContext();
Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty); Type *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
// Truncate the ShadowStackDescriptor if some metadata is null. // Truncate the ShadowStackDescriptor if some metadata is null.
@ -209,7 +207,7 @@ Constant *ShadowStackGC::GetFrameMap(Function &F) {
Constant *DescriptorElts[] = { Constant *DescriptorElts[] = {
ConstantStruct::get(BaseElts, 2), ConstantStruct::get(BaseElts, 2),
ConstantArray::get(Context.getArrayType(VoidPtr, NumMeta), ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
Metadata.begin(), NumMeta) Metadata.begin(), NumMeta)
}; };

View File

@ -368,7 +368,6 @@ void JIT::deleteModuleProvider(ModuleProvider *MP, std::string *E) {
GenericValue JIT::runFunction(Function *F, GenericValue JIT::runFunction(Function *F,
const std::vector<GenericValue> &ArgValues) { const std::vector<GenericValue> &ArgValues) {
assert(F && "Function *F was null at entry to run()"); assert(F && "Function *F was null at entry to run()");
LLVMContext &Context = F->getContext();
void *FPtr = getPointerToFunction(F); void *FPtr = getPointerToFunction(F);
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction"); assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
@ -470,7 +469,7 @@ GenericValue JIT::runFunction(Function *F,
// arguments. Make this function and return. // arguments. Make this function and return.
// First, create the function. // First, create the function.
FunctionType *STy=Context.getFunctionType(RetTy, false); FunctionType *STy=FunctionType::get(RetTy, false);
Function *Stub = Function::Create(STy, Function::InternalLinkage, "", Function *Stub = Function::Create(STy, Function::InternalLinkage, "",
F->getParent()); F->getParent());

View File

@ -1148,7 +1148,7 @@ static bool LinkAppendingVars(Module *M,
"Appending variables with different section name need to be linked!"); "Appending variables with different section name need to be linked!");
unsigned NewSize = T1->getNumElements() + T2->getNumElements(); unsigned NewSize = T1->getNumElements() + T2->getNumElements();
ArrayType *NewType = Context.getArrayType(T1->getElementType(), ArrayType *NewType = ArrayType::get(T1->getElementType(),
NewSize); NewSize);
G1->setName(""); // Clear G1's name in case of a conflict! G1->setName(""); // Clear G1's name in case of a conflict!

View File

@ -101,7 +101,7 @@ namespace {
TargetLowering::ArgListEntry Entry; TargetLowering::ArgListEntry Entry;
for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = Op.getNumOperands(); i != e; ++i) {
MVT ArgVT = Op.getOperand(i).getValueType(); MVT ArgVT = Op.getOperand(i).getValueType();
const Type *ArgTy = ArgVT.getTypeForMVT(*DAG.getContext()); const Type *ArgTy = ArgVT.getTypeForMVT();
Entry.Node = Op.getOperand(i); Entry.Node = Op.getOperand(i);
Entry.Ty = ArgTy; Entry.Ty = ArgTy;
Entry.isSExt = isSigned; Entry.isSExt = isSigned;
@ -112,8 +112,7 @@ namespace {
TLI.getPointerTy()); TLI.getPointerTy());
// Splice the libcall in wherever FindInputOutputChains tells us to. // Splice the libcall in wherever FindInputOutputChains tells us to.
const Type *RetTy = const Type *RetTy = Op.getNode()->getValueType(0).getTypeForMVT();
Op.getNode()->getValueType(0).getTypeForMVT(*DAG.getContext());
std::pair<SDValue, SDValue> CallInfo = std::pair<SDValue, SDValue> CallInfo =
TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false, TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, false,
0, CallingConv::C, false, Callee, Args, DAG, 0, CallingConv::C, false, Callee, Args, DAG,

View File

@ -372,14 +372,14 @@ PIC16TargetLowering::MakePIC16Libcall(PIC16ISD::PIC16Libcall Call,
TargetLowering::ArgListEntry Entry; TargetLowering::ArgListEntry Entry;
for (unsigned i = 0; i != NumOps; ++i) { for (unsigned i = 0; i != NumOps; ++i) {
Entry.Node = Ops[i]; Entry.Node = Ops[i];
Entry.Ty = Entry.Node.getValueType().getTypeForMVT(*DAG.getContext()); Entry.Ty = Entry.Node.getValueType().getTypeForMVT();
Entry.isSExt = isSigned; Entry.isSExt = isSigned;
Entry.isZExt = !isSigned; Entry.isZExt = !isSigned;
Args.push_back(Entry); Args.push_back(Entry);
} }
SDValue Callee = DAG.getExternalSymbol(getPIC16LibcallName(Call), MVT::i8); SDValue Callee = DAG.getExternalSymbol(getPIC16LibcallName(Call), MVT::i8);
const Type *RetTy = RetVT.getTypeForMVT(*DAG.getContext()); const Type *RetTy = RetVT.getTypeForMVT();
std::pair<SDValue,SDValue> CallInfo = std::pair<SDValue,SDValue> CallInfo =
LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false, LowerCallTo(DAG.getEntryNode(), RetTy, isSigned, !isSigned, false,
false, 0, CallingConv::C, false, Callee, Args, DAG, dl); false, 0, CallingConv::C, false, Callee, Args, DAG, dl);

View File

@ -1291,7 +1291,7 @@ SDValue PPCTargetLowering::LowerTRAMPOLINE(SDValue Op, SelectionDAG &DAG) {
// Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg) // Lower to a call to __trampoline_setup(Trmp, TrampSize, FPtr, ctx_reg)
std::pair<SDValue, SDValue> CallResult = std::pair<SDValue, SDValue> CallResult =
LowerCallTo(Chain, Op.getValueType().getTypeForMVT(*DAG.getContext()), LowerCallTo(Chain, Op.getValueType().getTypeForMVT(),
false, false, false, false, 0, CallingConv::C, false, false, false, false, false, 0, CallingConv::C, false,
DAG.getExternalSymbol("__trampoline_setup", PtrVT), DAG.getExternalSymbol("__trampoline_setup", PtrVT),
Args, DAG, dl); Args, DAG, dl);

View File

@ -380,7 +380,7 @@ LowerLOAD(SDValue Op, SelectionDAG &DAG)
return SDValue(); return SDValue();
} }
unsigned ABIAlignment = getTargetData()-> unsigned ABIAlignment = getTargetData()->
getABITypeAlignment(LD->getMemoryVT().getTypeForMVT(*DAG.getContext())); getABITypeAlignment(LD->getMemoryVT().getTypeForMVT());
// Leave aligned load alone. // Leave aligned load alone.
if (LD->getAlignment() >= ABIAlignment) { if (LD->getAlignment() >= ABIAlignment) {
return SDValue(); return SDValue();
@ -475,7 +475,7 @@ LowerSTORE(SDValue Op, SelectionDAG &DAG)
return SDValue(); return SDValue();
} }
unsigned ABIAlignment = getTargetData()-> unsigned ABIAlignment = getTargetData()->
getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(*DAG.getContext())); getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
// Leave aligned store alone. // Leave aligned store alone.
if (ST->getAlignment() >= ABIAlignment) { if (ST->getAlignment() >= ABIAlignment) {
return SDValue(); return SDValue();
@ -1077,7 +1077,7 @@ SDValue XCoreTargetLowering::PerformDAGCombine(SDNode *N,
break; break;
} }
unsigned ABIAlignment = getTargetData()-> unsigned ABIAlignment = getTargetData()->
getABITypeAlignment(ST->getMemoryVT().getTypeForMVT(*DAG.getContext())); getABITypeAlignment(ST->getMemoryVT().getTypeForMVT());
unsigned Alignment = ST->getAlignment(); unsigned Alignment = ST->getAlignment();
if (Alignment >= ABIAlignment) { if (Alignment >= ABIAlignment) {
break; break;

View File

@ -588,7 +588,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
} }
// Construct the new function type using the new arguments. // Construct the new function type using the new arguments.
FunctionType *NFTy = Context.getFunctionType(RetTy, Params, FTy->isVarArg()); FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module... // Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName()); Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());

View File

@ -197,10 +197,9 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
// Start by computing a new prototype for the function, which is the same as // Start by computing a new prototype for the function, which is the same as
// the old function, but doesn't have isVarArg set. // the old function, but doesn't have isVarArg set.
const FunctionType *FTy = Fn.getFunctionType(); const FunctionType *FTy = Fn.getFunctionType();
LLVMContext &Context = FTy->getContext();
std::vector<const Type*> Params(FTy->param_begin(), FTy->param_end()); std::vector<const Type*> Params(FTy->param_begin(), FTy->param_end());
FunctionType *NFTy = Context.getFunctionType(FTy->getReturnType(), FunctionType *NFTy = FunctionType::get(FTy->getReturnType(),
Params, false); Params, false);
unsigned NumArgs = Params.size(); unsigned NumArgs = Params.size();
@ -641,7 +640,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// something and {} into void. // something and {} into void.
// Make the new struct packed if we used to return a packed struct // Make the new struct packed if we used to return a packed struct
// already. // already.
NRetTy = Context.getStructType(RetTypes, STy->isPacked()); NRetTy = StructType::get(RetTypes, STy->isPacked());
else if (RetTypes.size() == 1) else if (RetTypes.size() == 1)
// One return type? Just a simple value then, but only if we didn't use to // One return type? Just a simple value then, but only if we didn't use to
// return a struct with that simple value before. // return a struct with that simple value before.
@ -709,7 +708,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
} }
// Create the new function type based on the recomputed parameters. // Create the new function type based on the recomputed parameters.
FunctionType *NFTy = Context.getFunctionType(NRetTy, Params, FunctionType *NFTy = FunctionType::get(NRetTy, Params,
FTy->isVarArg()); FTy->isVarArg());
// No change? // No change?

View File

@ -103,13 +103,13 @@ namespace {
// by putting them in the used array // by putting them in the used array
{ {
std::vector<Constant *> AUGs; std::vector<Constant *> AUGs;
const Type *SBP= Context.getPointerTypeUnqual(Type::Int8Ty); const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
for (std::vector<GlobalValue*>::iterator GI = Named.begin(), for (std::vector<GlobalValue*>::iterator GI = Named.begin(),
GE = Named.end(); GI != GE; ++GI) { GE = Named.end(); GI != GE; ++GI) {
(*GI)->setLinkage(GlobalValue::ExternalLinkage); (*GI)->setLinkage(GlobalValue::ExternalLinkage);
AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP)); AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP));
} }
ArrayType *AT = Context.getArrayType(SBP, AUGs.size()); ArrayType *AT = ArrayType::get(SBP, AUGs.size());
Constant *Init = ConstantArray::get(AT, AUGs); Constant *Init = ConstantArray::get(AT, AUGs);
GlobalValue *gv = new GlobalVariable(M, AT, false, GlobalValue *gv = new GlobalVariable(M, AT, false,
GlobalValue::AppendingLinkage, GlobalValue::AppendingLinkage,

View File

@ -826,7 +826,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
if (NElements->getZExtValue() != 1) { if (NElements->getZExtValue() != 1) {
// If we have an array allocation, transform it to a single element // If we have an array allocation, transform it to a single element
// allocation to make the code below simpler. // allocation to make the code below simpler.
Type *NewTy = Context.getArrayType(MI->getAllocatedType(), Type *NewTy = ArrayType::get(MI->getAllocatedType(),
NElements->getZExtValue()); NElements->getZExtValue());
MallocInst *NewMI = MallocInst *NewMI =
new MallocInst(NewTy, Context.getNullValue(Type::Int32Ty), new MallocInst(NewTy, Context.getNullValue(Type::Int32Ty),
@ -1161,7 +1161,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
cast<StructType>(cast<PointerType>(PN->getType())->getElementType()); cast<StructType>(cast<PointerType>(PN->getType())->getElementType());
Result = Result =
PHINode::Create(Context.getPointerTypeUnqual(ST->getElementType(FieldNo)), PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
PN->getName()+".f"+utostr(FieldNo), PN); PN->getName()+".f"+utostr(FieldNo), PN);
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo)); PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
} else { } else {
@ -1282,7 +1282,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){ for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
const Type *FieldTy = STy->getElementType(FieldNo); const Type *FieldTy = STy->getElementType(FieldNo);
const Type *PFieldTy = Context.getPointerTypeUnqual(FieldTy); const Type *PFieldTy = PointerType::getUnqual(FieldTy);
GlobalVariable *NGV = GlobalVariable *NGV =
new GlobalVariable(*GV->getParent(), new GlobalVariable(*GV->getParent(),
@ -1957,8 +1957,8 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
if (Ctors[i]) { if (Ctors[i]) {
CSVals[1] = Ctors[i]; CSVals[1] = Ctors[i];
} else { } else {
const Type *FTy = Context.getFunctionType(Type::VoidTy, false); const Type *FTy = FunctionType::get(Type::VoidTy, false);
const PointerType *PFTy = Context.getPointerTypeUnqual(FTy); const PointerType *PFTy = PointerType::getUnqual(FTy);
CSVals[1] = Context.getNullValue(PFTy); CSVals[1] = Context.getNullValue(PFTy);
CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647); CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
} }

View File

@ -201,9 +201,8 @@ bool LowerSetJmp::runOnModule(Module& M) {
// This function is always successful, unless it isn't. // This function is always successful, unless it isn't.
bool LowerSetJmp::doInitialization(Module& M) bool LowerSetJmp::doInitialization(Module& M)
{ {
LLVMContext &Context = M.getContext(); const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
const Type *SBPTy = Context.getPointerTypeUnqual(Type::Int8Ty); const Type *SBPPTy = PointerType::getUnqual(SBPTy);
const Type *SBPPTy = Context.getPointerTypeUnqual(SBPTy);
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for // N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
// a description of the following library functions. // a description of the following library functions.
@ -259,7 +258,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
// throwing the exception for us. // throwing the exception for us.
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst) void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
{ {
const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty); const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
// same parameters as "longjmp", except that the buffer is cast to a // same parameters as "longjmp", except that the buffer is cast to a
@ -312,7 +311,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func)
assert(Inst && "Couldn't find even ONE instruction in entry block!"); assert(Inst && "Couldn't find even ONE instruction in entry block!");
// Fill in the alloca and call to initialize the SJ map. // Fill in the alloca and call to initialize the SJ map.
const Type *SBPTy = Func->getContext().getPointerTypeUnqual(Type::Int8Ty); const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst); AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
CallInst::Create(InitSJMap, Map, "", Inst); CallInst::Create(InitSJMap, Map, "", Inst);
return SJMap[Func] = Map; return SJMap[Func] = Map;
@ -378,7 +377,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
Function* Func = ABlock->getParent(); Function* Func = ABlock->getParent();
// Add this setjmp to the setjmp map. // Add this setjmp to the setjmp map.
const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty); const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
CastInst* BufPtr = CastInst* BufPtr =
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
std::vector<Value*> Args = std::vector<Value*> Args =

View File

@ -70,8 +70,6 @@ ModulePass *llvm::createRaiseAllocationsPass() {
// function into the appropriate instruction. // function into the appropriate instruction.
// //
void RaiseAllocations::doInitialization(Module &M) { void RaiseAllocations::doInitialization(Module &M) {
LLVMContext &Context = M.getContext();
// Get Malloc and free prototypes if they exist! // Get Malloc and free prototypes if they exist!
MallocFunc = M.getFunction("malloc"); MallocFunc = M.getFunction("malloc");
if (MallocFunc) { if (MallocFunc) {
@ -79,7 +77,7 @@ void RaiseAllocations::doInitialization(Module &M) {
// Get the expected prototype for malloc // Get the expected prototype for malloc
const FunctionType *Malloc1Type = const FunctionType *Malloc1Type =
Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(1, Type::Int64Ty), false); std::vector<const Type*>(1, Type::Int64Ty), false);
// Chck to see if we got the expected malloc // Chck to see if we got the expected malloc
@ -87,14 +85,14 @@ void RaiseAllocations::doInitialization(Module &M) {
// Check to see if the prototype is wrong, giving us i8*(i32) * malloc // Check to see if the prototype is wrong, giving us i8*(i32) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);' // This handles the common declaration of: 'void *malloc(unsigned);'
const FunctionType *Malloc2Type = const FunctionType *Malloc2Type =
Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(1, Type::Int32Ty), false); std::vector<const Type*>(1, Type::Int32Ty), false);
if (TyWeHave != Malloc2Type) { if (TyWeHave != Malloc2Type) {
// Check to see if the prototype is missing, giving us // Check to see if the prototype is missing, giving us
// i8*(...) * malloc // i8*(...) * malloc
// This handles the common declaration of: 'void *malloc();' // This handles the common declaration of: 'void *malloc();'
const FunctionType *Malloc3Type = const FunctionType *Malloc3Type =
Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
true); true);
if (TyWeHave != Malloc3Type) if (TyWeHave != Malloc3Type)
// Give up // Give up
@ -108,21 +106,21 @@ void RaiseAllocations::doInitialization(Module &M) {
const FunctionType* TyWeHave = FreeFunc->getFunctionType(); const FunctionType* TyWeHave = FreeFunc->getFunctionType();
// Get the expected prototype for void free(i8*) // Get the expected prototype for void free(i8*)
const FunctionType *Free1Type = Context.getFunctionType(Type::VoidTy, const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
std::vector<const Type*>(1, Context.getPointerTypeUnqual(Type::Int8Ty)), std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)),
false); false);
if (TyWeHave != Free1Type) { if (TyWeHave != Free1Type) {
// Check to see if the prototype was forgotten, giving us // Check to see if the prototype was forgotten, giving us
// void (...) * free // void (...) * free
// This handles the common forward declaration of: 'void free();' // This handles the common forward declaration of: 'void free();'
const FunctionType* Free2Type = Context.getFunctionType(Type::VoidTy, const FunctionType* Free2Type = FunctionType::get(Type::VoidTy,
true); true);
if (TyWeHave != Free2Type) { if (TyWeHave != Free2Type) {
// One last try, check to see if we can find free as // One last try, check to see if we can find free as
// int (...)* free. This handles the case where NOTHING was declared. // int (...)* free. This handles the case where NOTHING was declared.
const FunctionType* Free3Type = Context.getFunctionType(Type::Int32Ty, const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
true); true);
if (TyWeHave != Free3Type) { if (TyWeHave != Free3Type) {
@ -224,7 +222,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
Value *Source = *CS.arg_begin(); Value *Source = *CS.arg_begin();
if (!isa<PointerType>(Source->getType())) if (!isa<PointerType>(Source->getType()))
Source = new IntToPtrInst(Source, Source = new IntToPtrInst(Source,
Context.getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
"FreePtrCast", I); "FreePtrCast", I);
new FreeInst(Source, I); new FreeInst(Source, I);

View File

@ -232,8 +232,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F,
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs)); AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
FunctionType *NFTy = FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
F->getContext().getFunctionType(STy, Params, FTy->isVarArg());
Function *NF = Function::Create(NFTy, F->getLinkage()); Function *NF = Function::Create(NFTy, F->getLinkage());
NF->takeName(F); NF->takeName(F);
NF->copyAttributesFrom(F); NF->copyAttributesFrom(F);

View File

@ -63,7 +63,7 @@ bool FunctionProfiler::runOnModule(Module &M) {
if (!I->isDeclaration()) if (!I->isDeclaration())
++NumFunctions; ++NumFunctions;
const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumFunctions); const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions);
GlobalVariable *Counters = GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "FuncProfCounters"); M.getContext().getNullValue(ATy), "FuncProfCounters");
@ -108,7 +108,7 @@ bool BlockProfiler::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
NumBlocks += I->size(); NumBlocks += I->size();
const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumBlocks); const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks);
GlobalVariable *Counters = GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "BlockProfCounters"); M.getContext().getNullValue(ATy), "BlockProfCounters");

View File

@ -64,7 +64,7 @@ bool EdgeProfiler::runOnModule(Module &M) {
NumEdges += BB->getTerminator()->getNumSuccessors(); NumEdges += BB->getTerminator()->getNumSuccessors();
} }
const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumEdges); const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
GlobalVariable *Counters = GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage, new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "EdgeProfCounters"); M.getContext().getNullValue(ATy), "EdgeProfCounters");

View File

@ -25,8 +25,8 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
GlobalValue *Array) { GlobalValue *Array) {
LLVMContext &Context = MainFn->getContext(); LLVMContext &Context = MainFn->getContext();
const Type *ArgVTy = const Type *ArgVTy =
Context.getPointerTypeUnqual(Context.getPointerTypeUnqual(Type::Int8Ty)); PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
const PointerType *UIntPtr = Context.getPointerTypeUnqual(Type::Int32Ty); const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty);
Module &M = *MainFn->getParent(); Module &M = *MainFn->getParent();
Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty, Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
ArgVTy, UIntPtr, Type::Int32Ty, ArgVTy, UIntPtr, Type::Int32Ty,

View File

@ -7681,7 +7681,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
case 32 : case 32 :
case 64 : case 64 :
case 128: case 128:
SExtType = Context->getIntegerType(Ty->getBitWidth() - ShiftAmt1); SExtType = IntegerType::get(Ty->getBitWidth() - ShiftAmt1);
break; break;
default: break; default: break;
} }
@ -9697,7 +9697,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
// Use an integer load+store unless we can find something better. // Use an integer load+store unless we can find something better.
Type *NewPtrTy = Type *NewPtrTy =
Context->getPointerTypeUnqual(Context->getIntegerType(Size<<3)); PointerType::getUnqual(IntegerType::get(Size<<3));
// Memcpy forces the use of i8* for the source and destination. That means // 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 // that if you're using memcpy to move one double around, you'll get a cast
@ -9726,7 +9726,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
} }
if (SrcETy->isSingleValueType()) if (SrcETy->isSingleValueType())
NewPtrTy = Context->getPointerTypeUnqual(SrcETy); NewPtrTy = PointerType::getUnqual(SrcETy);
} }
} }
@ -9768,10 +9768,10 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
// memset(s,c,n) -> store s, c (for n=1,2,4,8) // memset(s,c,n) -> store s, c (for n=1,2,4,8)
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) { if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
const Type *ITy = Context->getIntegerType(Len*8); // n=1 -> i8. const Type *ITy = IntegerType::get(Len*8); // n=1 -> i8.
Value *Dest = MI->getDest(); Value *Dest = MI->getDest();
Dest = InsertBitCastBefore(Dest, Context->getPointerTypeUnqual(ITy), *MI); Dest = InsertBitCastBefore(Dest, PointerType::getUnqual(ITy), *MI);
// Alignment 0 is identity for alignment 1 for memset, but not store. // Alignment 0 is identity for alignment 1 for memset, but not store.
if (Alignment == 0) Alignment = 1; if (Alignment == 0) Alignment = 1;
@ -9875,7 +9875,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn X86 loadups -> load if the pointer is known aligned. // Turn X86 loadups -> load if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) { if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) {
Value *Ptr = InsertBitCastBefore(II->getOperand(1), Value *Ptr = InsertBitCastBefore(II->getOperand(1),
Context->getPointerTypeUnqual(II->getType()), PointerType::getUnqual(II->getType()),
CI); CI);
return new LoadInst(Ptr); return new LoadInst(Ptr);
} }
@ -9885,7 +9885,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn stvx -> store if the pointer is known aligned. // Turn stvx -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(2), 16) >= 16) { if (GetOrEnforceKnownAlignment(II->getOperand(2), 16) >= 16) {
const Type *OpPtrTy = const Type *OpPtrTy =
Context->getPointerTypeUnqual(II->getOperand(1)->getType()); PointerType::getUnqual(II->getOperand(1)->getType());
Value *Ptr = InsertBitCastBefore(II->getOperand(2), OpPtrTy, CI); Value *Ptr = InsertBitCastBefore(II->getOperand(2), OpPtrTy, CI);
return new StoreInst(II->getOperand(1), Ptr); return new StoreInst(II->getOperand(1), Ptr);
} }
@ -9896,7 +9896,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn X86 storeu -> store if the pointer is known aligned. // Turn X86 storeu -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) { if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) {
const Type *OpPtrTy = const Type *OpPtrTy =
Context->getPointerTypeUnqual(II->getOperand(2)->getType()); PointerType::getUnqual(II->getOperand(2)->getType());
Value *Ptr = InsertBitCastBefore(II->getOperand(1), OpPtrTy, CI); Value *Ptr = InsertBitCastBefore(II->getOperand(1), OpPtrTy, CI);
return new StoreInst(II->getOperand(2), Ptr); return new StoreInst(II->getOperand(2), Ptr);
} }
@ -10062,7 +10062,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// If the call and callee calling conventions don't match, this call must // If the call and callee calling conventions don't match, this call must
// be unreachable, as the call is undefined. // be unreachable, as the call is undefined.
new StoreInst(Context->getTrue(), new StoreInst(Context->getTrue(),
Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)), Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
OldCall); OldCall);
if (!OldCall->use_empty()) if (!OldCall->use_empty())
OldCall->replaceAllUsesWith(Context->getUndef(OldCall->getType())); OldCall->replaceAllUsesWith(Context->getUndef(OldCall->getType()));
@ -10076,7 +10076,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// undef so that we know that this code is not reachable, despite the fact // undef so that we know that this code is not reachable, despite the fact
// that we can't modify the CFG here. // that we can't modify the CFG here.
new StoreInst(Context->getTrue(), new StoreInst(Context->getTrue(),
Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)), Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
CS.getInstruction()); CS.getInstruction());
if (!CS.getInstruction()->use_empty()) if (!CS.getInstruction()->use_empty())
@ -10457,13 +10457,12 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
// Replace the trampoline call with a direct call. Let the generic // Replace the trampoline call with a direct call. Let the generic
// code sort out any function type mismatches. // code sort out any function type mismatches.
FunctionType *NewFTy = FunctionType *NewFTy = FunctionType::get(FTy->getReturnType(), NewTypes,
Context->getFunctionType(FTy->getReturnType(), NewTypes,
FTy->isVarArg()); FTy->isVarArg());
Constant *NewCallee = Constant *NewCallee =
NestF->getType() == Context->getPointerTypeUnqual(NewFTy) ? NestF->getType() == PointerType::getUnqual(NewFTy) ?
NestF : ConstantExpr::getBitCast(NestF, NestF : ConstantExpr::getBitCast(NestF,
Context->getPointerTypeUnqual(NewFTy)); PointerType::getUnqual(NewFTy));
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(), const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),
NewAttrs.end()); NewAttrs.end());
@ -11367,7 +11366,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
if (AI.isArrayAllocation()) { // Check C != 1 if (AI.isArrayAllocation()) { // Check C != 1
if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) { if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
const Type *NewTy = const Type *NewTy =
Context->getArrayType(AI.getAllocatedType(), C->getZExtValue()); ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
AllocationInst *New = 0; AllocationInst *New = 0;
// Create and insert the replacement instruction... // Create and insert the replacement instruction...
@ -11427,7 +11426,7 @@ Instruction *InstCombiner::visitFreeInst(FreeInst &FI) {
if (isa<UndefValue>(Op)) { if (isa<UndefValue>(Op)) {
// Insert a new store to null because we cannot modify the CFG here. // Insert a new store to null because we cannot modify the CFG here.
new StoreInst(Context->getTrue(), new StoreInst(Context->getTrue(),
Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)), &FI); Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), &FI);
return EraseInstFromFunction(FI); return EraseInstFromFunction(FI);
} }
@ -11734,7 +11733,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
} }
} }
SrcTy = Context->getPointerType(SrcPTy, SrcTy->getAddressSpace()); SrcTy = PointerType::get(SrcPTy, SrcTy->getAddressSpace());
} }
if (!SrcPTy->isInteger() && !isa<PointerType>(SrcPTy)) if (!SrcPTy->isInteger() && !isa<PointerType>(SrcPTy))
@ -12456,7 +12455,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
unsigned AS = unsigned AS =
cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace(); cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace();
Value *Ptr = InsertBitCastBefore(I->getOperand(0), Value *Ptr = InsertBitCastBefore(I->getOperand(0),
Context->getPointerType(EI.getType(), AS),EI); PointerType::get(EI.getType(), AS),EI);
GetElementPtrInst *GEP = GetElementPtrInst *GEP =
GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName()+".gep"); GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName()+".gep");
cast<GEPOperator>(GEP)->setIsInBounds(true); cast<GEPOperator>(GEP)->setIsInBounds(true);

View File

@ -1947,7 +1947,7 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
NewCmpTy = NewCmpLHS->getType(); NewCmpTy = NewCmpLHS->getType();
NewTyBits = SE->getTypeSizeInBits(NewCmpTy); NewTyBits = SE->getTypeSizeInBits(NewCmpTy);
const Type *NewCmpIntTy = Context.getIntegerType(NewTyBits); const Type *NewCmpIntTy = IntegerType::get(NewTyBits);
if (RequiresTypeConversion(NewCmpTy, CmpTy)) { if (RequiresTypeConversion(NewCmpTy, CmpTy)) {
// Check if it is possible to rewrite it using // Check if it is possible to rewrite it using
// an iv / stride of a smaller integer type. // an iv / stride of a smaller integer type.

View File

@ -352,7 +352,6 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
TargetData &TD = getAnalysis<TargetData>(); TargetData &TD = getAnalysis<TargetData>();
AliasAnalysis &AA = getAnalysis<AliasAnalysis>(); AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
LLVMContext &Context = SI->getContext();
Module *M = SI->getParent()->getParent()->getParent(); Module *M = SI->getParent()->getParent()->getParent();
// Okay, so we now have a single store that can be splatable. Scan to find // Okay, so we now have a single store that can be splatable. Scan to find
@ -441,7 +440,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
StartPtr = Range.StartPtr; StartPtr = Range.StartPtr;
// Cast the start ptr to be i8* as memset requires. // Cast the start ptr to be i8* as memset requires.
const Type *i8Ptr = Context.getPointerTypeUnqual(Type::Int8Ty); const Type *i8Ptr = PointerType::getUnqual(Type::Int8Ty);
if (StartPtr->getType() != i8Ptr) if (StartPtr->getType() != i8Ptr)
StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
InsertPt); InsertPt);

View File

@ -307,7 +307,7 @@ bool SROA::performScalarRepl(Function &F) {
DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n"; DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n";
// Create and insert the integer alloca. // Create and insert the integer alloca.
const Type *NewTy = F.getContext().getIntegerType(AllocaSize*8); const Type *NewTy = IntegerType::get(AllocaSize*8);
NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin()); NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin());
ConvertUsesToScalar(AI, NewAI, 0); ConvertUsesToScalar(AI, NewAI, 0);
} }
@ -900,7 +900,6 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
SmallVector<AllocaInst*, 32> &NewElts){ SmallVector<AllocaInst*, 32> &NewElts){
// Extract each element out of the integer according to its structure offset // Extract each element out of the integer according to its structure offset
// and store the element value to the individual alloca. // and store the element value to the individual alloca.
LLVMContext &Context = SI->getContext();
Value *SrcVal = SI->getOperand(0); Value *SrcVal = SI->getOperand(0);
const Type *AllocaEltTy = AI->getType()->getElementType(); const Type *AllocaEltTy = AI->getType()->getElementType();
uint64_t AllocaSizeBits = TD->getTypeAllocSizeInBits(AllocaEltTy); uint64_t AllocaSizeBits = TD->getTypeAllocSizeInBits(AllocaEltTy);
@ -914,7 +913,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
// Handle tail padding by extending the operand // Handle tail padding by extending the operand
if (TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits) if (TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits)
SrcVal = new ZExtInst(SrcVal, SrcVal = new ZExtInst(SrcVal,
Context.getIntegerType(AllocaSizeBits), "", SI); IntegerType::get(AllocaSizeBits), "", SI);
DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI; DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI;
@ -946,7 +945,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
if (FieldSizeBits != AllocaSizeBits) if (FieldSizeBits != AllocaSizeBits)
EltVal = new TruncInst(EltVal, EltVal = new TruncInst(EltVal,
Context.getIntegerType(FieldSizeBits), "", SI); IntegerType::get(FieldSizeBits), "", SI);
Value *DestField = NewElts[i]; Value *DestField = NewElts[i];
if (EltVal->getType() == FieldTy) { if (EltVal->getType() == FieldTy) {
// Storing to an integer field of this size, just do it. // Storing to an integer field of this size, just do it.
@ -956,7 +955,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
} else { } else {
// Otherwise, bitcast the dest pointer (for aggregates). // Otherwise, bitcast the dest pointer (for aggregates).
DestField = new BitCastInst(DestField, DestField = new BitCastInst(DestField,
Context.getPointerTypeUnqual(EltVal->getType()), PointerType::getUnqual(EltVal->getType()),
"", SI); "", SI);
} }
new StoreInst(EltVal, DestField, SI); new StoreInst(EltVal, DestField, SI);
@ -989,7 +988,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
// Truncate down to an integer of the right size. // Truncate down to an integer of the right size.
if (ElementSizeBits != AllocaSizeBits) if (ElementSizeBits != AllocaSizeBits)
EltVal = new TruncInst(EltVal, EltVal = new TruncInst(EltVal,
Context.getIntegerType(ElementSizeBits),"",SI); IntegerType::get(ElementSizeBits),"",SI);
Value *DestField = NewElts[i]; Value *DestField = NewElts[i];
if (EltVal->getType() == ArrayEltTy) { if (EltVal->getType() == ArrayEltTy) {
// Storing to an integer field of this size, just do it. // Storing to an integer field of this size, just do it.
@ -999,7 +998,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
} else { } else {
// Otherwise, bitcast the dest pointer (for aggregates). // Otherwise, bitcast the dest pointer (for aggregates).
DestField = new BitCastInst(DestField, DestField = new BitCastInst(DestField,
Context.getPointerTypeUnqual(EltVal->getType()), PointerType::getUnqual(EltVal->getType()),
"", SI); "", SI);
} }
new StoreInst(EltVal, DestField, SI); new StoreInst(EltVal, DestField, SI);
@ -1046,7 +1045,7 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI,
LLVMContext &Context = LI->getContext(); LLVMContext &Context = LI->getContext();
Value *ResultVal = Value *ResultVal =
Context.getNullValue(Context.getIntegerType(AllocaSizeBits)); Context.getNullValue(IntegerType::get(AllocaSizeBits));
for (unsigned i = 0, e = NewElts.size(); i != e; ++i) { for (unsigned i = 0, e = NewElts.size(); i != e; ++i) {
// Load the value from the alloca. If the NewElt is an aggregate, cast // Load the value from the alloca. If the NewElt is an aggregate, cast
@ -1059,11 +1058,11 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI,
// Ignore zero sized fields like {}, they obviously contain no data. // Ignore zero sized fields like {}, they obviously contain no data.
if (FieldSizeBits == 0) continue; if (FieldSizeBits == 0) continue;
const IntegerType *FieldIntTy = Context.getIntegerType(FieldSizeBits); const IntegerType *FieldIntTy = IntegerType::get(FieldSizeBits);
if (!isa<IntegerType>(FieldTy) && !FieldTy->isFloatingPoint() && if (!isa<IntegerType>(FieldTy) && !FieldTy->isFloatingPoint() &&
!isa<VectorType>(FieldTy)) !isa<VectorType>(FieldTy))
SrcField = new BitCastInst(SrcField, SrcField = new BitCastInst(SrcField,
Context.getPointerTypeUnqual(FieldIntTy), PointerType::getUnqual(FieldIntTy),
"", LI); "", LI);
SrcField = new LoadInst(SrcField, "sroa.load.elt", LI); SrcField = new LoadInst(SrcField, "sroa.load.elt", LI);
@ -1297,7 +1296,7 @@ static void MergeInType(const Type *In, uint64_t Offset, const Type *&VecTy,
cast<VectorType>(VecTy)->getElementType() cast<VectorType>(VecTy)->getElementType()
->getPrimitiveSizeInBits()/8 == EltSize)) { ->getPrimitiveSizeInBits()/8 == EltSize)) {
if (VecTy == 0) if (VecTy == 0)
VecTy = In->getContext().getVectorType(In, AllocaSize/EltSize); VecTy = VectorType::get(In, AllocaSize/EltSize);
return; return;
} }
} }
@ -1623,10 +1622,10 @@ Value *SROA::ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
unsigned LIBitWidth = TD->getTypeSizeInBits(ToType); unsigned LIBitWidth = TD->getTypeSizeInBits(ToType);
if (LIBitWidth < NTy->getBitWidth()) if (LIBitWidth < NTy->getBitWidth())
FromVal = FromVal =
Builder.CreateTrunc(FromVal, Context.getIntegerType(LIBitWidth), "tmp"); Builder.CreateTrunc(FromVal, IntegerType::get(LIBitWidth), "tmp");
else if (LIBitWidth > NTy->getBitWidth()) else if (LIBitWidth > NTy->getBitWidth())
FromVal = FromVal =
Builder.CreateZExt(FromVal, Context.getIntegerType(LIBitWidth), "tmp"); Builder.CreateZExt(FromVal, IntegerType::get(LIBitWidth), "tmp");
// If the result is an integer, this is a trunc or bitcast. // If the result is an integer, this is a trunc or bitcast.
if (isa<IntegerType>(ToType)) { if (isa<IntegerType>(ToType)) {
@ -1711,7 +1710,7 @@ Value *SROA::ConvertScalar_InsertValue(Value *SV, Value *Old,
unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType()); unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType());
unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType); unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType);
if (SV->getType()->isFloatingPoint() || isa<VectorType>(SV->getType())) if (SV->getType()->isFloatingPoint() || isa<VectorType>(SV->getType()))
SV = Builder.CreateBitCast(SV, Context.getIntegerType(SrcWidth), "tmp"); SV = Builder.CreateBitCast(SV, IntegerType::get(SrcWidth), "tmp");
else if (isa<PointerType>(SV->getType())) else if (isa<PointerType>(SV->getType()))
SV = Builder.CreatePtrToInt(SV, TD->getIntPtrType(), "tmp"); SV = Builder.CreatePtrToInt(SV, TD->getIntPtrType(), "tmp");

View File

@ -126,7 +126,7 @@ public:
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*. /// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) { Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
return return
B.CreateBitCast(V, Context->getPointerTypeUnqual(Type::Int8Ty), "cstr"); B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr");
} }
/// EmitStrLen - Emit a call to the strlen function to the builder, for the /// EmitStrLen - Emit a call to the strlen function to the builder, for the
@ -140,7 +140,7 @@ Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder<> &B) {
Constant *StrLen =M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2), Constant *StrLen =M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2),
TD->getIntPtrType(), TD->getIntPtrType(),
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
NULL); NULL);
CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen"); CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen");
if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts())) if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
@ -171,8 +171,8 @@ Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val,
AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind); AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1), Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1),
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
Type::Int32Ty, TD->getIntPtrType(), Type::Int32Ty, TD->getIntPtrType(),
NULL); NULL);
CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr"); CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
@ -195,8 +195,8 @@ Value *LibCallOptimization::EmitMemCmp(Value *Ptr1, Value *Ptr2,
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3), Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3),
Type::Int32Ty, Type::Int32Ty,
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), NULL); TD->getIntPtrType(), NULL);
CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B), CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
Len, "memcmp"); Len, "memcmp");
@ -274,7 +274,7 @@ void LibCallOptimization::EmitPutS(Value *Str, IRBuilder<> &B) {
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2), Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2),
Type::Int32Ty, Type::Int32Ty,
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
NULL); NULL);
CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts"); CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts");
if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts())) if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
@ -314,11 +314,11 @@ void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B) {
Constant *F; Constant *F;
if (isa<PointerType>(File->getType())) if (isa<PointerType>(File->getType()))
F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::Int32Ty, F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::Int32Ty,
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
File->getType(), NULL); File->getType(), NULL);
else else
F = M->getOrInsertFunction("fputs", Type::Int32Ty, F = M->getOrInsertFunction("fputs", Type::Int32Ty,
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
File->getType(), NULL); File->getType(), NULL);
CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs"); CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
@ -339,12 +339,12 @@ void LibCallOptimization::EmitFWrite(Value *Ptr, Value *Size, Value *File,
if (isa<PointerType>(File->getType())) if (isa<PointerType>(File->getType()))
F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3), F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3),
TD->getIntPtrType(), TD->getIntPtrType(),
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), TD->getIntPtrType(), TD->getIntPtrType(), TD->getIntPtrType(),
File->getType(), NULL); File->getType(), NULL);
else else
F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(), F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
Context->getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), TD->getIntPtrType(), TD->getIntPtrType(), TD->getIntPtrType(),
File->getType(), NULL); File->getType(), NULL);
CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size, CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
@ -555,7 +555,7 @@ struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
// Verify the "strcat" function prototype. // Verify the "strcat" function prototype.
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || if (FT->getNumParams() != 2 ||
FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) || FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType() || FT->getParamType(0) != FT->getReturnType() ||
FT->getParamType(1) != FT->getReturnType()) FT->getParamType(1) != FT->getReturnType())
return 0; return 0;
@ -602,7 +602,7 @@ struct VISIBILITY_HIDDEN StrNCatOpt : public StrCatOpt {
// Verify the "strncat" function prototype. // Verify the "strncat" function prototype.
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || if (FT->getNumParams() != 3 ||
FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) || FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType() || FT->getParamType(0) != FT->getReturnType() ||
FT->getParamType(1) != FT->getReturnType() || FT->getParamType(1) != FT->getReturnType() ||
!isa<IntegerType>(FT->getParamType(2))) !isa<IntegerType>(FT->getParamType(2)))
@ -647,7 +647,7 @@ struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
// Verify the "strchr" function prototype. // Verify the "strchr" function prototype.
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || if (FT->getNumParams() != 2 ||
FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) || FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType()) FT->getParamType(0) != FT->getReturnType())
return 0; return 0;
@ -701,7 +701,7 @@ struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty || if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty ||
FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty)) FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty))
return 0; return 0;
Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2); Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2);
@ -745,7 +745,7 @@ struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty || if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty ||
FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) || FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getParamType(2))) !isa<IntegerType>(FT->getParamType(2)))
return 0; return 0;
@ -791,7 +791,7 @@ struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) || if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) ||
FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty)) FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty))
return 0; return 0;
Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2); Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2);
@ -818,7 +818,7 @@ struct VISIBILITY_HIDDEN StrNCpyOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) || if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
FT->getParamType(0) != FT->getParamType(1) || FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) || FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getParamType(2))) !isa<IntegerType>(FT->getParamType(2)))
return 0; return 0;
@ -863,7 +863,7 @@ struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType(); const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 1 || if (FT->getNumParams() != 1 ||
FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) || FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getReturnType())) !isa<IntegerType>(FT->getReturnType()))
return 0; return 0;
@ -937,7 +937,7 @@ struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
// memcmp(S1,S2,2) != 0 -> (*(short*)LHS ^ *(short*)RHS) != 0 // memcmp(S1,S2,2) != 0 -> (*(short*)LHS ^ *(short*)RHS) != 0
// memcmp(S1,S2,4) != 0 -> (*(int*)LHS ^ *(int*)RHS) != 0 // memcmp(S1,S2,4) != 0 -> (*(int*)LHS ^ *(int*)RHS) != 0
if ((Len == 2 || Len == 4) && IsOnlyUsedInZeroEqualityComparison(CI)) { if ((Len == 2 || Len == 4) && IsOnlyUsedInZeroEqualityComparison(CI)) {
const Type *PTy = Context->getPointerTypeUnqual(Len == 2 ? const Type *PTy = PointerType::getUnqual(Len == 2 ?
Type::Int16Ty : Type::Int32Ty); Type::Int16Ty : Type::Int32Ty);
LHS = B.CreateBitCast(LHS, PTy, "tmp"); LHS = B.CreateBitCast(LHS, PTy, "tmp");
RHS = B.CreateBitCast(RHS, PTy, "tmp"); RHS = B.CreateBitCast(RHS, PTy, "tmp");

View File

@ -151,8 +151,7 @@ Function *llvm::CloneFunction(const Function *F,
ArgTypes.push_back(I->getType()); ArgTypes.push_back(I->getType());
// Create a new function type... // Create a new function type...
FunctionType *FTy = FunctionType *FTy = FunctionType::get(F->getFunctionType()->getReturnType(),
F->getContext().getFunctionType(F->getFunctionType()->getReturnType(),
ArgTypes, F->getFunctionType()->isVarArg()); ArgTypes, F->getFunctionType()->isVarArg());
// Create the new function... // Create the new function...

View File

@ -266,8 +266,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
if (AggregateArgs) if (AggregateArgs)
paramTy.push_back((*I)->getType()); paramTy.push_back((*I)->getType());
else else
paramTy.push_back( paramTy.push_back(PointerType::getUnqual((*I)->getType()));
header->getContext().getPointerTypeUnqual((*I)->getType()));
} }
DOUT << "Function type: " << *RetTy << " f("; DOUT << "Function type: " << *RetTy << " f(";
@ -278,12 +277,12 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
PointerType *StructPtr = PointerType *StructPtr =
Context.getPointerTypeUnqual(Context.getStructType(paramTy)); PointerType::getUnqual(StructType::get(paramTy));
paramTy.clear(); paramTy.clear();
paramTy.push_back(StructPtr); paramTy.push_back(StructPtr);
} }
const FunctionType *funcType = const FunctionType *funcType =
Context.getFunctionType(RetTy, paramTy, false); FunctionType::get(RetTy, paramTy, false);
// Create the new function // Create the new function
Function *newFunction = Function::Create(funcType, Function *newFunction = Function::Create(funcType,
@ -387,7 +386,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
ArgTypes.push_back((*v)->getType()); ArgTypes.push_back((*v)->getType());
// Allocate a struct at the beginning of this function // Allocate a struct at the beginning of this function
Type *StructArgTy = Context.getStructType(ArgTypes); Type *StructArgTy = StructType::get(ArgTypes);
Struct = Struct =
new AllocaInst(StructArgTy, 0, "structArg", new AllocaInst(StructArgTy, 0, "structArg",
codeReplacer->getParent()->begin()->begin()); codeReplacer->getParent()->begin()->begin());

View File

@ -304,7 +304,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) && if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) &&
!CalledFunc->onlyReadsMemory()) { !CalledFunc->onlyReadsMemory()) {
const Type *AggTy = cast<PointerType>(I->getType())->getElementType(); const Type *AggTy = cast<PointerType>(I->getType())->getElementType();
const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty); const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
// Create the alloca. If we have TargetData, use nice alignment. // Create the alloca. If we have TargetData, use nice alignment.
unsigned Align = 1; unsigned Align = 1;

View File

@ -87,10 +87,10 @@ Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) {
// This function is always successful. // This function is always successful.
// //
bool LowerAllocations::doInitialization(Module &M) { bool LowerAllocations::doInitialization(Module &M) {
const Type *BPTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty); const Type *BPTy = PointerType::getUnqual(Type::Int8Ty);
// Prototype malloc as "char* malloc(...)", because we don't know in // Prototype malloc as "char* malloc(...)", because we don't know in
// doInitialization whether size_t is int or long. // doInitialization whether size_t is int or long.
FunctionType *FT = M.getContext().getFunctionType(BPTy, true); FunctionType *FT = FunctionType::get(BPTy, true);
MallocFunc = M.getOrInsertFunction("malloc", FT); MallocFunc = M.getOrInsertFunction("malloc", FT);
FreeFunc = M.getOrInsertFunction("free" , Type::VoidTy, BPTy, (Type *)0); FreeFunc = M.getOrInsertFunction("free" , Type::VoidTy, BPTy, (Type *)0);
return true; return true;
@ -166,7 +166,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) { } else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
Value *PtrCast = Value *PtrCast =
new BitCastInst(FI->getOperand(0), new BitCastInst(FI->getOperand(0),
Context.getPointerTypeUnqual(Type::Int8Ty), "", I); PointerType::getUnqual(Type::Int8Ty), "", I);
// Insert a call to the free function... // Insert a call to the free function...
CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall(); CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();

View File

@ -117,26 +117,26 @@ FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
bool LowerInvoke::doInitialization(Module &M) { bool LowerInvoke::doInitialization(Module &M) {
LLVMContext &Context = M.getContext(); LLVMContext &Context = M.getContext();
const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty); const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
AbortMessage = 0; AbortMessage = 0;
if (ExpensiveEHSupport) { if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers. // Insert a type for the linked list of jump buffers.
unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0; unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0;
JBSize = JBSize ? JBSize : 200; JBSize = JBSize ? JBSize : 200;
const Type *JmpBufTy = Context.getArrayType(VoidPtrTy, JBSize); const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize);
{ // The type is recursive, so use a type holder. { // The type is recursive, so use a type holder.
std::vector<const Type*> Elements; std::vector<const Type*> Elements;
Elements.push_back(JmpBufTy); Elements.push_back(JmpBufTy);
OpaqueType *OT = Context.getOpaqueType(); OpaqueType *OT = OpaqueType::get();
Elements.push_back(Context.getPointerTypeUnqual(OT)); Elements.push_back(PointerType::getUnqual(OT));
PATypeHolder JBLType(Context.getStructType(Elements)); PATypeHolder JBLType(StructType::get(Elements));
OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle. OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle.
JBLinkTy = JBLType.get(); JBLinkTy = JBLType.get();
M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy); M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);
} }
const Type *PtrJBList = Context.getPointerTypeUnqual(JBLinkTy); const Type *PtrJBList = PointerType::getUnqual(JBLinkTy);
// Now that we've done that, insert the jmpbuf list head global, unless it // Now that we've done that, insert the jmpbuf list head global, unless it
// already exists. // already exists.

View File

@ -27,8 +27,6 @@ using namespace llvm;
static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
assert(F && "Illegal to upgrade a non-existent Function."); assert(F && "Illegal to upgrade a non-existent Function.");
LLVMContext &Context = F->getContext();
// Get the Function's name. // Get the Function's name.
const std::string& Name = F->getName(); const std::string& Name = F->getName();
@ -167,7 +165,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') { Name.compare(13,4,"psrl", 4) == 0) && Name[17] != 'i') {
const llvm::Type *VT = const llvm::Type *VT =
Context.getVectorType(Context.getIntegerType(64), 1); VectorType::get(IntegerType::get(64), 1);
// We don't have to do anything if the parameter already has // We don't have to do anything if the parameter already has
// the correct type. // the correct type.
@ -268,7 +266,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
if (isLoadH || isLoadL) { if (isLoadH || isLoadL) {
Value *Op1 = Context.getUndef(Op0->getType()); Value *Op1 = Context.getUndef(Op0->getType());
Value *Addr = new BitCastInst(CI->getOperand(2), Value *Addr = new BitCastInst(CI->getOperand(2),
Context.getPointerTypeUnqual(Type::DoubleTy), PointerType::getUnqual(Type::DoubleTy),
"upgraded.", CI); "upgraded.", CI);
Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI); Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI);
Value *Idx = ConstantInt::get(Type::Int32Ty, 0); Value *Idx = ConstantInt::get(Type::Int32Ty, 0);

View File

@ -1373,7 +1373,7 @@ Constant *llvm::ConstantFoldCompareInstruction(LLVMContext &Context,
const Constant *C2) { const Constant *C2) {
const Type *ResultTy; const Type *ResultTy;
if (const VectorType *VT = dyn_cast<VectorType>(C1->getType())) if (const VectorType *VT = dyn_cast<VectorType>(C1->getType()))
ResultTy = Context.getVectorType(Type::Int1Ty, VT->getNumElements()); ResultTy = VectorType::get(Type::Int1Ty, VT->getNumElements());
else else
ResultTy = Type::Int1Ty; ResultTy = Type::Int1Ty;
@ -1677,7 +1677,7 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
(Value **)Idxs, (Value **)Idxs,
(Value **)Idxs+NumIdx); (Value **)Idxs+NumIdx);
assert(Ty != 0 && "Invalid indices for GEP!"); assert(Ty != 0 && "Invalid indices for GEP!");
return Context.getUndef(Context.getPointerType(Ty, Ptr->getAddressSpace())); return Context.getUndef(PointerType::get(Ty, Ptr->getAddressSpace()));
} }
Constant *Idx0 = Idxs[0]; Constant *Idx0 = Idxs[0];
@ -1695,7 +1695,7 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context,
(Value**)Idxs+NumIdx); (Value**)Idxs+NumIdx);
assert(Ty != 0 && "Invalid indices for GEP!"); assert(Ty != 0 && "Invalid indices for GEP!");
return Context.getConstantPointerNull( return Context.getConstantPointerNull(
Context.getPointerType(Ty,Ptr->getAddressSpace())); PointerType::get(Ty,Ptr->getAddressSpace()));
} }
} }

View File

@ -178,7 +178,7 @@ ConstantInt::ConstantInt(const IntegerType *Ty, const APInt& V)
// invariant which generates an assertion. // invariant which generates an assertion.
ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt& V) { ConstantInt *ConstantInt::get(LLVMContext &Context, const APInt& V) {
// Get the corresponding integer type for the bit width of the value. // Get the corresponding integer type for the bit width of the value.
const IntegerType *ITy = Context.getIntegerType(V.getBitWidth()); const IntegerType *ITy = IntegerType::get(V.getBitWidth());
// get an existing value or the insertion position // get an existing value or the insertion position
DenseMapAPIntKeyInfo::KeyTy Key(V, ITy); DenseMapAPIntKeyInfo::KeyTy Key(V, ITy);

View File

@ -162,7 +162,7 @@ LLVMTypeRef LLVMInt32Type(void) { return (LLVMTypeRef) Type::Int32Ty; }
LLVMTypeRef LLVMInt64Type(void) { return (LLVMTypeRef) Type::Int64Ty; } LLVMTypeRef LLVMInt64Type(void) { return (LLVMTypeRef) Type::Int64Ty; }
LLVMTypeRef LLVMIntType(unsigned NumBits) { LLVMTypeRef LLVMIntType(unsigned NumBits) {
return wrap(getGlobalContext().getIntegerType(NumBits)); return wrap(IntegerType::get(NumBits));
} }
unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) { unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy) {
@ -186,8 +186,7 @@ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType,
for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I)
Tys.push_back(unwrap(*I)); Tys.push_back(unwrap(*I));
return wrap(getGlobalContext().getFunctionType(unwrap(ReturnType), Tys, return wrap(FunctionType::get(unwrap(ReturnType), Tys, IsVarArg != 0));
IsVarArg != 0));
} }
int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy) { int LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy) {
@ -218,7 +217,7 @@ LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes,
*E = ElementTypes + ElementCount; I != E; ++I) *E = ElementTypes + ElementCount; I != E; ++I)
Tys.push_back(unwrap(*I)); Tys.push_back(unwrap(*I));
return wrap(getGlobalContext().getStructType(Tys, Packed != 0)); return wrap(StructType::get(Tys, Packed != 0));
} }
unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) { unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) {
@ -239,18 +238,15 @@ int LLVMIsPackedStruct(LLVMTypeRef StructTy) {
/*--.. Operations on array, pointer, and vector types (sequence types) .....--*/ /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/
LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) { LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) {
return wrap(getGlobalContext().getArrayType(unwrap(ElementType), return wrap(ArrayType::get(unwrap(ElementType), ElementCount));
ElementCount));
} }
LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) { LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) {
return wrap(getGlobalContext().getPointerType(unwrap(ElementType), return wrap(PointerType::get(unwrap(ElementType), AddressSpace));
AddressSpace));
} }
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) { LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {
return wrap(getGlobalContext().getVectorType(unwrap(ElementType), return wrap(VectorType::get(unwrap(ElementType), ElementCount));
ElementCount));
} }
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty) { LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty) {
@ -275,7 +271,7 @@ LLVMTypeRef LLVMVoidType(void) { return (LLVMTypeRef) Type::VoidTy; }
LLVMTypeRef LLVMLabelType(void) { return (LLVMTypeRef) Type::LabelTy; } LLVMTypeRef LLVMLabelType(void) { return (LLVMTypeRef) Type::LabelTy; }
LLVMTypeRef LLVMOpaqueType(void) { LLVMTypeRef LLVMOpaqueType(void) {
return wrap(getGlobalContext().getOpaqueType()); return wrap(OpaqueType::get());
} }
/*--.. Operations on type handles ..........................................--*/ /*--.. Operations on type handles ..........................................--*/
@ -408,8 +404,7 @@ LLVMValueRef LLVMConstString(const char *Str, unsigned Length,
LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy,
LLVMValueRef *ConstantVals, unsigned Length) { LLVMValueRef *ConstantVals, unsigned Length) {
return wrap(ConstantArray::get( return wrap(ConstantArray::get(ArrayType::get(unwrap(ElementTy), Length),
getGlobalContext().getArrayType(unwrap(ElementTy), Length),
unwrap<Constant>(ConstantVals, Length), unwrap<Constant>(ConstantVals, Length),
Length)); Length));
} }

View File

@ -346,7 +346,7 @@ const FunctionType *Intrinsic::getType(LLVMContext &Context,
#include "llvm/Intrinsics.gen" #include "llvm/Intrinsics.gen"
#undef GET_INTRINSIC_GENERATOR #undef GET_INTRINSIC_GENERATOR
return Context.getFunctionType(ResultTy, ArgTys, IsVarArg); return FunctionType::get(ResultTy, ArgTys, IsVarArg);
} }
bool Intrinsic::isOverloaded(ID id) { bool Intrinsic::isOverloaded(ID id) {

View File

@ -98,7 +98,7 @@ GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
bool constant, LinkageTypes Link, bool constant, LinkageTypes Link,
Constant *InitVal, const Twine &Name, Constant *InitVal, const Twine &Name,
bool ThreadLocal, unsigned AddressSpace) bool ThreadLocal, unsigned AddressSpace)
: GlobalValue(Context.getPointerType(Ty, AddressSpace), : GlobalValue(PointerType::get(Ty, AddressSpace),
Value::GlobalVariableVal, Value::GlobalVariableVal,
OperandTraits<GlobalVariable>::op_begin(this), OperandTraits<GlobalVariable>::op_begin(this),
InitVal != 0, Link, Name), InitVal != 0, Link, Name),
@ -117,7 +117,7 @@ GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant,
const Twine &Name, const Twine &Name,
GlobalVariable *Before, bool ThreadLocal, GlobalVariable *Before, bool ThreadLocal,
unsigned AddressSpace) unsigned AddressSpace)
: GlobalValue(M.getContext().getPointerType(Ty, AddressSpace), : GlobalValue(PointerType::get(Ty, AddressSpace),
Value::GlobalVariableVal, Value::GlobalVariableVal,
OperandTraits<GlobalVariable>::op_begin(this), OperandTraits<GlobalVariable>::op_begin(this),
InitVal != 0, Link, Name), InitVal != 0, Link, Name),

View File

@ -716,7 +716,7 @@ static Value *getAISize(LLVMContext &Context, Value *Amt) {
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
unsigned Align, const Twine &Name, unsigned Align, const Twine &Name,
Instruction *InsertBefore) Instruction *InsertBefore)
: UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy, : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertBefore) { getAISize(Ty->getContext(), ArraySize), InsertBefore) {
setAlignment(Align); setAlignment(Align);
assert(Ty != Type::VoidTy && "Cannot allocate void!"); assert(Ty != Type::VoidTy && "Cannot allocate void!");
@ -726,7 +726,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
unsigned Align, const Twine &Name, unsigned Align, const Twine &Name,
BasicBlock *InsertAtEnd) BasicBlock *InsertAtEnd)
: UnaryInstruction(Ty->getContext().getPointerTypeUnqual(Ty), iTy, : UnaryInstruction(PointerType::getUnqual(Ty), iTy,
getAISize(Ty->getContext(), ArraySize), InsertAtEnd) { getAISize(Ty->getContext(), ArraySize), InsertAtEnd) {
setAlignment(Align); setAlignment(Align);
assert(Ty != Type::VoidTy && "Cannot allocate void!"); assert(Ty != Type::VoidTy && "Cannot allocate void!");
@ -1046,7 +1046,7 @@ GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
const Twine &Name, Instruction *InBe) const Twine &Name, Instruction *InBe)
: Instruction(Ptr->getType()->getContext().getPointerType( : Instruction(PointerType::get(
checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)), checkType(getIndexedType(Ptr->getType(),Idx)), retrieveAddrSpace(Ptr)),
GetElementPtr, GetElementPtr,
OperandTraits<GetElementPtrInst>::op_end(this) - 2, OperandTraits<GetElementPtrInst>::op_end(this) - 2,
@ -1056,7 +1056,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
const Twine &Name, BasicBlock *IAE) const Twine &Name, BasicBlock *IAE)
: Instruction(Ptr->getType()->getContext().getPointerType( : Instruction(PointerType::get(
checkType(getIndexedType(Ptr->getType(),Idx)), checkType(getIndexedType(Ptr->getType(),Idx)),
retrieveAddrSpace(Ptr)), retrieveAddrSpace(Ptr)),
GetElementPtr, GetElementPtr,
@ -1270,8 +1270,7 @@ ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask, ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
const Twine &Name, const Twine &Name,
Instruction *InsertBefore) Instruction *InsertBefore)
: Instruction(V1->getType()->getContext().getVectorType( : Instruction(VectorType::get(cast<VectorType>(V1->getType())->getElementType(),
cast<VectorType>(V1->getType())->getElementType(),
cast<VectorType>(Mask->getType())->getNumElements()), cast<VectorType>(Mask->getType())->getNumElements()),
ShuffleVector, ShuffleVector,
OperandTraits<ShuffleVectorInst>::op_begin(this), OperandTraits<ShuffleVectorInst>::op_begin(this),

View File

@ -113,89 +113,6 @@ MDString* LLVMContext::getMDString(const StringRef &Str) {
return pImpl->getMDString(Str.data(), Str.size()); return pImpl->getMDString(Str.data(), Str.size());
} }
// FunctionType accessors
FunctionType* LLVMContext::getFunctionType(const Type* Result, bool isVarArg) {
return FunctionType::get(Result, isVarArg);
}
FunctionType* LLVMContext::getFunctionType(const Type* Result,
const std::vector<const Type*>& Params,
bool isVarArg) {
return FunctionType::get(Result, Params, isVarArg);
}
// IntegerType accessors
const IntegerType* LLVMContext::getIntegerType(unsigned NumBits) {
return IntegerType::get(NumBits);
}
// OpaqueType accessors
OpaqueType* LLVMContext::getOpaqueType() {
return OpaqueType::get();
}
// StructType accessors
StructType* LLVMContext::getStructType(bool isPacked) {
return StructType::get(isPacked);
}
StructType* LLVMContext::getStructType(const std::vector<const Type*>& Params,
bool isPacked) {
return StructType::get(Params, isPacked);
}
StructType *LLVMContext::getStructType(const Type *type, ...) {
va_list ap;
std::vector<const llvm::Type*> StructFields;
va_start(ap, type);
while (type) {
StructFields.push_back(type);
type = va_arg(ap, llvm::Type*);
}
return StructType::get(StructFields);
}
// ArrayType accessors
ArrayType* LLVMContext::getArrayType(const Type* ElementType,
uint64_t NumElements) {
return ArrayType::get(ElementType, NumElements);
}
// PointerType accessors
PointerType* LLVMContext::getPointerType(const Type* ElementType,
unsigned AddressSpace) {
return PointerType::get(ElementType, AddressSpace);
}
PointerType* LLVMContext::getPointerTypeUnqual(const Type* ElementType) {
return PointerType::getUnqual(ElementType);
}
// VectorType accessors
VectorType* LLVMContext::getVectorType(const Type* ElementType,
unsigned NumElements) {
return VectorType::get(ElementType, NumElements);
}
VectorType* LLVMContext::getVectorTypeInteger(const VectorType* VTy) {
return VectorType::getInteger(VTy);
}
VectorType* LLVMContext::getVectorTypeExtendedElement(const VectorType* VTy) {
return VectorType::getExtendedElementVectorType(VTy);
}
VectorType* LLVMContext::getVectorTypeTruncatedElement(const VectorType* VTy) {
return VectorType::getTruncatedElementVectorType(VTy);
}
const Type* LLVMContext::makeCmpResultType(const Type* opnd_type) {
if (const VectorType* vt = dyn_cast<const VectorType>(opnd_type)) {
return getVectorType(Type::Int1Ty, vt->getNumElements());
}
return Type::Int1Ty;
}
void LLVMContext::erase(MDString *M) { void LLVMContext::erase(MDString *M) {
pImpl->erase(M); pImpl->erase(M);
} }

View File

@ -153,8 +153,8 @@ Constant *Module::getOrInsertFunction(const StringRef &Name,
// If the function exists but has the wrong type, return a bitcast to the // If the function exists but has the wrong type, return a bitcast to the
// right type. // right type.
if (F->getType() != Context.getPointerTypeUnqual(Ty)) if (F->getType() != PointerType::getUnqual(Ty))
return ConstantExpr::getBitCast(F, Context.getPointerTypeUnqual(Ty)); return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty));
// Otherwise, we just found the existing function or a prototype. // Otherwise, we just found the existing function or a prototype.
return F; return F;
@ -203,7 +203,7 @@ Constant *Module::getOrInsertFunction(const StringRef &Name,
// Build the function type and chain to the other getOrInsertFunction... // Build the function type and chain to the other getOrInsertFunction...
return getOrInsertFunction(Name, return getOrInsertFunction(Name,
Context.getFunctionType(RetTy, ArgTys, false), FunctionType::get(RetTy, ArgTys, false),
AttributeList); AttributeList);
} }
@ -221,7 +221,7 @@ Constant *Module::getOrInsertFunction(const StringRef &Name,
// Build the function type and chain to the other getOrInsertFunction... // Build the function type and chain to the other getOrInsertFunction...
return getOrInsertFunction(Name, return getOrInsertFunction(Name,
Context.getFunctionType(RetTy, ArgTys, false), FunctionType::get(RetTy, ArgTys, false),
AttrListPtr::get((AttributeWithIndex *)0, 0)); AttrListPtr::get((AttributeWithIndex *)0, 0));
} }
@ -271,8 +271,8 @@ Constant *Module::getOrInsertGlobal(const StringRef &Name, const Type *Ty) {
// If the variable exists but has the wrong type, return a bitcast to the // If the variable exists but has the wrong type, return a bitcast to the
// right type. // right type.
if (GV->getType() != Context.getPointerTypeUnqual(Ty)) if (GV->getType() != PointerType::getUnqual(Ty))
return ConstantExpr::getBitCast(GV, Context.getPointerTypeUnqual(Ty)); return ConstantExpr::getBitCast(GV, PointerType::getUnqual(Ty));
// Otherwise, we just found the existing function or a prototype. // Otherwise, we just found the existing function or a prototype.
return GV; return GV;

View File

@ -21,16 +21,14 @@ using namespace llvm;
MVT MVT::getExtendedIntegerVT(unsigned BitWidth) { MVT MVT::getExtendedIntegerVT(unsigned BitWidth) {
MVT VT; MVT VT;
VT.LLVMTy = getGlobalContext().getIntegerType(BitWidth); VT.LLVMTy = IntegerType::get(BitWidth);
assert(VT.isExtended() && "Type is not extended!"); assert(VT.isExtended() && "Type is not extended!");
return VT; return VT;
} }
MVT MVT::getExtendedVectorVT(MVT VT, unsigned NumElements) { MVT MVT::getExtendedVectorVT(MVT VT, unsigned NumElements) {
MVT ResultVT; MVT ResultVT;
ResultVT.LLVMTy = getGlobalContext().getVectorType( ResultVT.LLVMTy = VectorType::get(VT.getTypeForMVT(), NumElements);
VT.getTypeForMVT(getGlobalContext()),
NumElements);
assert(ResultVT.isExtended() && "Type is not extended!"); assert(ResultVT.isExtended() && "Type is not extended!");
return ResultVT; return ResultVT;
} }
@ -133,7 +131,7 @@ std::string MVT::getMVTString() const {
/// getTypeForMVT - This method returns an LLVM type corresponding to the /// getTypeForMVT - This method returns an LLVM type corresponding to the
/// specified MVT. For integer types, this returns an unsigned type. Note /// specified MVT. For integer types, this returns an unsigned type. Note
/// that this will abort for types that cannot be represented. /// that this will abort for types that cannot be represented.
const Type *MVT::getTypeForMVT(LLVMContext &Context) const { const Type *MVT::getTypeForMVT() const {
switch (V) { switch (V) {
default: default:
assert(isExtended() && "Type is not extended!"); assert(isExtended() && "Type is not extended!");
@ -144,32 +142,32 @@ const Type *MVT::getTypeForMVT(LLVMContext &Context) const {
case MVT::i16: return Type::Int16Ty; case MVT::i16: return Type::Int16Ty;
case MVT::i32: return Type::Int32Ty; case MVT::i32: return Type::Int32Ty;
case MVT::i64: return Type::Int64Ty; case MVT::i64: return Type::Int64Ty;
case MVT::i128: return Context.getIntegerType(128); case MVT::i128: return IntegerType::get(128);
case MVT::f32: return Type::FloatTy; case MVT::f32: return Type::FloatTy;
case MVT::f64: return Type::DoubleTy; case MVT::f64: return Type::DoubleTy;
case MVT::f80: return Type::X86_FP80Ty; case MVT::f80: return Type::X86_FP80Ty;
case MVT::f128: return Type::FP128Ty; case MVT::f128: return Type::FP128Ty;
case MVT::ppcf128: return Type::PPC_FP128Ty; case MVT::ppcf128: return Type::PPC_FP128Ty;
case MVT::v2i8: return Context.getVectorType(Type::Int8Ty, 2); case MVT::v2i8: return VectorType::get(Type::Int8Ty, 2);
case MVT::v4i8: return Context.getVectorType(Type::Int8Ty, 4); case MVT::v4i8: return VectorType::get(Type::Int8Ty, 4);
case MVT::v8i8: return Context.getVectorType(Type::Int8Ty, 8); case MVT::v8i8: return VectorType::get(Type::Int8Ty, 8);
case MVT::v16i8: return Context.getVectorType(Type::Int8Ty, 16); case MVT::v16i8: return VectorType::get(Type::Int8Ty, 16);
case MVT::v32i8: return Context.getVectorType(Type::Int8Ty, 32); case MVT::v32i8: return VectorType::get(Type::Int8Ty, 32);
case MVT::v2i16: return Context.getVectorType(Type::Int16Ty, 2); case MVT::v2i16: return VectorType::get(Type::Int16Ty, 2);
case MVT::v4i16: return Context.getVectorType(Type::Int16Ty, 4); case MVT::v4i16: return VectorType::get(Type::Int16Ty, 4);
case MVT::v8i16: return Context.getVectorType(Type::Int16Ty, 8); case MVT::v8i16: return VectorType::get(Type::Int16Ty, 8);
case MVT::v16i16: return Context.getVectorType(Type::Int16Ty, 16); case MVT::v16i16: return VectorType::get(Type::Int16Ty, 16);
case MVT::v2i32: return Context.getVectorType(Type::Int32Ty, 2); case MVT::v2i32: return VectorType::get(Type::Int32Ty, 2);
case MVT::v4i32: return Context.getVectorType(Type::Int32Ty, 4); case MVT::v4i32: return VectorType::get(Type::Int32Ty, 4);
case MVT::v8i32: return Context.getVectorType(Type::Int32Ty, 8); case MVT::v8i32: return VectorType::get(Type::Int32Ty, 8);
case MVT::v1i64: return Context.getVectorType(Type::Int64Ty, 1); case MVT::v1i64: return VectorType::get(Type::Int64Ty, 1);
case MVT::v2i64: return Context.getVectorType(Type::Int64Ty, 2); case MVT::v2i64: return VectorType::get(Type::Int64Ty, 2);
case MVT::v4i64: return Context.getVectorType(Type::Int64Ty, 4); case MVT::v4i64: return VectorType::get(Type::Int64Ty, 4);
case MVT::v2f32: return Context.getVectorType(Type::FloatTy, 2); case MVT::v2f32: return VectorType::get(Type::FloatTy, 2);
case MVT::v4f32: return Context.getVectorType(Type::FloatTy, 4); case MVT::v4f32: return VectorType::get(Type::FloatTy, 4);
case MVT::v8f32: return Context.getVectorType(Type::FloatTy, 8); case MVT::v8f32: return VectorType::get(Type::FloatTy, 8);
case MVT::v2f64: return Context.getVectorType(Type::DoubleTy, 2); case MVT::v2f64: return VectorType::get(Type::DoubleTy, 2);
case MVT::v4f64: return Context.getVectorType(Type::DoubleTy, 4); case MVT::v4f64: return VectorType::get(Type::DoubleTy, 4);
} }
} }

View File

@ -1490,7 +1490,6 @@ static std::string IntrinsicParam(unsigned ArgNo, unsigned NumRets) {
bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty, bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty,
int VT, unsigned ArgNo, std::string &Suffix) { int VT, unsigned ArgNo, std::string &Suffix) {
const FunctionType *FTy = F->getFunctionType(); const FunctionType *FTy = F->getFunctionType();
LLVMContext &Context = FTy->getContext();
unsigned NumElts = 0; unsigned NumElts = 0;
const Type *EltTy = Ty; const Type *EltTy = Ty;
@ -1620,7 +1619,7 @@ bool Verifier::PerformTypeCheck(Intrinsic::ID ID, Function *F, const Type *Ty,
"vector elements!", F); "vector elements!", F);
return false; return false;
} }
} else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT(Context) != EltTy) { } else if (MVT((MVT::SimpleValueType)VT).getTypeForMVT() != EltTy) {
CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is wrong!", F); CheckFailed(IntrinsicParam(ArgNo, NumRets) + " is wrong!", F);
return false; return false;
} else if (EltTy != Ty) { } else if (EltTy != Ty) {

View File

@ -181,7 +181,6 @@ void llvm::DeleteFunctionBody(Function *F) {
/// as a constant array. /// as a constant array.
static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) { static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
assert(!TorList.empty() && "Don't create empty tor list!"); assert(!TorList.empty() && "Don't create empty tor list!");
LLVMContext &Context = TorList[0].first->getContext();
std::vector<Constant*> ArrayElts; std::vector<Constant*> ArrayElts;
for (unsigned i = 0, e = TorList.size(); i != e; ++i) { for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
std::vector<Constant*> Elts; std::vector<Constant*> Elts;
@ -189,7 +188,7 @@ static Constant *GetTorInit(std::vector<std::pair<Function*, int> > &TorList) {
Elts.push_back(TorList[i].first); Elts.push_back(TorList[i].first);
ArrayElts.push_back(ConstantStruct::get(Elts)); ArrayElts.push_back(ConstantStruct::get(Elts));
} }
return ConstantArray::get(Context.getArrayType(ArrayElts[0]->getType(), return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(),
ArrayElts.size()), ArrayElts.size()),
ArrayElts); ArrayElts);
} }

View File

@ -701,8 +701,8 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Prototype: void *getPointerToNamedFunction(const char* Name) // Prototype: void *getPointerToNamedFunction(const char* Name)
Constant *resolverFunc = Constant *resolverFunc =
Safe->getOrInsertFunction("getPointerToNamedFunction", Safe->getOrInsertFunction("getPointerToNamedFunction",
Context.getPointerTypeUnqual(Type::Int8Ty), PointerType::getUnqual(Type::Int8Ty),
Context.getPointerTypeUnqual(Type::Int8Ty), (Type *)0); PointerType::getUnqual(Type::Int8Ty), (Type *)0);
// Use the function we just added to get addresses of functions we need. // Use the function we just added to get addresses of functions we need.
for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) { for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
@ -765,7 +765,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
// Cast the result from the resolver to correctly-typed function. // Cast the result from the resolver to correctly-typed function.
CastInst *CastedResolver = CastInst *CastedResolver =
new BitCastInst(Resolver, new BitCastInst(Resolver,
Context.getPointerTypeUnqual(F->getFunctionType()), PointerType::getUnqual(F->getFunctionType()),
"resolverCast", LookupBB); "resolverCast", LookupBB);
// Save the value in our cache. // Save the value in our cache.

View File

@ -31,8 +31,7 @@ namespace {
Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) {
std::vector<const Type*> params; std::vector<const Type*> params;
const FunctionType *FTy = const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(),
getGlobalContext().getFunctionType(G->getType()->getElementType(),
params, false); params, false);
Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M);
BasicBlock *Entry = BasicBlock::Create("entry", F); BasicBlock *Entry = BasicBlock::Create("entry", F);

View File

@ -171,7 +171,7 @@ public:
st.push_back(TypeBuilder<int, cross>::get(Context)); st.push_back(TypeBuilder<int, cross>::get(Context));
st.push_back(TypeBuilder<int*, cross>::get(Context)); st.push_back(TypeBuilder<int*, cross>::get(Context));
st.push_back(TypeBuilder<void*[], cross>::get(Context)); st.push_back(TypeBuilder<void*[], cross>::get(Context));
static const StructType *const result = Context.getStructType(st); static const StructType *const result = StructType::get(st);
return result; return result;
} }
@ -194,7 +194,7 @@ public:
st.push_back(TypeBuilder<types::i<32>, cross>::get(Context)); st.push_back(TypeBuilder<types::i<32>, cross>::get(Context));
st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context)); st.push_back(TypeBuilder<types::i<32>*, cross>::get(Context));
st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context)); st.push_back(TypeBuilder<types::i<8>*[], cross>::get(Context));
static const StructType *const result = Context.getStructType(st); static const StructType *const result = StructType::get(st);
return result; return result;
} }

View File

@ -163,12 +163,12 @@ void CallingConvEmitter::EmitAction(Record *Action,
O << Size << ", "; O << Size << ", ";
else else
O << "\n" << IndentStr << " State.getTarget().getTargetData()" O << "\n" << IndentStr << " State.getTarget().getTargetData()"
"->getTypeAllocSize(LocVT.getTypeForMVT(State.getContext())), "; "->getTypeAllocSize(LocVT.getTypeForMVT()), ";
if (Align) if (Align)
O << Align; O << Align;
else else
O << "\n" << IndentStr << " State.getTarget().getTargetData()" O << "\n" << IndentStr << " State.getTarget().getTargetData()"
"->getABITypeAlignment(LocVT.getTypeForMVT(State.getContext()))"; "->getABITypeAlignment(LocVT.getTypeForMVT())";
O << ");\n" << IndentStr O << ");\n" << IndentStr
<< "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset" << "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
<< Counter << ", LocVT, LocInfo));\n"; << Counter << ", LocVT, LocInfo));\n";