Build fix for the latest LLVMContext changes (LLVM r75445)

This shouldn't break the build with older LLVM revs. We include
LLVMContext.h in gen/llvm.h now to make the transition a little bit
easier.
This commit is contained in:
Benjamin Kramer 2009-07-13 12:17:58 +02:00
parent 8576788245
commit 331319dab1
16 changed files with 36 additions and 38 deletions

View file

@ -105,7 +105,7 @@ DValue* DtoAAIndex(Loc& loc, Type* type, DValue* aa, DValue* key, bool lvalue)
llvm::BasicBlock* failbb = llvm::BasicBlock::Create("aaboundscheckfail", gIR->topfunc(), oldend); llvm::BasicBlock* failbb = llvm::BasicBlock::Create("aaboundscheckfail", gIR->topfunc(), oldend);
llvm::BasicBlock* okbb = llvm::BasicBlock::Create("aaboundsok", gIR->topfunc(), oldend); llvm::BasicBlock* okbb = llvm::BasicBlock::Create("aaboundsok", gIR->topfunc(), oldend);
LLValue* nullaa = LLConstant::getNullValue(ret->getType()); LLValue* nullaa = llvm::getGlobalContext().getNullValue(ret->getType());
LLValue* cond = gIR->ir->CreateICmpNE(nullaa, ret, "aaboundscheck"); LLValue* cond = gIR->ir->CreateICmpNE(nullaa, ret, "aaboundscheck");
gIR->ir->CreateCondBr(cond, okbb, failbb); gIR->ir->CreateCondBr(cond, okbb, failbb);

View file

@ -60,7 +60,7 @@ void DtoSetArrayToNull(LLValue* v)
assert(isaPointer(v)); assert(isaPointer(v));
const LLType* t = v->getType()->getContainedType(0); const LLType* t = v->getType()->getContainedType(0);
DtoStore(LLConstant::getNullValue(t), v); DtoStore(llvm::getGlobalContext().getNullValue(t), v);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////

View file

@ -211,7 +211,7 @@ void DtoInitClass(TypeClass* tc, LLValue* dst)
// monitor always defaults to zero // monitor always defaults to zero
tmp = DtoGEPi(dst,0,1,"monitor"); tmp = DtoGEPi(dst,0,1,"monitor");
val = llvm::Constant::getNullValue(tmp->getType()->getContainedType(0)); val = llvm::getGlobalContext().getNullValue(tmp->getType()->getContainedType(0));
DtoStore(val, tmp); DtoStore(val, tmp);
// done? // done?
@ -262,7 +262,7 @@ DValue* DtoCastClass(DValue* val, Type* _to)
else if (to->ty == Tbool) { else if (to->ty == Tbool) {
IF_LOG Logger::println("to bool"); IF_LOG Logger::println("to bool");
LLValue* llval = val->getRVal(); LLValue* llval = val->getRVal();
LLValue* zero = LLConstant::getNullValue(llval->getType()); LLValue* zero = llvm::getGlobalContext().getNullValue(llval->getType());
return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp")); return new DImValue(_to, gIR->ir->CreateICmpNE(llval, zero, "tmp"));
} }
// class -> integer // class -> integer
@ -326,8 +326,8 @@ DValue* DtoCastClass(DValue* val, Type* _to)
// Sure we could have jumped over the code above in this case, but // Sure we could have jumped over the code above in this case, but
// it's just a GEP and (maybe) a pointer-to-pointer BitCast, so it // it's just a GEP and (maybe) a pointer-to-pointer BitCast, so it
// should be pretty cheap and perfectly safe even if the original was null. // should be pretty cheap and perfectly safe even if the original was null.
LLValue* isNull = gIR->ir->CreateICmpEQ(orig, LLConstant::getNullValue(orig->getType()), ".nullcheck"); LLValue* isNull = gIR->ir->CreateICmpEQ(orig, llvm::getGlobalContext().getNullValue(orig->getType()), ".nullcheck");
v = gIR->ir->CreateSelect(isNull, LLConstant::getNullValue(ifType), v, ".interface"); v = gIR->ir->CreateSelect(isNull, llvm::getGlobalContext().getNullValue(ifType), v, ".interface");
// return r-value // return r-value
return new DImValue(_to, v); return new DImValue(_to, v);
@ -602,7 +602,7 @@ static LLConstant* build_offti_array(ClassDeclaration* cd, const LLType* arrayT)
LLConstant* ptr; LLConstant* ptr;
if (nvars == 0) if (nvars == 0)
return LLConstant::getNullValue( arrayT ); return llvm::getGlobalContext().getNullValue( arrayT );
// array type // array type
const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars); const llvm::ArrayType* arrTy = llvm::ArrayType::get(arrayInits[0]->getType(), nvars);

