mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 02:45:25 +03:00
Wrapped all the most potentially expensive logging calls in a conditional to only do work when actually requested.
Commented some logging calls that could potentially write out many megabytes of type dumps.
This commit is contained in:
parent
7b18b7a633
commit
bcafbe169d
13 changed files with 197 additions and 87 deletions
|
@ -105,12 +105,16 @@ DValue* DtoAAIn(Loc& loc, Type* type, DValue* aa, DValue* key)
|
|||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaIn");
|
||||
const llvm::FunctionType* funcTy = func->getFunctionType();
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "_aaIn = " << *func << '\n';
|
||||
|
||||
// aa param
|
||||
LLValue* aaval = aa->getRVal();
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "aaval: " << *aaval << '\n';
|
||||
Logger::cout() << "totype: " << *funcTy->getParamType(0) << '\n';
|
||||
}
|
||||
aaval = DtoBitCast(aaval, funcTy->getParamType(0));
|
||||
|
||||
// keyti param
|
||||
|
@ -143,12 +147,16 @@ void DtoAARemove(Loc& loc, DValue* aa, DValue* key)
|
|||
llvm::Function* func = LLVM_D_GetRuntimeFunction(gIR->module, "_aaDel");
|
||||
const llvm::FunctionType* funcTy = func->getFunctionType();
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "_aaDel = " << *func << '\n';
|
||||
|
||||
// aa param
|
||||
LLValue* aaval = aa->getRVal();
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "aaval: " << *aaval << '\n';
|
||||
Logger::cout() << "totype: " << *funcTy->getParamType(0) << '\n';
|
||||
}
|
||||
aaval = DtoBitCast(aaval, funcTy->getParamType(0));
|
||||
|
||||
// keyti param
|
||||
|
|
|
@ -85,6 +85,7 @@ void DtoArrayAssign(LLValue* dst, LLValue* src)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "array assignment type dont match: " << *dst->getType() << "\n\n" << *src->getType() << '\n';
|
||||
const LLArrayType* arrty = isaArray(src->getType()->getContainedType(0));
|
||||
if (!arrty)
|
||||
|
@ -234,6 +235,7 @@ void DtoArrayInit(Loc& loc, DValue* array, DValue* value)
|
|||
|
||||
LLFunction* fn = LLVM_D_GetRuntimeFunction(gIR->module, funcname);
|
||||
assert(fn);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "calling array init function: " << *fn <<'\n';
|
||||
CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end());
|
||||
call->setCallingConv(llvm::CallingConv::C);
|
||||
|
@ -335,6 +337,7 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
|
|||
assert(v);
|
||||
|
||||
inits[i] = v;
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "llval: " << *v << '\n';
|
||||
}
|
||||
|
||||
|
@ -426,6 +429,7 @@ DSliceValue* DtoNewDynArray(Loc& loc, Type* arrayType, DValue* dim, bool default
|
|||
if (newptr->getType() != dstType)
|
||||
newptr = DtoBitCast(newptr, dstType, ".gc_mem");
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "final ptr = " << *newptr << '\n';
|
||||
|
||||
return new DSliceValue(arrayType, arrayLen, newptr);
|
||||
|
@ -468,6 +472,7 @@ DSliceValue* DtoNewMulDimDynArray(Loc& loc, Type* arrayType, DValue** dims, size
|
|||
if (newptr->getType() != dstType)
|
||||
newptr = DtoBitCast(newptr, dstType, ".gc_mem");
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "final ptr = " << *newptr << '\n';
|
||||
|
||||
assert(firstDim);
|
||||
|
@ -497,6 +502,7 @@ DSliceValue* DtoResizeDynArray(Type* arrayType, DValue* array, DValue* newdim)
|
|||
args.push_back(DtoArrayLen(array));
|
||||
|
||||
LLValue* arrPtr = DtoArrayPtr(array);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "arrPtr = " << *arrPtr << '\n';
|
||||
args.push_back(DtoBitCast(arrPtr, fn->getFunctionType()->getParamType(3), "tmp"));
|
||||
|
||||
|
@ -726,9 +732,12 @@ static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue
|
|||
const LLType* pt = fn->getFunctionType()->getParamType(0);
|
||||
|
||||
LLSmallVector<LLValue*, 3> args;
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "bitcasting to " << *pt << '\n';
|
||||
Logger::cout() << *lmem << '\n';
|
||||
Logger::cout() << *rmem << '\n';
|
||||
}
|
||||
args.push_back(DtoBitCast(lmem,pt));
|
||||
args.push_back(DtoBitCast(rmem,pt));
|
||||
|
||||
|
@ -738,6 +747,8 @@ static LLValue* DtoArrayEqCmp_impl(Loc& loc, const char* func, DValue* l, DValue
|
|||
LLValue* tival = DtoTypeInfoOf(t);
|
||||
// DtoTypeInfoOf only does declare, not enough in this case :/
|
||||
DtoForceConstInitDsymbol(t->vtinfo);
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "typeinfo decl: " << *tival << '\n';
|
||||
|
||||
pt = fn->getFunctionType()->getParamType(2);
|
||||
|
@ -957,22 +968,29 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
|||
LLValue* rval2;
|
||||
bool isslice = false;
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "from array or sarray" << '\n';
|
||||
|
||||
if (totype->ty == Tpointer) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "to pointer" << '\n';
|
||||
rval = DtoArrayPtr(u);
|
||||
if (rval->getType() != tolltype)
|
||||
rval = gIR->ir->CreateBitCast(rval, tolltype, "tmp");
|
||||
}
|
||||
else if (totype->ty == Tarray) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "to array" << '\n';
|
||||
|
||||
const LLType* ptrty = DtoArrayType(totype)->getContainedType(1);
|
||||
const LLType* ety = DtoTypeNotVoid(fromtype->next);
|
||||
|
||||
if (DSliceValue* usl = u->isSlice()) {
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::println("from slice");
|
||||
Logger::cout() << "from: " << *usl->ptr << " to: " << *ptrty << '\n';
|
||||
}
|
||||
rval = DtoBitCast(usl->ptr, ptrty);
|
||||
if (fromtype->next->size() == totype->next->size())
|
||||
rval2 = DtoArrayLen(usl);
|
||||
|
@ -982,6 +1000,7 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
|||
else {
|
||||
LLValue* uval = u->getRVal();
|
||||
if (fromtype->ty == Tsarray) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "uvalTy = " << *uval->getType() << '\n';
|
||||
assert(isaPointer(uval->getType()));
|
||||
const LLArrayType* arrty = isaArray(uval->getType()->getContainedType(0));
|
||||
|
@ -1012,6 +1031,7 @@ DValue* DtoCastArray(Loc& loc, DValue* u, Type* to)
|
|||
isslice = true;
|
||||
}
|
||||
else if (totype->ty == Tsarray) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "to sarray" << '\n';
|
||||
assert(0);
|
||||
}
|
||||
|
|
|
@ -624,6 +624,7 @@ void AsmBlockStatement::toIR(IRState* p)
|
|||
types.insert(types.end(), outtypes.begin(), outtypes.end());
|
||||
types.insert(types.end(), intypes.begin(), intypes.end());
|
||||
llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::VoidTy, types, false);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "function type = " << *fty << '\n';
|
||||
llvm::InlineAsm* ia = llvm::InlineAsm::get(fty, code, out_c, true);
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ void DtoResolveClass(ClassDeclaration* cd)
|
|||
Logger::println("DtoResolveClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
//printf("resolve class: %s\n", cd->toPrettyChars());
|
||||
|
||||
// get the TypeClass
|
||||
assert(cd->type->ty == Tclass);
|
||||
TypeClass* ts = (TypeClass*)cd->type;
|
||||
|
@ -244,6 +246,7 @@ void DtoResolveClass(ClassDeclaration* cd)
|
|||
TypeClass* itc = (TypeClass*)id->type;
|
||||
const LLType* ivtblTy = itc->ir.vtblType->get();
|
||||
assert(ivtblTy);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "interface vtbl type: " << *ivtblTy << '\n';
|
||||
fieldtypes.push_back(getPtrToType(ivtblTy));
|
||||
|
||||
|
@ -360,6 +363,8 @@ void DtoDeclareClass(ClassDeclaration* cd)
|
|||
Logger::println("DtoDeclareClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
//printf("declare class: %s\n", cd->toPrettyChars());
|
||||
|
||||
assert(cd->type->ty == Tclass);
|
||||
TypeClass* ts = (TypeClass*)cd->type;
|
||||
|
||||
|
@ -654,7 +659,7 @@ void DtoConstInitClass(ClassDeclaration* cd)
|
|||
|
||||
for (int k=1; k < b->vtbl.dim; k++)
|
||||
{
|
||||
Logger::println("interface vtbl const init nr. %d", k);
|
||||
// Logger::println("interface vtbl const init nr. %d", k);
|
||||
Dsymbol* dsym = (Dsymbol*)b->vtbl.data[k];
|
||||
|
||||
// error on unimplemented functions, error was already generated earlier
|
||||
|
@ -674,11 +679,13 @@ void DtoConstInitClass(ClassDeclaration* cd)
|
|||
// we have to bitcast, as the type created in ResolveClass expects a different this type
|
||||
c = llvm::ConstantExpr::getBitCast(c, targetTy);
|
||||
iinits.push_back(c);
|
||||
Logger::cout() << "c: " << *c << '\n';
|
||||
// if (Logger::enabled())
|
||||
// Logger::cout() << "c: " << *c << '\n';
|
||||
}
|
||||
|
||||
#if OPAQUE_VTBLS
|
||||
Logger::cout() << "n: " << iinits.size() << " ivtbl_ty: " << *ivtbl_ty << '\n';
|
||||
// if (Logger::enabled())
|
||||
// Logger::cout() << "n: " << iinits.size() << " ivtbl_ty: " << *ivtbl_ty << '\n';
|
||||
LLConstant* civtblInit = llvm::ConstantArray::get(ivtbl_ty, iinits);
|
||||
iri->vtblInit = llvm::cast<llvm::ConstantArray>(civtblInit);
|
||||
#else
|
||||
|
@ -825,6 +832,7 @@ DValue* DtoNewClass(Loc loc, TypeClass* tc, NewExp* newexp)
|
|||
size_t idx = 2 + tc->sym->vthis->ir.irField->index;
|
||||
LLValue* src = thisval->getRVal();
|
||||
LLValue* dst = DtoGEPi(mem,0,idx,"tmp");
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
|
||||
DtoStore(src, dst);
|
||||
}
|
||||
|
@ -1175,6 +1183,7 @@ LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl)
|
|||
assert(inst->getType()->toBasetype()->ty == Tclass);
|
||||
|
||||
LLValue* vthis = inst->getRVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "vthis: " << *vthis << '\n';
|
||||
|
||||
LLValue* funcval;
|
||||
|
@ -1183,10 +1192,12 @@ LLValue* DtoVirtualFunctionPointer(DValue* inst, FuncDeclaration* fdecl)
|
|||
funcval = DtoGEPi(funcval, 0, fdecl->vtblIndex, fdecl->toPrettyChars());
|
||||
funcval = DtoLoad(funcval);
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "funcval: " << *funcval << '\n';
|
||||
|
||||
#if OPAQUE_VTBLS
|
||||
funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type)));
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "funcval casted: " << *funcval << '\n';
|
||||
#endif
|
||||
|
||||
|
|
|
@ -164,11 +164,16 @@ Lbadstuff:
|
|||
// handle lazy args
|
||||
if (arg->storageClass & STClazy)
|
||||
{
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "for lazy got: " << *paramvec.back() << '\n';
|
||||
|
||||
TypeFunction *ltf = new TypeFunction(NULL, arg->type, 0, LINKd);
|
||||
TypeDelegate *ltd = new TypeDelegate(ltf);
|
||||
at = getPtrToType(DtoType(ltd));
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "lazy updated to: " << *at << '\n';
|
||||
|
||||
paramvec.back() = at;
|
||||
// lazy doesn't need byval as the delegate is not visible to the user
|
||||
}
|
||||
|
@ -289,6 +294,8 @@ void DtoResolveFunction(FuncDeclaration* fdecl)
|
|||
Logger::println("DtoResolveFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
//printf("resolve function: %s\n", fdecl->toPrettyChars());
|
||||
|
||||
if (fdecl->parent)
|
||||
if (TemplateInstance* tinst = fdecl->parent->isTemplateInstance())
|
||||
{
|
||||
|
@ -391,6 +398,8 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
|||
Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars());
|
||||
LOG_SCOPE;
|
||||
|
||||
//printf("declare function: %s\n", fdecl->toPrettyChars());
|
||||
|
||||
// intrinsic sanity check
|
||||
if (fdecl->llvmInternal == LLVMintrinsic && fdecl->fbody) {
|
||||
error(fdecl->loc, "intrinsics cannot have function bodies");
|
||||
|
@ -530,6 +539,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl)
|
|||
else
|
||||
assert(func->getLinkage() != llvm::GlobalValue::InternalLinkage);
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "func decl: " << *func << '\n';
|
||||
}
|
||||
|
||||
|
|
|
@ -416,7 +416,7 @@ LLValue* DtoNestedContext(Loc loc, Dsymbol* sym)
|
|||
|
||||
void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
||||
{
|
||||
Logger::cout() << "DtoAssign(...);\n";
|
||||
Logger::println("DtoAssign(...);\n");
|
||||
LOG_SCOPE;
|
||||
|
||||
Type* t = lhs->getType()->toBasetype();
|
||||
|
@ -472,6 +472,7 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
|||
else {
|
||||
LLValue* l = lhs->getLVal();
|
||||
LLValue* r = rhs->getRVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n';
|
||||
DtoAggrCopy(l, r);
|
||||
}
|
||||
|
@ -480,8 +481,11 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
|||
assert(t2->ty == Tclass);
|
||||
LLValue* l = lhs->getLVal();
|
||||
LLValue* r = rhs->getRVal();
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "l : " << *l << '\n';
|
||||
Logger::cout() << "r : " << *r << '\n';
|
||||
}
|
||||
r = DtoBitCast(r, l->getType()->getContainedType(0));
|
||||
DtoStore(r, l);
|
||||
}
|
||||
|
@ -499,6 +503,7 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
|||
else {
|
||||
LLValue* l = lhs->getLVal();
|
||||
LLValue* r = rhs->getRVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "assign\nlhs: " << *l << "rhs: " << *r << '\n';
|
||||
const LLType* lit = l->getType()->getContainedType(0);
|
||||
if (r->getType() != lit) {
|
||||
|
@ -510,6 +515,7 @@ void DtoAssign(Loc& loc, DValue* lhs, DValue* rhs)
|
|||
else {
|
||||
r = DtoCast(loc, rhs, lhs->getType())->getRVal();
|
||||
}
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "really assign\nlhs: " << *l << "rhs: " << *r << '\n';
|
||||
assert(r->getType() == l->getType()->getContainedType(0));
|
||||
}
|
||||
|
@ -584,6 +590,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
|
|||
|
||||
if (to->isintegral()) {
|
||||
if (fromsz < tosz) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "cast to: " << *tolltype << '\n';
|
||||
if (from->isunsigned() || from->ty == Tbool) {
|
||||
rval = new llvm::ZExtInst(rval, tolltype, "tmp", gIR->scopebb());
|
||||
|
@ -610,6 +617,7 @@ DValue* DtoCastInt(Loc& loc, DValue* val, Type* _to)
|
|||
}
|
||||
}
|
||||
else if (to->ty == Tpointer) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "cast pointer: " << *tolltype << '\n';
|
||||
rval = gIR->ir->CreateIntToPtr(rval, tolltype, "tmp");
|
||||
}
|
||||
|
@ -633,6 +641,7 @@ DValue* DtoCastPtr(Loc& loc, DValue* val, Type* to)
|
|||
|
||||
if (totype->ty == Tpointer || totype->ty == Tclass) {
|
||||
LLValue* src = val->getRVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "src: " << *src << "to type: " << *tolltype << '\n';
|
||||
rval = DtoBitCast(src, tolltype);
|
||||
}
|
||||
|
@ -910,7 +919,9 @@ void DtoConstInitGlobal(VarDeclaration* vd)
|
|||
|
||||
//Logger::cout() << "initializer: " << *_init << '\n';
|
||||
if (_type != _init->getType()) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "got type '" << *_init->getType() << "' expected '" << *_type << "'\n";
|
||||
|
||||
// zero initalizer
|
||||
if (_init->isNullValue())
|
||||
_init = llvm::Constant::getNullValue(_type);
|
||||
|
@ -930,6 +941,7 @@ void DtoConstInitGlobal(VarDeclaration* vd)
|
|||
_init = DtoConstStaticArray(_type, _init);
|
||||
}
|
||||
else {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "Unexpected initializer type: " << *_type << '\n';
|
||||
//assert(0);
|
||||
}
|
||||
|
@ -949,10 +961,13 @@ void DtoConstInitGlobal(VarDeclaration* vd)
|
|||
|
||||
llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->ir.irGlobal->value);
|
||||
if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl))
|
||||
{
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::println("setting initializer");
|
||||
Logger::cout() << "global: " << *gvar << '\n';
|
||||
Logger::cout() << "init: " << *_init << '\n';
|
||||
}
|
||||
gvar->setInitializer(_init);
|
||||
// do debug info
|
||||
if (global.params.symdebug)
|
||||
|
@ -1168,6 +1183,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
|||
assert(vd->ir.irLocal->value);
|
||||
}
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n';
|
||||
DValue* ie = DtoInitializer(vd->ir.irLocal->value, vd->init);
|
||||
}
|
||||
|
@ -1292,6 +1308,7 @@ LLConstant* DtoConstFieldInitializer(Type* t, Initializer* init)
|
|||
assert(_init);
|
||||
if (_type != _init->getType())
|
||||
{
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "field init is: " << *_init << " type should be " << *_type << '\n';
|
||||
if (t->ty == Tsarray)
|
||||
{
|
||||
|
@ -1379,6 +1396,7 @@ static LLConstant* expand_to_sarray(Type *base, Expression* exp)
|
|||
{
|
||||
Logger::println("building type %s from expression (%s) of type %s", base->toChars(), exp->toChars(), exp->type->toChars());
|
||||
const LLType* dstTy = DtoType(base);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "final llvm type requested: " << *dstTy << '\n';
|
||||
|
||||
LLConstant* val = exp->toConstElem(gIR);
|
||||
|
@ -1510,8 +1528,11 @@ LLValue* DtoBoolean(Loc& loc, DValue* dval)
|
|||
else if (ty == Tpointer || ty == Tclass) {
|
||||
LLValue* val = dval->getRVal();
|
||||
LLValue* zero = LLConstant::getNullValue(val->getType());
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "val: " << *val << '\n';
|
||||
Logger::cout() << "zero: " << *zero << '\n';
|
||||
}
|
||||
return gIR->ir->CreateICmpNE(val, zero, "tmp");
|
||||
}
|
||||
// dynamic array
|
||||
|
|
|
@ -79,12 +79,15 @@ void ReturnStatement::toIR(IRState* p)
|
|||
DValue* e = exp->toElem(p);
|
||||
LLValue* v = e->getRVal();
|
||||
delete e;
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "return value is '" <<*v << "'\n";
|
||||
|
||||
// can happen for classes
|
||||
if (v->getType() != p->topfunc()->getReturnType())
|
||||
{
|
||||
v = gIR->ir->CreateBitCast(v, p->topfunc()->getReturnType(), "tmp");
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "return value after cast: " << *v << '\n';
|
||||
}
|
||||
|
||||
|
@ -165,6 +168,7 @@ void IfStatement::toIR(IRState* p)
|
|||
llvm::BasicBlock* elsebb = elsebody ? llvm::BasicBlock::Create("else", gIR->topfunc(), endbb) : endbb;
|
||||
|
||||
if (cond_val->getType() != LLType::Int1Ty) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "if conditional: " << *cond_val << '\n';
|
||||
cond_val = DtoBoolean(loc, cond_e);
|
||||
}
|
||||
|
@ -677,8 +681,11 @@ static LLValue* call_string_switch_runtime(llvm::GlobalVariable* table, Expressi
|
|||
|
||||
llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, fname);
|
||||
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << *table->getType() << '\n';
|
||||
Logger::cout() << *fn->getFunctionType()->getParamType(0) << '\n';
|
||||
}
|
||||
assert(table->getType() == fn->getFunctionType()->getParamType(0));
|
||||
|
||||
DValue* val = e->toElem(gIR);
|
||||
|
|
|
@ -29,6 +29,8 @@ LLConstant* DtoConstStructInitializer(StructInitializer* si)
|
|||
DtoResolveDsymbol(si->ad);
|
||||
|
||||
const llvm::StructType* structtype = isaStruct(ts->ir.type->get());
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "llvm struct type: " << *structtype << '\n';
|
||||
|
||||
assert(si->value.dim == si->vars.dim);
|
||||
|
@ -61,8 +63,11 @@ LLValue* DtoIndexStruct(LLValue* ptr, StructDeclaration* sd, Type* t, unsigned o
|
|||
const LLType* llt = getPtrToType(DtoType(t));
|
||||
const LLType* st = getPtrToType(DtoType(sd->type));
|
||||
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "ptr = " << *ptr << '\n';
|
||||
Logger::cout() << "st = " << *st << '\n';
|
||||
}
|
||||
|
||||
if (ptr->getType() != st) {
|
||||
assert(sd->ir.irStruct->hasUnions);
|
||||
|
|
|
@ -76,6 +76,7 @@ LLValue* DtoCallableValue(DValue* fn)
|
|||
else if (type->ty == Tdelegate)
|
||||
{
|
||||
LLValue* dg = fn->getRVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "delegate: " << *dg << '\n';
|
||||
LLValue* funcptr = DtoGEPi(dg, 0, 1);
|
||||
return DtoLoad(funcptr);
|
||||
|
@ -126,7 +127,10 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, llvm::PAListPtr& palist, T
|
|||
vtypes.back() = DtoSize_t();
|
||||
}
|
||||
const LLStructType* vtype = LLStructType::get(vtypes);
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "d-variadic argument struct type:\n" << *vtype << '\n';
|
||||
|
||||
LLValue* mem = DtoAlloca(vtype,"_argptr_storage");
|
||||
|
||||
// store arguments in the struct
|
||||
|
@ -147,6 +151,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args, llvm::PAListPtr& palist, T
|
|||
|
||||
llvm::GlobalVariable* typeinfomem =
|
||||
new llvm::GlobalVariable(typeinfoarraytype, true, llvm::GlobalValue::InternalLinkage, NULL, "._arguments.storage", gIR->module);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "_arguments storage: " << *typeinfomem << '\n';
|
||||
|
||||
std::vector<LLConstant*> vtypeinfos;
|
||||
|
@ -314,8 +319,11 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||
LLValue* arg = argval->getRVal();
|
||||
if (fnarg) // can fnarg ever be null in this block?
|
||||
{
|
||||
Logger::cout() << "arg: " << *arg << '\n';
|
||||
Logger::cout() << "expects: " << *callableTy->getParamType(j) << '\n';
|
||||
// if (Logger::enabled())
|
||||
// {
|
||||
// Logger::cout() << "arg: " << *arg << '\n';
|
||||
// Logger::cout() << "expects: " << *callableTy->getParamType(j) << '\n';
|
||||
// }
|
||||
if (arg->getType() != callableTy->getParamType(j))
|
||||
arg = DtoBitCast(arg, callableTy->getParamType(j));
|
||||
if (fnarg->llvmAttrs)
|
||||
|
|
16
gen/toir.cpp
16
gen/toir.cpp
|
@ -132,6 +132,7 @@ DValue* VarExp::toElem(IRState* p)
|
|||
}
|
||||
if (!vd->ir.isSet() || !vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) {
|
||||
error("global variable %s not resolved", vd->toChars());
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "unresolved global had type: " << *DtoType(vd->type) << '\n';
|
||||
fatal();
|
||||
}
|
||||
|
@ -222,6 +223,7 @@ LLConstant* IntegerExp::toConstElem(IRState* p)
|
|||
assert(llvm::isa<LLIntegerType>(t));
|
||||
LLConstant* c = llvm::ConstantInt::get(t,(uint64_t)value,!type->isunsigned());
|
||||
assert(c);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "value = " << *c << '\n';
|
||||
return c;
|
||||
}
|
||||
|
@ -353,6 +355,7 @@ DValue* StringExp::toElem(IRState* p)
|
|||
assert(0);
|
||||
|
||||
llvm::GlobalValue::LinkageTypes _linkage = llvm::GlobalValue::InternalLinkage;//WeakLinkage;
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "type: " << *at << "\ninit: " << *_init << '\n';
|
||||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(at,true,_linkage,_init,".stringliteral",gIR->module);
|
||||
|
||||
|
@ -588,6 +591,7 @@ DValue* MinExp::toElem(IRState* p)
|
|||
if (t1->ty == Tpointer && t2->ty == Tpointer) {
|
||||
LLValue* lv = l->getRVal();
|
||||
LLValue* rv = r->getRVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "lv: " << *lv << " rv: " << *rv << '\n';
|
||||
lv = p->ir->CreatePtrToInt(lv, DtoSize_t(), "tmp");
|
||||
rv = p->ir->CreatePtrToInt(rv, DtoSize_t(), "tmp");
|
||||
|
@ -869,6 +873,7 @@ DValue* AddrExp::toElem(IRState* p)
|
|||
}
|
||||
Logger::println("is nothing special");
|
||||
LLValue* lval = v->getLVal();
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "lval: " << *lval << '\n';
|
||||
return new DImValue(type, DtoBitCast(v->getLVal(), DtoType(type)));
|
||||
}
|
||||
|
@ -1009,6 +1014,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
|||
|
||||
LLValue* zero = llvm::ConstantInt::get(LLType::Int32Ty, 0, false);
|
||||
LLValue* vtblidx = llvm::ConstantInt::get(LLType::Int32Ty, (size_t)fdecl->vtblIndex, false);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "vthis: " << *vthis << '\n';
|
||||
funcval = DtoGEP(vthis, zero, zero);
|
||||
funcval = DtoLoad(funcval);
|
||||
|
@ -1016,6 +1022,7 @@ DValue* DotVarExp::toElem(IRState* p)
|
|||
funcval = DtoLoad(funcval);
|
||||
#if OPAQUE_VTBLS
|
||||
funcval = DtoBitCast(funcval, getPtrToType(DtoType(fdecl->type)));
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "funcval casted: " << *funcval << '\n';
|
||||
#endif
|
||||
}
|
||||
|
@ -1248,8 +1255,11 @@ DValue* CmpExp::toElem(IRState* p)
|
|||
{
|
||||
LLValue* a = l->getRVal();
|
||||
LLValue* b = r->getRVal();
|
||||
if (Logger::enabled())
|
||||
{
|
||||
Logger::cout() << "type 1: " << *a << '\n';
|
||||
Logger::cout() << "type 2: " << *b << '\n';
|
||||
}
|
||||
if (a->getType() != b->getType())
|
||||
b = DtoBitCast(b, a->getType());
|
||||
eval = p->ir->CreateICmp(cmpop, a, b, "tmp");
|
||||
|
@ -1871,6 +1881,7 @@ DValue* DelegateExp::toElem(IRState* p)
|
|||
uval = src->getRVal();
|
||||
}
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "context = " << *uval << '\n';
|
||||
|
||||
LLValue* context = DtoGEPi(lval,0,0);
|
||||
|
@ -2160,11 +2171,13 @@ DValue* ArrayLiteralExp::toElem(IRState* p)
|
|||
|
||||
// llvm target type
|
||||
const LLType* llType = DtoType(arrayType);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n";
|
||||
|
||||
// llvm storage type
|
||||
const LLType* llElemType = DtoTypeNotVoid(elemType);
|
||||
const LLType* llStoType = LLArrayType::get(llElemType, len);
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "llvm storage type: '" << *llStoType << "'\n";
|
||||
|
||||
// don't allocate storage for zero length dynamic array literals
|
||||
|
@ -2285,10 +2298,12 @@ DValue* StructLiteralExp::toElem(IRState* p)
|
|||
const LLStructType* t = LLStructType::get(tys, sd->ir.irStruct->packed);
|
||||
if (t != llt) {
|
||||
if (getABITypeSize(t) != getABITypeSize(llt)) {
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "got size " << getABITypeSize(t) << ", expected " << getABITypeSize(llt) << '\n';
|
||||
assert(0 && "type size mismatch");
|
||||
}
|
||||
sptr = DtoBitCast(sptr, getPtrToType(t));
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "sptr type is now: " << *t << '\n';
|
||||
}
|
||||
}
|
||||
|
@ -2300,6 +2315,7 @@ DValue* StructLiteralExp::toElem(IRState* p)
|
|||
Expression* vx = (Expression*)elements->data[i];
|
||||
if (!vx) continue;
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "getting index " << j << " of " << *sptr << '\n';
|
||||
LLValue* arrptr = DtoGEPi(sptr,0,j);
|
||||
DValue* darrptr = new DVarValue(vx->type, arrptr);
|
||||
|
|
|
@ -319,6 +319,7 @@ LLValue* DtoPointedType(LLValue* ptr, LLValue* val)
|
|||
// something else unsupported
|
||||
else
|
||||
{
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << *ptrTy << '|' << *valTy << '\n';
|
||||
assert(0);
|
||||
}
|
||||
|
|
|
@ -61,10 +61,10 @@ void Module::genobjfile(int multiobj)
|
|||
Logger::enable();
|
||||
}
|
||||
|
||||
Logger::cout() << "Generating module: " << (md ? md->toChars() : toChars()) << '\n';
|
||||
Logger::println("Generating module: %s\n", (md ? md->toChars() : toChars()));
|
||||
LOG_SCOPE;
|
||||
|
||||
//printf("codegen: %s\n", srcfile->toChars());
|
||||
printf("codegen: %s\n", srcfile->toChars());
|
||||
|
||||
// start by deleting the old object file
|
||||
deleteObjFile();
|
||||
|
@ -652,6 +652,7 @@ void VarDeclaration::toObjFile(int multiobj)
|
|||
llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_type,_isconst,_linkage,NULL,_name,gIR->module);
|
||||
this->ir.irGlobal->value = gvar;
|
||||
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << *gvar << '\n';
|
||||
|
||||
if (static_local)
|
||||
|
|
|
@ -369,6 +369,7 @@ void TypeInfoTypedefDeclaration::llvmDefine()
|
|||
DtoForceConstInitDsymbol(base);
|
||||
|
||||
const LLStructType* stype = isaStruct(base->type->ir.type->get());
|
||||
if (Logger::enabled())
|
||||
Logger::cout() << "got stype: " << *stype << '\n';
|
||||
|
||||
// vtbl
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue