diff gen/aa.cpp @ 1643:8f121883bce8

Apply patch from klickverbot. This is his 'proper fix' patch for bug #395.
author Kelly Wilson <wilsonk cpsc.ucalgary.ca>
date Mon, 08 Mar 2010 23:37:40 -0700
parents 819b4f961711
children
line wrap: on
line diff
--- a/gen/aa.cpp	Mon Mar 08 23:10:26 2010 -0700
+++ b/gen/aa.cpp	Mon Mar 08 23:37:40 2010 -0700
@@ -14,41 +14,6 @@
 #include "gen/dvalue.h"
 #include "ir/irmodule.h"
 
-// makes sure the key value lives in memory so it can be passed to the runtime functions without problems
-// returns the pointer
-static LLValue* to_pkey(Loc& loc, DValue* key)
-{
-    Type* keytype = key->getType();
-    bool needmem = !DtoIsPassedByRef(keytype);
-    LLValue* pkey;
-    if (key->isIm()) {
-        pkey = key->getRVal();
-    }
-    else if (DVarValue* var = key->isVar()) {
-        pkey = key->getLVal();
-        needmem = false;
-    }
-    else if (key->isConst()) {
-        needmem = true;
-        pkey = key->getRVal();
-    }
-    else {
-        LLValue* tmp = DtoAlloca(keytype, "aatmpkeystorage");
-        DVarValue var(keytype, tmp);
-        DtoAssign(loc, &var, key);
-        return tmp;
-    }
-
-    // give memory
-    if (needmem) {
-        LLValue* tmp = DtoAlloca(keytype, "aatmpkeystorage");
-        DtoStore(pkey, tmp);
-        pkey = tmp;
-    }
-
-    return pkey;
-}
-
 // returns the keytype typeinfo
 static LLValue* to_keyti(DValue* key)
 {
@@ -79,7 +44,7 @@
     keyti = DtoBitCast(keyti, funcTy->getParamType(1));
 
     // pkey param
-    LLValue* pkey = to_pkey(loc, key);
+    LLValue* pkey = makeLValue(loc, key);
     pkey = DtoBitCast(pkey, funcTy->getParamType(lvalue ? 3 : 2));
 
     // call runtime
@@ -164,7 +129,7 @@
     keyti = DtoBitCast(keyti, funcTy->getParamType(1));
 
     // pkey param
-    LLValue* pkey = to_pkey(loc, key);
+    LLValue* pkey = makeLValue(loc, key);
     pkey = DtoBitCast(pkey, funcTy->getParamType(2));
 
     // call runtime
@@ -206,7 +171,7 @@
     keyti = DtoBitCast(keyti, funcTy->getParamType(1));
 
     // pkey param
-    LLValue* pkey = to_pkey(loc, key);
+    LLValue* pkey = makeLValue(loc, key);
     pkey = DtoBitCast(pkey, funcTy->getParamType(2));
 
     // build arg vector