Fix for issue #637.

In case of a ctor `this` is passed to the function and is also the
return value. This is the perfect case for the `Returned` attribute.
But the x86_64 ABI missed the fact that the return value was a pointer
to a struct and did a struct rewrite, resulting in an bitcast
incompatible type.
This commit is contained in:
kai 2014-11-13 01:49:36 +01:00
parent 17171b3e76
commit dbbbe0092b
2 changed files with 3 additions and 12 deletions

View file

@ -149,17 +149,8 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype,
{
#if LDC_LLVM_VER >= 303
llvm::AttrBuilder attrBuilder;
// Issue 624: In case of a ctor 'this' is passed to the function and is also
// the return value. This could be a perfect case for the 'Returned' attribute.
// However the 'this' type and the return type are transformed in different
// ways, making them bitcast incompatible.
// Example: extern(C): struct Value { this(string) {} string s; }
// return type: { i64, i64 }
// this type: %ldc_github_624.Value*
// FIXME: (1) Investigate why the types are handled in different ways
// (2) The attributes are cleared by some abi implementations
// if (isCtor)
// attrBuilder.addAttribute(llvm::Attribute::Returned);
if (isCtor)
attrBuilder.addAttribute(llvm::Attribute::Returned);
#endif
newIrFty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct
#if LDC_LLVM_VER >= 303