Index: src/main.cc
===================================================================
--- src/main.cc	(revision 6d611fbad907e655df57704c865a57c64b6c6756)
+++ src/main.cc	(revision 01690b7043d295891fbc0a37b36fabf82e4159d8)
@@ -63,6 +63,8 @@
 using namespace std;
 
-#define OPTPRINT(x) if ( errorp ) cerr << x << endl;
-
+#define PASS(name, pass)                   \
+	if ( errorp ) { cerr << #name << endl; } \
+	HeapStats::newPass(#name);               \
+	pass;
 
 LinkageSpec::Spec linkage = LinkageSpec::Cforall;
@@ -245,6 +247,5 @@
 
 		// add the assignment statement after the initialization of a type parameter
-		OPTPRINT( "validate" )
-		SymTab::validate( translationUnit, symtabp );
+		PASS( "validate", SymTab::validate( translationUnit, symtabp ) );
 		if ( symtabp ) {
 			deleteAll( translationUnit );
@@ -263,12 +264,8 @@
 		} // if
 
-		OPTPRINT( "mutate" )
-		ControlStruct::mutate( translationUnit );
-		OPTPRINT( "fixNames" )
-		CodeGen::fixNames( translationUnit );
-		OPTPRINT( "genInit" )
-		InitTweak::genInit( translationUnit );
-		OPTPRINT( "expandMemberTuples" );
-		Tuples::expandMemberTuples( translationUnit );
+		PASS( "mutate", ControlStruct::mutate( translationUnit ) );
+		PASS( "fixNames", CodeGen::fixNames( translationUnit ) );
+		PASS( "genInit", InitTweak::genInit( translationUnit ) );
+		PASS( "expandMemberTuples" , Tuples::expandMemberTuples( translationUnit ) );
 		if ( libcfap ) {
 			// generate the bodies of cfa library functions
@@ -289,6 +286,5 @@
 		CodeTools::fillLocations( translationUnit );
 
-		OPTPRINT( "resolve" )
-		ResolvExpr::resolve( translationUnit );
+		PASS( "resolve", ResolvExpr::resolve( translationUnit ) );
 		if ( exprp ) {
 			dump( translationUnit );
@@ -297,6 +293,5 @@
 
 		// fix ObjectDecl - replaces ConstructorInit nodes
-		OPTPRINT( "fixInit" )
-		InitTweak::fix( translationUnit, filename, libcfap || treep );
+		PASS( "fixInit", InitTweak::fix( translationUnit, filename, libcfap || treep ) );
 		if ( ctorinitp ) {
 			dump ( translationUnit );
@@ -304,18 +299,15 @@
 		} // if
 
-		OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
+		PASS( "expandUniqueExpr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
 		Tuples::expandUniqueExpr( translationUnit );
 
-		OPTPRINT( "translateEHM" );
-		ControlStruct::translateEHM( translationUnit );
-
-		OPTPRINT( "generateWaitfor" );
-		Concurrency::generateWaitFor( translationUnit );
-
-		OPTPRINT( "convertSpecializations" ) // needs to happen before tuple types are expanded
-		GenPoly::convertSpecializations( translationUnit );
-
-		OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
-		Tuples::expandTuples( translationUnit );
+		PASS( "translateEHM" , ControlStruct::translateEHM( translationUnit ) );
+
+		PASS( "generateWaitfor" , Concurrency::generateWaitFor( translationUnit ) );
+
+		PASS( "convertSpecializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
+
+		PASS( "expandTuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
+
 		if ( tuplep ) {
 			dump( translationUnit );
@@ -323,15 +315,12 @@
 		}
 
-		OPTPRINT( "virtual expandCasts" ) // Must come after translateEHM
-		Virtual::expandCasts( translationUnit );
-
-		OPTPRINT("instantiateGenerics")
-		GenPoly::instantiateGeneric( translationUnit );
+		PASS( "virtual expandCasts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
+
+		PASS( "instantiateGenerics", GenPoly::instantiateGeneric( translationUnit ) );
 		if ( genericsp ) {
 			dump( translationUnit );
 			return 0;
 		}
-		OPTPRINT( "convertLvalue" )
-		GenPoly::convertLvalue( translationUnit );
+		PASS( "convertLvalue", GenPoly::convertLvalue( translationUnit ) );
 
 
@@ -340,6 +329,5 @@
 			return 0;
 		} // if
-		OPTPRINT( "box" )
-		GenPoly::box( translationUnit );
+		PASS( "box", GenPoly::box( translationUnit ) );
 
 		if ( bcodegenp ) {
@@ -353,11 +341,7 @@
 
 		CodeTools::fillLocations( translationUnit );
-		OPTPRINT( "codegen" )
-		CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks );
+		PASS( "codegen", CodeGen::generate( translationUnit, *output, ! noprotop, prettycodegenp, true, linemarks ) );
 
 		CodeGen::FixMain::fix( *output, treep ? "../prelude/bootloader.c" : CFA_LIBDIR "/bootloader.c" );
-		OPTPRINT( "end" )
-
-
 		if ( output != &cout ) {
 			delete output;
