From d7047f639e4d7200835e666d5a0c779e3ff73651 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Wed, 3 Nov 2010 19:46:19 +0300 Subject: [PATCH] Rehash associative array right after its creating (DMD seems to be doing the same) --- gen/toir.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gen/toir.cpp b/gen/toir.cpp index aec18094..9bf81e0a 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2695,6 +2695,25 @@ DValue* AssocArrayLiteralExp::toElem(IRState* p) DtoAssign(loc, mem, val); } +#if DMDV2 + // Rehash array + if (keys->dim) { + // first get the runtime function + llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_aaRehash"); + const llvm::FunctionType* funcTy = fn->getFunctionType(); + + // aa param + LLValue* aaval = DtoBitCast(tmp, funcTy->getParamType(0)); + + // keyti param + LLValue* keyti = DtoTypeInfoOf(((TypeAArray*)aatype)->index, false); + keyti = DtoBitCast(keyti, funcTy->getParamType(1)); + + // Call function + gIR->CreateCallOrInvoke2(fn, aaval, keyti, ".gc_mem").getInstruction(); + } +#endif + return aa; }