Use type gep in initializeArrayLiteral (#4092)

This commit is contained in:
Nicholas Wilson 2022-09-01 17:14:57 +08:00 committed by GitHub
parent 3c2b8906b0
commit f2155c6dd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -588,7 +588,8 @@ llvm::Constant *arrayLiteralToConst(IRState *p, ArrayLiteralExp *ale) {
////////////////////////////////////////////////////////////////////////////////
void initializeArrayLiteral(IRState *p, ArrayLiteralExp *ale, LLValue *dstMem) {
void initializeArrayLiteral(IRState *p, ArrayLiteralExp *ale,
LLValue *dstMem, LLType *dstType) {
size_t elemCount = ale->elements->length;
// Don't try to write nothing to a zero-element array, we might represent it
@ -618,7 +619,7 @@ void initializeArrayLiteral(IRState *p, ArrayLiteralExp *ale, LLValue *dstMem) {
for (size_t i = 0; i < elemCount; ++i) {
Expression *rhsExp = indexArrayLiteral(ale, i);
LLValue *lhsPtr = DtoGEP(dstMem, 0, i, "", p->scopebb());
LLValue *lhsPtr = DtoGEP(dstType, dstMem, 0, i, "", p->scopebb());
DLValue lhs(rhsExp->type, DtoBitCast(lhsPtr, DtoPtrToType(rhsExp->type)));
// try to construct it in-place