mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Merge pull request #1082 from klickverbot/empty-structs-linux
x86: Only skip empty structs on OS X
This commit is contained in:
commit
dc8ff497ac
2 changed files with 25 additions and 11 deletions
|
@ -215,6 +215,31 @@ struct X86TargetABI : TargetABI
|
||||||
// IMPLICIT PARAMETERS
|
// IMPLICIT PARAMETERS
|
||||||
|
|
||||||
// EXPLICIT PARAMETERS
|
// EXPLICIT PARAMETERS
|
||||||
|
|
||||||
|
// Clang does not pass empty structs, while it seems that GCC does,
|
||||||
|
// at least on Linux x86.
|
||||||
|
if (isOSX)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
while (i < fty.args.size())
|
||||||
|
{
|
||||||
|
Type *type = fty.args[i]->type->toBasetype();
|
||||||
|
if (type->ty == Tstruct)
|
||||||
|
{
|
||||||
|
// Do not pass empty structs at all for C++ ABI compatibility.
|
||||||
|
// Tests with clang reveal that more complex "empty" types, for
|
||||||
|
// example a struct containing an empty struct, are not
|
||||||
|
// optimized in the same way.
|
||||||
|
StructDeclaration *sd = static_cast<TypeStruct *>(type)->sym;
|
||||||
|
if (sd->fields.empty())
|
||||||
|
{
|
||||||
|
fty.args.erase(fty.args.begin() + i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -164,17 +164,6 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype,
|
||||||
}
|
}
|
||||||
else if (!passPointer)
|
else if (!passPointer)
|
||||||
{
|
{
|
||||||
if (loweredDType->toBasetype()->ty == Tstruct)
|
|
||||||
{
|
|
||||||
// Do not pass empty structs at all for C++ ABI compatibility.
|
|
||||||
// Tests with clang reveal that more complex "empty" types, for
|
|
||||||
// example a struct containing an empty struct, are not
|
|
||||||
// optimized in the same way.
|
|
||||||
StructDeclaration *sd =
|
|
||||||
static_cast<TypeStruct*>(loweredDType->toBasetype())->sym;
|
|
||||||
if (sd->fields.empty()) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abi->passByVal(loweredDType))
|
if (abi->passByVal(loweredDType))
|
||||||
{
|
{
|
||||||
attrBuilder.add(LDC_ATTRIBUTE(ByVal));
|
attrBuilder.add(LDC_ATTRIBUTE(ByVal));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue