Fix for issue #624

This commit is contained in:
kai 2014-06-13 14:08:27 +02:00
parent 0d6c556e50
commit 5372e57595

View file

@ -138,8 +138,17 @@ llvm::FunctionType* DtoFunctionType(Type* type, IrFuncTy &irFty, Type* thistype,
{
#if LDC_LLVM_VER >= 303
llvm::AttrBuilder attrBuilder;
if (isCtor)
attrBuilder.addAttribute(llvm::Attribute::Returned);
// 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);
#endif
newIrFty.arg_this = new IrFuncTyArg(thistype, thistype->toBasetype()->ty == Tstruct
#if LDC_LLVM_VER >= 303