Mercurial > projects > ldc
comparison gen/arrays.cpp @ 1342:16d9afa22df4
Fix DtoArrayCopyToSlice by passing length*sizeof(element) instead of just length to _d_array_slice_copy.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 10 May 2009 22:26:04 +0200 |
parents | c78fd2d30da1 |
children | 15e9762bb620 |
comparison
equal
deleted
inserted
replaced
1341:681dd955c53b | 1342:16d9afa22df4 |
---|---|
362 { | 362 { |
363 Logger::println("ArrayCopyToSlice"); | 363 Logger::println("ArrayCopyToSlice"); |
364 | 364 |
365 LLValue* sz1; | 365 LLValue* sz1; |
366 LLValue* dstarr = get_slice_ptr(dst,sz1); | 366 LLValue* dstarr = get_slice_ptr(dst,sz1); |
367 | |
367 LLValue* srcarr = DtoBitCast(DtoArrayPtr(src), getVoidPtrType()); | 368 LLValue* srcarr = DtoBitCast(DtoArrayPtr(src), getVoidPtrType()); |
369 const LLType* arrayelemty = DtoType(src->getType()->nextOf()->toBasetype()); | |
370 LLValue* sz2 = gIR->ir->CreateMul(DtoConstSize_t(getTypePaddedSize(arrayelemty)), DtoArrayLen(src), "tmp"); | |
368 | 371 |
369 if (global.params.useAssert || global.params.useArrayBounds) | 372 if (global.params.useAssert || global.params.useArrayBounds) |
370 { | 373 { |
371 LLValue* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_slice_copy"); | 374 LLValue* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_array_slice_copy"); |
372 gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, DtoArrayLen(src)); | 375 gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2); |
373 } | 376 } |
374 else | 377 else |
375 { | 378 { |
376 DtoMemCpy(dstarr, srcarr, sz1); | 379 DtoMemCpy(dstarr, srcarr, sz1); |
377 } | 380 } |