Skip to content

Commit 5372e57

Browse files
committed
Fix for issue ldc-developers#624
1 parent 0d6c556 commit 5372e57

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

gen/functions.cpp

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

0 commit comments

Comments
 (0)