From cbd02963289dc15210b026d7b0cfc296c7a20817 Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Thu, 6 Jan 2011 19:41:54 +0300 Subject: [PATCH] Implemented CommaExp::cacheLvalue(). Fixed CallExp::chackLvalue(). --- dmd2/expression.h | 3 +-- gen/toir.cpp | 31 +++++++++++++++++++------------ ir/irfunction.cpp | 2 +- phobos.patch | 13 +------------ 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/dmd2/expression.h b/dmd2/expression.h index 474bcfed..357bfc67 100644 --- a/dmd2/expression.h +++ b/dmd2/expression.h @@ -1122,10 +1122,8 @@ struct CallExp : UnaExp #if IN_LLVM DValue* toElem(IRState* irs); -#if DMDV2 void cacheLvalue(IRState* p); #endif -#endif }; struct AddrExp : UnaExp @@ -1415,6 +1413,7 @@ struct CommaExp : BinExp #if IN_LLVM DValue* toElem(IRState* irs); + void cacheLvalue(IRState* irs); #endif }; diff --git a/gen/toir.cpp b/gen/toir.cpp index deb45215..a58039a8 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -52,14 +52,6 @@ llvm::cl::opt checkPrintf("check-printf-calls", void Expression::cacheLvalue(IRState* irs) { -#if DMDV2 - if (isLvalue()) { - Logger::println("Caching l-value of %s", toChars()); - LOG_SCOPE; - cachedLvalue = toElem(irs)->getLVal(); - return; - } -#endif error("expression %s does not mask any l-value", toChars()); fatal(); } @@ -786,8 +778,6 @@ DValue* ModExp::toElem(IRState* p) ////////////////////////////////////////////////////////////////////////////////////////// -#if DMDV2 - void CallExp::cacheLvalue(IRState* p) { @@ -796,8 +786,6 @@ void CallExp::cacheLvalue(IRState* p) cachedLvalue = toElem(p)->getLVal(); } -#endif - ////////////////////////////////////////////////////////////////////////////////////////// DValue* CallExp::toElem(IRState* p) @@ -805,6 +793,12 @@ DValue* CallExp::toElem(IRState* p) Logger::print("CallExp::toElem: %s @ %s\n", toChars(), type->toChars()); LOG_SCOPE; + if (cachedLvalue) + { + LLValue* V = cachedLvalue; + return new DVarValue(type, V); + } + // handle magic inline asm if (e1->op == TOKvar) { @@ -2229,12 +2223,25 @@ DValue* CommaExp::toElem(IRState* p) Logger::print("CommaExp::toElem: %s @ %s\n", toChars(), type->toChars()); LOG_SCOPE; + if (cachedLvalue) + { + LLValue* V = cachedLvalue; + return new DVarValue(type, V); + } + DValue* u = e1->toElem(p); DValue* v = e2->toElem(p); assert(e2->type == type); return v; } +void CommaExp::cacheLvalue(IRState* p) +{ + Logger::println("Caching l-value of %s", toChars()); + LOG_SCOPE; + cachedLvalue = toElem(p)->getLVal(); +} + ////////////////////////////////////////////////////////////////////////////////////////// DValue* CondExp::toElem(IRState* p) diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index 575edffc..b2067646 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -88,7 +88,7 @@ void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval) LLValue *rval = val->getRVal(); #if DMDV2 - if (DtoIsPassedByRef(val->type)) + if (DtoIsPassedByRef(val->type) && isaPointer(rval)) rval = DtoLoad(rval); #endif DtoStore(rval, lval); diff --git a/phobos.patch b/phobos.patch index 0e23aac5..1311d5e8 100644 --- a/phobos.patch +++ b/phobos.patch @@ -1,14 +1,3 @@ -diff -U 3 -H -d -r -N -x '*.mak' -x tk -x backend -x debug -x release -x '*_pch.h' -x Makefile -x '*.rej' -x '*~' -x '*.log' -x .svn -x '*pro.user' -x .directory -x cmake_install -x CMakeFiles -x .preprocessed.tmp -x 'Makefile.*' -x '*.orig' -- phobos-orig/std/base64.d phobos/std/base64.d ---- phobos-orig/std/base64.d 2010-12-20 23:02:36.000000000 +0300 -+++ phobos/std/base64.d 2011-01-06 12:56:56.420864296 +0300 -@@ -1577,6 +1577,7 @@ - } - } - -+ version (LDC) {} // FIXME: - { // Encoder and Decoder for single character encoding and decoding - alias Base64Impl!('+', '/', Base64.NoPadding) Base64NoPadding; - diff -U 3 -H -d -r -N -x '*.mak' -x tk -x backend -x debug -x release -x '*_pch.h' -x Makefile -x '*.rej' -x '*~' -x '*.log' -x .svn -x '*pro.user' -x .directory -x cmake_install -x CMakeFiles -x .preprocessed.tmp -x 'Makefile.*' -x '*.orig' -- phobos-orig/std/concurrency.d phobos/std/concurrency.d --- phobos-orig/std/concurrency.d 2010-12-20 23:02:36.000000000 +0300 +++ phobos/std/concurrency.d 2011-01-05 15:15:31.000000000 +0300 @@ -50,7 +39,7 @@ diff -U 3 -H -d -r -N -x '*.mak' -x tk -x backend -x debug -x release -x '*_pch. return to!T(buffer[0 .. len].dup); diff -U 3 -H -d -r -N -x '*.mak' -x tk -x backend -x debug -x release -x '*_pch.h' -x Makefile -x '*.rej' -x '*~' -x '*.log' -x .svn -x '*pro.user' -x .directory -x cmake_install -x CMakeFiles -x .preprocessed.tmp -x 'Makefile.*' -x '*.orig' -- phobos-orig/std/functional.d phobos/std/functional.d --- phobos-orig/std/functional.d 2010-12-20 23:02:36.000000000 +0300 -+++ phobos/std/functional.d 2011-01-05 15:15:31.000000000 +0300 ++++ phobos/std/functional.d 2011-01-06 19:41:23.740864295 +0300 @@ -714,6 +714,13 @@ assert(dg_pure_nothrow() == 7); //assert(dg_pure_nothrow_safe() == 8);