diff gen/tollvm.c @ 67:f918f3e2e99e trunk

[svn r71] Fixed accessing parent function arguments from inside nested delegates. Some cleanups in VarExp::toElem.
author lindquist
date Sun, 28 Oct 2007 02:46:06 +0200
parents b86e00b938a5
children 2b5a2eaa88be
line wrap: on
line diff
--- a/gen/tollvm.c	Sun Oct 28 02:03:42 2007 +0200
+++ b/gen/tollvm.c	Sun Oct 28 02:46:06 2007 +0200
@@ -1306,7 +1306,10 @@
 
     // on this stack
     if (fd == f) {
-        return LLVM_DtoGEPi(vd->llvmValue,0,unsigned(vd->llvmNestedIndex),"tmp");
+        llvm::Value* v = LLVM_DtoGEPi(vd->llvmValue,0,unsigned(vd->llvmNestedIndex),"tmp");
+        if (vd->isParameter() && (vd->isRef() || vd->isOut()))
+            v = gIR->ir->CreateLoad(v,"tmp");
+        return v;
     }
 
     // on a caller stack
@@ -1325,7 +1328,10 @@
 
     while (f) {
         if (fd == f) {
-            return LLVM_DtoGEPi(ptr,0,vd->llvmNestedIndex,"tmp");
+            llvm::Value* v = LLVM_DtoGEPi(ptr,0,vd->llvmNestedIndex,"tmp");
+            if (vd->isParameter() && (vd->isRef() || vd->isOut()))
+                v = gIR->ir->CreateLoad(v,"tmp");
+            return v;
         }
         else {
             ptr = LLVM_DtoGEPi(ptr,0,0,"tmp");