diff --git a/gen/arrays.cpp b/gen/arrays.cpp index db68eebd43..1c3a5f7c1b 100644 --- a/gen/arrays.cpp +++ b/gen/arrays.cpp @@ -25,7 +25,6 @@ #include "ir/irmodule.h" static void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr); -static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2); ////////////////////////////////////////////////////////////////////////////////////////// @@ -202,6 +201,24 @@ static Type *DtoArrayElementType(Type *arrayType) ////////////////////////////////////////////////////////////////////////////////////////// +static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2) +{ + if (global.params.useAssert || gIR->emitArrayBoundsChecks()) + { + LLValue* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_slice_copy"); + gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2); + } + else + { + // We might have dstarr == srcarr at compile time, but as long as + // sz1 == 0 at runtime, this would probably still be legal (the C spec + // is unclear here). + DtoMemCpy(dstarr, srcarr, sz1); + } +} + +////////////////////////////////////////////////////////////////////////////////////////// + // Determine whether t is an array of structs that need a postblit. static bool arrayNeedsPostblit(Type *t) { @@ -563,24 +580,6 @@ void initializeArrayLiteral(IRState* p, ArrayLiteralExp* ale, LLValue* dstMem) } } -////////////////////////////////////////////////////////////////////////////////////////// - -static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2) -{ - if (global.params.useAssert || gIR->emitArrayBoundsChecks()) - { - LLValue* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_slice_copy"); - gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2); - } - else - { - // We might have dstarr == srcarr at compile time, but as long as - // sz1 == 0 at runtime, this would probably still be legal (the C spec - // is unclear here). - DtoMemCpy(dstarr, srcarr, sz1); - } -} - ////////////////////////////////////////////////////////////////////////////////////////// LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr, Type *type) {