View file

@ -111,9 +111,9 @@ DValue* DtoComplex(Loc& loc, Type* to, DValue* val)
DtoGetComplexParts(loc, to, val, re, im); DtoGetComplexParts(loc, to, val, re, im);
if(!re) if(!re)
re = LLConstant::getNullValue(DtoType(baserety)); re = llvm::getGlobalContext().getNullValue(DtoType(baserety));
if(!im) if(!im)
im = LLConstant::getNullValue(DtoType(baseimty)); im = llvm::getGlobalContext().getNullValue(DtoType(baseimty));
LLValue* res = DtoAggrPair(complexTy, re, im); LLValue* res = DtoAggrPair(complexTy, re, im);

View file

@ -811,7 +811,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
} }
} }
else else
llvm::ReturnInst::Create(llvm::Constant::getNullValue(func->getReturnType()), bb); llvm::ReturnInst::Create(llvm::getGlobalContext().getNullValue(func->getReturnType()), bb);
} }
// std::cout << *func << std::endl; // std::cout << *func << std::endl;

View file

@ -11,6 +11,7 @@
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Value.h" #include "llvm/Value.h"
#include "llvm/Attributes.h" #include "llvm/Attributes.h"
#include "llvm/LLVMContext.h"
#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetData.h"

View file

@ -464,13 +464,13 @@ DValue* DtoNullValue(Type* type)
if (basetype->iscomplex()) if (basetype->iscomplex())
{ {
const LLType* basefp = DtoComplexBaseType(basetype); const LLType* basefp = DtoComplexBaseType(basetype);
LLValue* res = DtoAggrPair(DtoType(type), LLConstant::getNullValue(basefp), LLConstant::getNullValue(basefp)); LLValue* res = DtoAggrPair(DtoType(type), llvm::getGlobalContext().getNullValue(basefp), llvm::getGlobalContext().getNullValue(basefp));
return new DImValue(type, res); return new DImValue(type, res);
} }
// integer, floating, pointer and class have no special representation // integer, floating, pointer and class have no special representation
else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass) else if (basetype->isintegral() || basetype->isfloating() || basety == Tpointer || basety == Tclass)
{ {
return new DConstValue(type, LLConstant::getNullValue(lltype)); return new DConstValue(type, llvm::getGlobalContext().getNullValue(lltype));
} }
// dynamic array // dynamic array
else if (basety == Tarray) else if (basety == Tarray)
@ -482,7 +482,7 @@ DValue* DtoNullValue(Type* type)
// delegate // delegate
else if (basety == Tdelegate) else if (basety == Tdelegate)
{ {
return new DNullValue(type, LLConstant::getNullValue(lltype)); return new DNullValue(type, llvm::getGlobalContext().getNullValue(lltype));
} }
// unknown // unknown
@ -577,7 +577,7 @@ DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to)
} }
else if (totype->ty == Tbool) { else if (totype->ty == Tbool) {
LLValue* src = val->getRVal(); LLValue* src = val->getRVal();
LLValue* zero = LLConstant::getNullValue(src->getType()); LLValue* zero = llvm::getGlobalContext().getNullValue(src->getType());
rval = gIR->ir->CreateICmpNE(src, zero, "tmp"); rval = gIR->ir->CreateICmpNE(src, zero, "tmp");
} }
else if (totype->isintegral()) { else if (totype->isintegral()) {
@ -609,7 +609,7 @@ DValue* DtoCastFloat(Loc& loc, DValue* val, Type* to)
if (totype->ty == Tbool) { if (totype->ty == Tbool) {
rval = val->getRVal(); rval = val->getRVal();
LLValue* zero = LLConstant::getNullValue(rval->getType()); LLValue* zero = llvm::getGlobalContext().getNullValue(rval->getType());
rval = gIR->ir->CreateFCmpUNE(rval, zero, "tmp"); rval = gIR->ir->CreateFCmpUNE(rval, zero, "tmp");
} }
else if (totype->iscomplex()) { else if (totype->iscomplex()) {
@ -1124,7 +1124,7 @@ LLConstant* DtoConstInitializer(Loc loc, Type* type, Initializer* init)
{ {
Logger::println("const void initializer"); Logger::println("const void initializer");
const LLType* ty = DtoType(type); const LLType* ty = DtoType(type);
_init = llvm::Constant::getNullValue(ty); _init = llvm::getGlobalContext().getNullValue(ty);
} }
else { else {
Logger::println("unsupported const initializer: %s", init->toChars()); Logger::println("unsupported const initializer: %s", init->toChars());

View file

@ -7,7 +7,6 @@
#include "gen/llvm-version.h" #include "gen/llvm-version.h"
#include "llvm/LinkAllVMCore.h" #include "llvm/LinkAllVMCore.h"
#include "llvm/Linker.h" #include "llvm/Linker.h"
#include "llvm/LLVMContext.h"
#include "llvm/System/Signals.h" #include "llvm/System/Signals.h"
#include "llvm/Target/SubtargetFeature.h" #include "llvm/Target/SubtargetFeature.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"

View file

@ -1,6 +1,5 @@
#include "gen/llvm.h" #include "gen/llvm.h"
#include "gen/llvm-version.h" #include "gen/llvm-version.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Attributes.h" #include "llvm/Attributes.h"
#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Bitcode/ReaderWriter.h"

View file

@ -114,7 +114,7 @@ void ReturnStatement::toIR(IRState* p)
// and return 0 instead // and return 0 instead
// if we're not in main, just bitcast // if we're not in main, just bitcast
if (p->topfunc() == p->mainFunc) if (p->topfunc() == p->mainFunc)
v = llvm::Constant::getNullValue(p->mainFunc->getReturnType()); v = llvm::getGlobalContext().getNullValue(p->mainFunc->getReturnType());
else else
v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp"); v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
@ -1380,7 +1380,7 @@ void WithStatement::toIR(IRState* p)
static LLConstant* generate_unique_critical_section() static LLConstant* generate_unique_critical_section()
{ {
const LLType* Mty = DtoMutexType(); const LLType* Mty = DtoMutexType();
return new llvm::GlobalVariable(*gIR->module, Mty, false, llvm::GlobalValue::InternalLinkage, LLConstant::getNullValue(Mty), ".uniqueCS"); return new llvm::GlobalVariable(*gIR->module, Mty, false, llvm::GlobalValue::InternalLinkage, llvm::getGlobalContext().getNullValue(Mty), ".uniqueCS");
} }
void SynchronizedStatement::toIR(IRState* p) void SynchronizedStatement::toIR(IRState* p)

View file

@ -162,22 +162,22 @@ size_t add_zeros(std::vector<llvm::Value*>& values, size_t diff)
{ {
if (is64 && diff % 8 == 0) if (is64 && diff % 8 == 0)
{ {
values.push_back(llvm::Constant::getNullValue(llvm::Type::Int64Ty)); values.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int64Ty));
diff -= 8; diff -= 8;
} }
else if (diff % 4 == 0) else if (diff % 4 == 0)
{ {
values.push_back(llvm::Constant::getNullValue(llvm::Type::Int32Ty)); values.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int32Ty));
diff -= 4; diff -= 4;
} }
else if (diff % 2 == 0) else if (diff % 2 == 0)
{ {
values.push_back(llvm::Constant::getNullValue(llvm::Type::Int16Ty)); values.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int16Ty));
diff -= 2; diff -= 2;
} }
else else
{ {
values.push_back(llvm::Constant::getNullValue(llvm::Type::Int8Ty)); values.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int8Ty));
diff -= 1; diff -= 1;
} }
} }

View file

@ -19,7 +19,7 @@
using namespace llvm::dwarf; using namespace llvm::dwarf;
#define DBG_NULL ( LLConstant::getNullValue(DBG_TYPE) ) #define DBG_NULL ( llvm::getGlobalContext().getNullValue(DBG_TYPE) )
#define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) ) #define DBG_TYPE ( getPtrToType(llvm::StructType::get(NULL,NULL)) )
#define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) ) #define DBG_CAST(X) ( llvm::ConstantExpr::getBitCast(X, DBG_TYPE) )
@ -297,7 +297,7 @@ static llvm::DICompositeType dwarfCompositeType(Type* type, llvm::DICompileUnit
std::vector<LLConstant*> initvals(11); std::vector<LLConstant*> initvals(11);
initvals[0] = DBG_TAG(DW_TAG_structure_type); initvals[0] = DBG_TAG(DW_TAG_structure_type);
for (int i = 1; i < initvals.size(); ++i) for (int i = 1; i < initvals.size(); ++i)
initvals[i] = LLConstant::getNullValue(getDwarfCompositeTypeType()->getContainedType(i)); initvals[i] = llvm::getGlobalContext().getNullValue(getDwarfCompositeTypeType()->getContainedType(i));
gv->setInitializer(LLConstantStruct::get(getDwarfCompositeTypeType(), initvals)); gv->setInitializer(LLConstantStruct::get(getDwarfCompositeTypeType(), initvals));
ir->diCompositeType = llvm::DICompositeType(gv); ir->diCompositeType = llvm::DICompositeType(gv);

View file

@ -341,7 +341,7 @@ LLConstant* NullExp::toConstElem(IRState* p)
return llvm::ConstantAggregateZero::get(t); return llvm::ConstantAggregateZero::get(t);
} }
else { else {
return llvm::Constant::getNullValue(t); return llvm::getGlobalContext().getNullValue(t);
} }
assert(0); assert(0);
return NULL; return NULL;
@ -1656,7 +1656,7 @@ DValue* DeleteExp::toElem(IRState* p)
LLValue* rval = dval->getRVal(); LLValue* rval = dval->getRVal();
DtoDeleteMemory(rval); DtoDeleteMemory(rval);
if (dval->isVar()) if (dval->isVar())
DtoStore(llvm::Constant::getNullValue(rval->getType()), dval->getLVal()); DtoStore(llvm::getGlobalContext().getNullValue(rval->getType()), dval->getLVal());
} }
// class // class
else if (et->ty == Tclass) else if (et->ty == Tclass)
@ -1680,7 +1680,7 @@ DValue* DeleteExp::toElem(IRState* p)
} }
if (dval->isVar()) { if (dval->isVar()) {
LLValue* lval = dval->getLVal(); LLValue* lval = dval->getLVal();
DtoStore(llvm::Constant::getNullValue(lval->getType()->getContainedType(0)), lval); DtoStore(llvm::getGlobalContext().getNullValue(lval->getType()->getContainedType(0)), lval);
} }
} }
// dyn array // dyn array
@ -2547,7 +2547,7 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p)
// it should be possible to avoid the temporary in some cases // it should be possible to avoid the temporary in some cases
LLValue* tmp = DtoAlloca(type,"aaliteral"); LLValue* tmp = DtoAlloca(type,"aaliteral");
DValue* aa = new DVarValue(type, tmp); DValue* aa = new DVarValue(type, tmp);
DtoStore(LLConstant::getNullValue(DtoType(type)), tmp); DtoStore(llvm::getGlobalContext().getNullValue(DtoType(type)), tmp);
const size_t n = keys->dim; const size_t n = keys->dim;
for (size_t i=0; i<n; ++i) for (size_t i=0; i<n; ++i)

View file

@ -213,7 +213,7 @@ LLValue* DtoDelegateEquals(TOK op, LLValue* lhs, LLValue* rhs)
llvm::Value *b1, *b2; llvm::Value *b1, *b2;
if (rhs == NULL) if (rhs == NULL)
{ {
rhs = LLConstant::getNullValue(lhs->getType()); rhs = llvm::getGlobalContext().getNullValue(lhs->getType());
} }
LLValue* l = gIR->ir->CreateExtractValue(lhs, 0); LLValue* l = gIR->ir->CreateExtractValue(lhs, 0);
@ -741,7 +741,7 @@ llvm::ConstantPointerNull* getNullPtr(const LLType* t)
LLConstant* getNullValue(const LLType* t) LLConstant* getNullValue(const LLType* t)
{ {
return LLConstant::getNullValue(t); return llvm::getGlobalContext().getNullValue(t);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////

View file

@ -14,7 +14,6 @@
#include "gen/llvm-version.h" #include "gen/llvm-version.h"
#include "llvm/Analysis/Verifier.h" #include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/ModuleProvider.h" #include "llvm/ModuleProvider.h"
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
@ -555,7 +554,7 @@ static LLFunction* build_module_reference_and_ctor(LLConstant* moduleinfo)
// provide the default initializer // provide the default initializer
const LLStructType* modulerefTy = DtoModuleReferenceType(); const LLStructType* modulerefTy = DtoModuleReferenceType();
std::vector<LLConstant*> mrefvalues; std::vector<LLConstant*> mrefvalues;
mrefvalues.push_back(LLConstant::getNullValue(modulerefTy->getContainedType(0))); mrefvalues.push_back(llvm::getGlobalContext().getNullValue(modulerefTy->getContainedType(0)));
mrefvalues.push_back(llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1))); mrefvalues.push_back(llvm::ConstantExpr::getBitCast(moduleinfo, modulerefTy->getContainedType(1)));
LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, mrefvalues); LLConstant* thismrefinit = LLConstantStruct::get(modulerefTy, mrefvalues);

View file

@ -117,22 +117,22 @@ size_t add_zeros(std::vector<llvm::Constant*>& constants, size_t diff)
{ {
if (global.params.is64bit && diff % 8 == 0) if (global.params.is64bit && diff % 8 == 0)
{ {
constants.push_back(llvm::Constant::getNullValue(llvm::Type::Int64Ty)); constants.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int64Ty));
diff -= 8; diff -= 8;
} }
else if (diff % 4 == 0) else if (diff % 4 == 0)
{ {
constants.push_back(llvm::Constant::getNullValue(llvm::Type::Int32Ty)); constants.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int32Ty));
diff -= 4; diff -= 4;
} }
else if (diff % 2 == 0) else if (diff % 2 == 0)
{ {
constants.push_back(llvm::Constant::getNullValue(llvm::Type::Int16Ty)); constants.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int16Ty));
diff -= 2; diff -= 2;
} }
else else
{ {
constants.push_back(llvm::Constant::getNullValue(llvm::Type::Int8Ty)); constants.push_back(llvm::getGlobalContext().getNullValue(llvm::Type::Int8Ty));
diff -= 1; diff -= 1;
} }
} }