mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Don't waste an alloca for the nested context argument
And so get rid of all loads too; just use the untouched pointer argument directly.
This commit is contained in:
parent
aa0b1b4e3a
commit
c6132508b1
3 changed files with 8 additions and 17 deletions
|
@ -1098,11 +1098,6 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
|
|||
gIR->DBuilder.EmitLocalVariable(thismem, fd->vthis, nullptr, true);
|
||||
}
|
||||
|
||||
// give the 'nestArg' parameter (an lvalue) storage
|
||||
if (irFty.arg_nest) {
|
||||
irFunc->nestArg = DtoAllocaDump(irFunc->nestArg, 0, "nestedFrame");
|
||||
}
|
||||
|
||||
// define all explicit parameters
|
||||
if (fd->parameters)
|
||||
defineParameters(irFty, *fd->parameters);
|
||||
|
|
|
@ -75,9 +75,8 @@ DValue *DtoNestedVariable(Loc &loc, Type *astype, VarDeclaration *vd,
|
|||
ctx = DtoLoad(DtoGEPi(val, 0, getVthisIdx(cd), ".vthis"));
|
||||
skipDIDeclaration = true;
|
||||
} else {
|
||||
Logger::println("Regular nested function, loading context arg");
|
||||
|
||||
ctx = DtoLoad(irfunc->nestArg);
|
||||
Logger::println("Regular nested function, using context arg");
|
||||
ctx = irfunc->nestArg;
|
||||
}
|
||||
|
||||
assert(ctx);
|
||||
|
@ -224,7 +223,7 @@ LLValue *DtoNestedContext(Loc &loc, Dsymbol *sym) {
|
|||
fromParent = false;
|
||||
} else if (irFunc.nestArg) {
|
||||
// otherwise, it may have gotten a context from the caller
|
||||
val = DtoLoad(irFunc.nestArg);
|
||||
val = irFunc.nestArg;
|
||||
} else if (irFunc.thisArg) {
|
||||
// or just have a this argument
|
||||
AggregateDeclaration *ad = irFunc.decl->isMember2();
|
||||
|
@ -456,8 +455,6 @@ void DtoCreateNestedContext(FuncGenState &funcGen) {
|
|||
} else {
|
||||
src = DtoLoad(DtoGEPi(thisval, 0, getVthisIdx(cd), ".vthis"));
|
||||
}
|
||||
} else {
|
||||
src = DtoLoad(src);
|
||||
}
|
||||
if (depth > 1) {
|
||||
src = DtoBitCast(src, getVoidPtrType());
|
||||
|
|
11
gen/toir.cpp
11
gen/toir.cpp
|
@ -1021,20 +1021,19 @@ public:
|
|||
assert(!isSpecialRefVar(vd) && "Code not expected to handle special ref "
|
||||
"vars, although it can easily be made to.");
|
||||
|
||||
LLValue *v;
|
||||
const auto ident = p->func()->decl->ident;
|
||||
if (ident == Id::ensure || ident == Id::require) {
|
||||
Logger::println("contract this exp");
|
||||
v = DtoBitCast(p->func()->nestArg, DtoType(e->type)->getPointerTo());
|
||||
LLValue *v = DtoBitCast(p->func()->nestArg, DtoType(e->type));
|
||||
result = new DImValue(e->type, v);
|
||||
} else if (vd->toParent2() != p->func()->decl) {
|
||||
Logger::println("nested this exp");
|
||||
result = DtoNestedVariable(e->loc, e->type, vd, e->type->ty == Tstruct);
|
||||
return;
|
||||
} else {
|
||||
Logger::println("normal this exp");
|
||||
v = p->func()->thisArg;
|
||||
LLValue *v = p->func()->thisArg;
|
||||
result = new DLValue(e->type, DtoBitCast(v, DtoPtrToType(e->type)));
|
||||
}
|
||||
result = new DLValue(e->type, DtoBitCast(v, DtoPtrToType(e->type)));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2184,7 +2183,7 @@ public:
|
|||
// function. Happens with anonymous functions.
|
||||
cval = funcGen.nestedVar;
|
||||
} else if (irfn.nestArg) {
|
||||
cval = DtoLoad(irfn.nestArg);
|
||||
cval = irfn.nestArg;
|
||||
} else if (irfn.thisArg) {
|
||||
AggregateDeclaration *ad = irfn.decl->isMember2();
|
||||
if (!ad || !ad->vthis) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue