Skip to content

Commit

Permalink
Fix issue #2729 - dump static array inline-IR results to memory (#2732)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Jun 8, 2018
1 parent 7611e75 commit 44074e3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 4 additions & 6 deletions gen/inlineir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,10 @@ DValue *DtoInlineIRExpr(Loc &loc, FuncDeclaration *fdecl,
return new DLValue(type, sretPointer);
}

// work around missing tuple support for users of the return value
if (type->toBasetype()->ty == Tstruct) {
// make a copy
llvm::Value *mem = DtoAlloca(type, ".__ir_tuple_ret");
DtoStore(rv, DtoBitCast(mem, getPtrToType(rv->getType())));
return new DLValue(type, mem);
// dump struct and static array return values to memory
if (DtoIsInMemoryOnly(type->toBasetype())) {
LLValue *lval = DtoAllocaDump(rv, type, ".__ir_ret");
return new DLValue(type, lval);
}

// return call as im value
Expand Down
15 changes: 15 additions & 0 deletions tests/codegen/gh2729.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: %ldc -run %s

ulong[2] foo(ulong a, ulong b) @nogc nothrow pure @safe
{
import ldc.simd;
return inlineIR!(`
%agg1 = insertvalue [2 x i64] undef, i64 %0, 0
%agg2 = insertvalue [2 x i64] %agg1, i64 %1, 1
ret [2 x i64] %agg2`, ulong[2])(a, b);
}

void main()
{
assert(foo(123, 456) == [ 123, 456 ]);
}

0 comments on commit 44074e3

Please sign in to comment.