Partial fix for #69 — LDC1 from master fails to build Tango.

Fixed regression that has been introduced in commit 9889067.
This commit is contained in:
Alexey Prokhin 2012-01-29 12:32:08 +04:00
parent efcbe8390a
commit 15a903580b
5 changed files with 20 additions and 18 deletions

View file

@ -87,11 +87,7 @@ llvm::FunctionType* DtoFunctionType(Type* type, Type* thistype, Type* nesttype,
// member functions
if (thistype)
{
bool toref = (thistype->toBasetype()->ty == Tstruct);
#if STRUCTTHISREF
fty.is_arg_this_ref = toref;
#endif
fty.arg_this = new IrFuncTyArg(thistype, toref);
fty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct);
lidx++;
}
@ -712,7 +708,10 @@ void DtoDefineFunction(FuncDeclaration* fd)
assert(thisvar);
LLValue* thismem = thisvar;
if (!f->fty.is_arg_this_ref) {
#if STRUCTTHISREF
if (!f->fty.arg_this->byref)
#endif
{
thismem = DtoRawAlloca(thisvar->getType(), 0, "this"); // FIXME: align?
DtoStore(thisvar, thismem);
irfunction->thisArg = thismem;
@ -722,6 +721,7 @@ void DtoDefineFunction(FuncDeclaration* fd)
fd->vthis->ir.irParam = new IrParameter(fd->vthis);
fd->vthis->ir.irParam->value = thismem;
fd->vthis->ir.irParam->arg = f->fty.arg_this;
fd->vthis->ir.irParam->isVthis = true;
DtoDwarfLocalVariable(thismem, fd->vthis);

View file

@ -463,12 +463,19 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
if (vd->isParameter()) {
// Parameters will have storage associated with them (to handle byref etc.),
// so handle those cases specially by storing a pointer instead of a value.
assert(vd->ir.irParam->value);
LLValue* value = vd->ir.irParam->value;
IrParameter * irparam = vd->ir.irParam;
LLValue* value = irparam->value;
assert(value);
LLType* type = value->getType();
bool refout = vd->storage_class & (STCref | STCout);
bool lazy = vd->storage_class & STClazy;
if (!refout && (!vd->ir.irParam->arg->byref || lazy)) {
bool byref = irparam->arg->byref;
#if STRUCTTHISREF
bool isVthisPtr = irparam->isVthis && !byref;
#else
bool isVthisPtr = irparam->isVthis;
#endif
if ((!refout && (!byref || lazy)) || isVthisPtr) {
// This will be copied to the nesting frame.
if (lazy)
type = type->getContainedType(0);

View file

@ -79,9 +79,6 @@ struct IrFuncTy : IrBase
// range of normal parameters to reverse
bool reverseParams;
// arg_this is reference
bool is_arg_this_ref;
IrFuncTy()
: ret(NULL),
args(),
@ -91,8 +88,7 @@ struct IrFuncTy : IrBase
arg_arguments(NULL),
arg_argptr(NULL),
c_vararg(false),
reverseParams(false),
is_arg_this_ref(false)
reverseParams(false)
{}
#if defined(_MSC_VER)
@ -107,8 +103,7 @@ struct IrFuncTy : IrBase
arg_arguments(rhs.arg_arguments),
arg_argptr(rhs.arg_argptr),
c_vararg(rhs.c_vararg),
reverseParams(rhs.reverseParams),
is_arg_this_ref(rhs.is_arg_this_ref)
reverseParams(rhs.reverseParams)
{}
IrFuncTy& operator=(const IrFuncTy& rhs)
@ -122,7 +117,6 @@ struct IrFuncTy : IrBase
arg_argptr = rhs.arg_argptr;
c_vararg = rhs.c_vararg;
reverseParams = rhs.reverseParams;
is_arg_this_ref = rhs.is_arg_this_ref;
return *this;
}
#endif

View file

@ -38,7 +38,7 @@ IrLocal::IrLocal(VarDeclaration* v) : IrVar(v)
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
IrParameter::IrParameter(VarDeclaration* v) : IrLocal(v), arg(0)
IrParameter::IrParameter(VarDeclaration* v) : IrLocal(v), arg(0), isVthis(false)
{
}

View file

@ -38,6 +38,7 @@ struct IrParameter : IrLocal
{
IrParameter(VarDeclaration* v);
IrFuncTyArg *arg;
bool isVthis; // true, if it is the 'this' parameter
};
// represents an aggregate field variable