Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc	(revision b03eed6a17a1fe2f04d90bcdc9417eaddbcac5c7)
+++ src/GenPoly/Lvalue.cc	(revision da7fe3906c96450ab7bb9652fd41097ef1096f9e)
@@ -17,4 +17,5 @@
 #include <string>                        // for string
 
+#include "Common/Debug.h"
 #include "Common/PassVisitor.h"
 #include "GenPoly.h"                     // for isPolyType
@@ -128,11 +129,19 @@
 		PassVisitor<AddrRef> addrRef;
 		PassVisitor<FixIntrinsicResult> intrinsicResults;
+		Debug::codeGen( translationUnit, "begin" );
 		mutateAll( translationUnit, intrinsicResults );
+		Debug::codeGen( translationUnit, "intrinsicResults" );
 		mutateAll( translationUnit, addrRef );
+		Debug::codeGen( translationUnit, "addrRef" );
 		mutateAll( translationUnit, refCvt );
+		Debug::codeGen( translationUnit, "refCvt" );
 		mutateAll( translationUnit, fixer );
+		Debug::codeGen( translationUnit, "fixer" );
 		mutateAll( translationUnit, collapser );
+		Debug::codeGen( translationUnit, "collapser" );
 		mutateAll( translationUnit, genLval );
+		Debug::codeGen( translationUnit, "genLval" );
 		mutateAll( translationUnit, elim );  // last because other passes need reference types to work
+		Debug::codeGen( translationUnit, "elim" );
 
 		// from this point forward, no other pass should create reference types.
@@ -211,5 +220,7 @@
 						)
 						// TODO: it's likely that the second condition should be ... && ! isIntrinsicReference( arg ), but this requires investigation.
+
 						if ( function->get_linkage() != LinkageSpec::Intrinsic && isIntrinsicReference( arg ) ) {
+							// needed for definition of prelude functions, etc.
 							// if argument is dereference or array subscript, the result isn't REALLY a reference, but non-intrinsic functions expect a reference: take address
 
@@ -225,4 +236,5 @@
 							)
 							arg = new AddressExpr( arg );
+						// } else if ( function->get_linkage() == LinkageSpec::Intrinsic && InitTweak::getPointerBase( arg->result ) ) {
 						} else if ( function->get_linkage() == LinkageSpec::Intrinsic && arg->result->referenceDepth() != 0 ) {
 							// argument is a 'real' reference, but function expects a C lvalue: add a dereference to the reference-typed argument
@@ -234,7 +246,7 @@
 							PointerType * ptrType = new PointerType( Type::Qualifiers(), baseType->clone() );
 							delete arg->result;
-							arg->set_result( ptrType );
+							arg->result = ptrType;
 							arg = mkDeref( arg );
-							assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );
+							// assertf( arg->result->referenceDepth() == 0, "Reference types should have been eliminated from intrinsic function calls, but weren't: %s", toCString( arg->result ) );
 						}
 					}
@@ -413,4 +425,5 @@
 				for ( int i = 0; i < diff; ++i ) {
 					ret = mkDeref( ret );
+					// xxx - try removing one reference here? actually, looks like mkDeref already does this, so more closely look at the types generated.
 				}
 				if ( ! ResolvExpr::typesCompatibleIgnoreQualifiers( destType->stripReferences(), srcType->stripReferences(), SymTab::Indexer() ) ) {
