changeset 173:db9890b3fb64 trunk

[svn r189] moving IR data back into DMD frontend nodes
author ChristianK
date Tue, 06 May 2008 07:56:03 +0200
parents 68a7dd38c03c
children 16e676ae5ab4
files dmd/dsymbol.h dmd/mtype.h gen/aa.cpp gen/arrays.cpp gen/classes.cpp gen/functions.cpp gen/irstate.h gen/runtime.cpp gen/statements.cpp gen/structs.cpp gen/todebug.cpp gen/toir.cpp gen/tollvm.cpp gen/toobj.cpp gen/typinf.cpp ir/irstruct.cpp ir/irsymbol.cpp ir/irsymbol.h ir/irtype.cpp ir/irtype.h
diffstat 20 files changed, 646 insertions(+), 520 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/dsymbol.h	Tue May 06 07:26:27 2008 +0200
+++ b/dmd/dsymbol.h	Tue May 06 07:56:03 2008 +0200
@@ -21,6 +21,9 @@
 #include "mars.h"
 #include "arraytypes.h"
 
+// llvm
+#include "../ir/irsymbol.h"
+
 struct Identifier;
 struct Scope;
 struct DsymbolTable;
@@ -76,6 +79,7 @@
 struct TYPE;
 #endif
 
+// llvm
 #if IN_LLVM
 namespace llvm
 {
@@ -220,6 +224,8 @@
     int llvmInternal;
     char* llvmInternal1;
     char* llvmInternal2;
+    
+    IrDsymbol ir;
 };
 
 // Dsymbol that generates a scope
--- a/dmd/mtype.h	Tue May 06 07:26:27 2008 +0200
+++ b/dmd/mtype.h	Tue May 06 07:56:03 2008 +0200
@@ -21,6 +21,9 @@
 #include "arraytypes.h"
 #include "expression.h"
 
+// llvm
+#include "../ir/irtype.h"
+
 struct Scope;
 struct Identifier;
 struct Expression;
@@ -248,6 +251,9 @@
 
     // For eliminating dynamic_cast
     virtual TypeBasic *isTypeBasic();
+
+    // llvmdc
+    IrType ir;
 };
 
 struct TypeBasic : Type
--- a/gen/aa.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/aa.cpp	Tue May 06 07:56:03 2008 +0200
@@ -61,8 +61,8 @@
     assert(tid);
     DtoResolveDsymbol(Type::typeinfo);
     DtoForceDeclareDsymbol(tid);
-    assert(gIR->irDsymbol[tid].irGlobal->value);
-    return gIR->irDsymbol[tid].irGlobal->value;
+    assert(tid->ir.irGlobal->value);
+    return tid->ir.irGlobal->value;
 }
 
 /////////////////////////////////////////////////////////////////////////////////////
--- a/gen/arrays.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/arrays.cpp	Tue May 06 07:56:03 2008 +0200
@@ -41,8 +41,8 @@
 
 const llvm::ArrayType* DtoStaticArrayType(Type* t)
 {
-    if (gIR->irType[t].type)
-        return isaArray(gIR->irType[t].type->get());
+    if (t->ir.type)
+        return isaArray(t->ir.type->get());
 
     assert(t->ty == Tsarray);
     assert(t->next);
@@ -53,8 +53,8 @@
     assert(tsa->dim->type->isintegral());
     const llvm::ArrayType* arrty = llvm::ArrayType::get(at,tsa->dim->toUInteger());
 
-    assert(!gIR->irType[tsa].type);
-    gIR->irType[tsa].type = new llvm::PATypeHolder(arrty);
+    assert(!tsa->ir.type);
+    tsa->ir.type = new llvm::PATypeHolder(arrty);
     return arrty;
 }
 
@@ -702,10 +702,10 @@
     if (useti) {
         TypeInfoDeclaration* ti = DtoDType(l->getType())->next->getTypeInfoDeclaration();
         DtoForceConstInitDsymbol(ti);
-        Logger::cout() << "typeinfo decl: " << *gIR->irDsymbol[ti].getIrValue() << '\n';
+        Logger::cout() << "typeinfo decl: " << *ti->ir.getIrValue() << '\n';
 
         pt = fn->getFunctionType()->getParamType(2);
-        args.push_back(DtoBitCast(gIR->irDsymbol[ti].getIrValue(), pt));
+        args.push_back(DtoBitCast(ti->ir.getIrValue(), pt));
     }
 
     return gIR->ir->CreateCall(fn, args.begin(), args.end(), "tmp");
--- a/gen/classes.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/classes.cpp	Tue May 06 07:56:03 2008 +0200
@@ -35,15 +35,15 @@
         if (bc->base->isInterfaceDeclaration())
         {
             // don't add twice
-            if (gIR->irDsymbol[target].irStruct->interfaceMap.find(bc->base) == gIR->irDsymbol[target].irStruct->interfaceMap.end())
+            if (target->ir.irStruct->interfaceMap.find(bc->base) == target->ir.irStruct->interfaceMap.end())
             {
                 Logger::println("adding interface '%s'", bc->base->toPrettyChars());
                 IrInterface* iri = new IrInterface(bc, NULL);
 
                 // add to map
-                gIR->irDsymbol[target].irStruct->interfaceMap.insert(std::make_pair(bc->base, iri));
+                target->ir.irStruct->interfaceMap.insert(std::make_pair(bc->base, iri));
                 // add to ordered list
-                gIR->irDsymbol[target].irStruct->interfaceVec.push_back(iri);
+                target->ir.irStruct->interfaceVec.push_back(iri);
 
                 // Fill in vtbl[]
                 if (!target->isAbstract()) {
@@ -88,8 +88,8 @@
 
 void DtoResolveClass(ClassDeclaration* cd)
 {
-    if (gIR->irDsymbol[cd].resolved) return;
-    gIR->irDsymbol[cd].resolved = true;
+    if (cd->ir.resolved) return;
+    cd->ir.resolved = true;
 
     Logger::println("DtoResolveClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
     LOG_SCOPE;
@@ -99,10 +99,10 @@
     TypeClass* ts = (TypeClass*)cd->type;
 
     // make sure the IrStruct is created
-    IrStruct* irstruct = gIR->irDsymbol[cd].irStruct;
+    IrStruct* irstruct = cd->ir.irStruct;
     if (!irstruct) {
         irstruct = new IrStruct(ts);
-        gIR->irDsymbol[cd].irStruct = irstruct;
+        cd->ir.irStruct = irstruct;
     }
 
     // resolve the base class
@@ -128,8 +128,8 @@
     gIR->classes.push_back(cd);
 
     // add vtable
-    gIR->irType[ts].vtblType = new llvm::PATypeHolder(llvm::OpaqueType::get());
-    const llvm::Type* vtabty = getPtrToType(gIR->irType[ts].vtblType->get());
+    ts->ir.vtblType = new llvm::PATypeHolder(llvm::OpaqueType::get());
+    const llvm::Type* vtabty = getPtrToType(ts->ir.vtblType->get());
 
     std::vector<const llvm::Type*> fieldtypes;
     fieldtypes.push_back(vtabty);
@@ -169,7 +169,7 @@
                 fieldtype = i->second.type;
                 fieldinit = i->second.var;
                 prevsize = getABITypeSize(fieldtype);
-                gIR->irDsymbol[i->second.var].irField->index = idx;
+                i->second.var->ir.irField->index = idx;
             }
             // colliding offset?
             else if (lastoffset == i->first) {
@@ -178,16 +178,16 @@
                     fieldpad += s - prevsize;
                     prevsize = s;
                 }
-                gIR->irDsymbol[cd].irStruct->hasUnions = true;
-                gIR->irDsymbol[i->second.var].irField->index = idx;
+                cd->ir.irStruct->hasUnions = true;
+                i->second.var->ir.irField->index = idx;
             }
             // intersecting offset?
             else if (i->first < (lastoffset + prevsize)) {
                 size_t s = getABITypeSize(i->second.type);
                 assert((i->first + s) <= (lastoffset + prevsize)); // this holds because all types are aligned to their size
-                gIR->irDsymbol[cd].irStruct->hasUnions = true;
-                gIR->irDsymbol[i->second.var].irField->index = idx;
-                gIR->irDsymbol[i->second.var].irField->indexOffset = (i->first - lastoffset) / s;
+                cd->ir.irStruct->hasUnions = true;
+                i->second.var->ir.irField->index = idx;
+                i->second.var->ir.irField->indexOffset = (i->first - lastoffset) / s;
             }
             // fresh offset
             else {
@@ -207,7 +207,7 @@
                 fieldtype = i->second.type;
                 fieldinit = i->second.var;
                 prevsize = getABITypeSize(fieldtype);
-                gIR->irDsymbol[i->second.var].irField->index = idx;
+                i->second.var->ir.irField->index = idx;
                 fieldpad = 0;
             }
         }
@@ -224,8 +224,8 @@
         Logger::println("Adding interfaces to '%s'", cd->toPrettyChars());
         LOG_SCOPE;
         LLVM_AddBaseClassInterfaces(cd, &cd->baseclasses);
-        Logger::println("%d interfaces added", gIR->irDsymbol[cd].irStruct->interfaceVec.size());
-        assert(gIR->irDsymbol[cd].irStruct->interfaceVec.size() == gIR->irDsymbol[cd].irStruct->interfaceMap.size());
+        Logger::println("%d interfaces added", cd->ir.irStruct->interfaceVec.size());
+        assert(cd->ir.irStruct->interfaceVec.size() == cd->ir.irStruct->interfaceMap.size());
     }
 
     // add interface vtables at the end
@@ -237,17 +237,17 @@
 
         // set vtbl type
         TypeClass* itc = (TypeClass*)id->type;
-        const llvm::Type* ivtblTy = getPtrToType(gIR->irType[itc].vtblType->get());
+        const llvm::Type* ivtblTy = getPtrToType(itc->ir.vtblType->get());
         fieldtypes.push_back(ivtblTy);
 
         // fix the interface vtable type
-        iri->vtblTy = isaStruct(gIR->irType[itc].vtblType->get());
+        iri->vtblTy = isaStruct(itc->ir.vtblType->get());
 
         // set index
         iri->index = interIdx++;
     }
-    Logger::println("%d interface vtables added", gIR->irDsymbol[cd].irStruct->interfaceVec.size());
-    assert(gIR->irDsymbol[cd].irStruct->interfaceVec.size() == gIR->irDsymbol[cd].irStruct->interfaceMap.size());
+    Logger::println("%d interface vtables added", cd->ir.irStruct->interfaceVec.size());
+    assert(cd->ir.irStruct->interfaceVec.size() == cd->ir.irStruct->interfaceMap.size());
 
     // create type
     const llvm::StructType* structtype = llvm::StructType::get(fieldtypes);
@@ -259,14 +259,14 @@
     structtype = isaStruct(spa.get());
 
     // make it official
-    if (!gIR->irType[ts].type)
-        gIR->irType[ts].type = new llvm::PATypeHolder(structtype);
+    if (!ts->ir.type)
+        ts->ir.type = new llvm::PATypeHolder(structtype);
     else
-        *gIR->irType[ts].type = structtype;
-    spa = *gIR->irType[ts].type;
+        *ts->ir.type = structtype;
+    spa = *ts->ir.type;
 
     // name the type
-    gIR->module->addTypeName(cd->mangle(), gIR->irType[ts].type->get());
+    gIR->module->addTypeName(cd->mangle(), ts->ir.type->get());
 
     // get interface info type
     const llvm::StructType* infoTy = DtoInterfaceInfoType();
@@ -285,7 +285,7 @@
             DtoResolveFunction(fd);
             //assert(fd->type->ty == Tfunction);
             //TypeFunction* tf = (TypeFunction*)fd->type;
-            //const llvm::Type* fpty = getPtrToType(gIR->irType[tf].type->get());
+            //const llvm::Type* fpty = getPtrToType(tf->ir.type->get());
             const llvm::FunctionType* vfty = DtoBaseFunctionType(fd);
             const llvm::Type* vfpty = getPtrToType(vfty);
             sinits_ty.push_back(vfpty);
@@ -297,11 +297,11 @@
                 cinfoty = infoTy;
             }
             else if (cd != ClassDeclaration::classinfo) {
-                cinfoty = gIR->irType[ClassDeclaration::classinfo->type].type->get();
+                cinfoty = ClassDeclaration::classinfo->type->ir.type->get();
             }
             else {
                 // this is the ClassInfo class, the type is this type
-                cinfoty = gIR->irType[ts].type->get();
+                cinfoty = ts->ir.type->get();
             }
             const llvm::Type* cty = getPtrToType(cinfoty);
             sinits_ty.push_back(cty);
@@ -318,7 +318,7 @@
     gIR->module->addTypeName(styname, svtbl_ty);
 
     // refine for final vtable type
-    llvm::cast<llvm::OpaqueType>(gIR->irType[ts].vtblType->get())->refineAbstractTypeTo(svtbl_ty);
+    llvm::cast<llvm::OpaqueType>(ts->ir.vtblType->get())->refineAbstractTypeTo(svtbl_ty);
 
     gIR->classes.pop_back();
     gIR->structs.pop_back();
@@ -330,8 +330,8 @@
 
 void DtoDeclareClass(ClassDeclaration* cd)
 {
-    if (gIR->irDsymbol[cd].declared) return;
-    gIR->irDsymbol[cd].declared = true;
+    if (cd->ir.declared) return;
+    cd->ir.declared = true;
 
     Logger::println("DtoDeclareClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
     LOG_SCOPE;
@@ -339,8 +339,8 @@
     assert(cd->type->ty == Tclass);
     TypeClass* ts = (TypeClass*)cd->type;
 
-    assert(gIR->irDsymbol[cd].irStruct);
-    IrStruct* irstruct = gIR->irDsymbol[cd].irStruct;
+    assert(cd->ir.irStruct);
+    IrStruct* irstruct = cd->ir.irStruct;
 
     gIR->structs.push_back(irstruct);
     gIR->classes.push_back(cd);
@@ -360,21 +360,21 @@
         varname.append(cd->mangle());
         varname.append("6__vtblZ");
 
-        const llvm::StructType* svtbl_ty = isaStruct(gIR->irType[ts].vtblType->get());
-        gIR->irDsymbol[cd].irStruct->vtbl = new llvm::GlobalVariable(svtbl_ty, true, _linkage, 0, varname, gIR->module);
+        const llvm::StructType* svtbl_ty = isaStruct(ts->ir.vtblType->get());
+        cd->ir.irStruct->vtbl = new llvm::GlobalVariable(svtbl_ty, true, _linkage, 0, varname, gIR->module);
     }
 
     // get interface info type
     const llvm::StructType* infoTy = DtoInterfaceInfoType();
 
     // interface info array
-    if (!gIR->irDsymbol[cd].irStruct->interfaceVec.empty()) {
+    if (!cd->ir.irStruct->interfaceVec.empty()) {
         // symbol name
         std::string nam = "_D";
         nam.append(cd->mangle());
         nam.append("16__interfaceInfosZ");
         // resolve array type
-        const llvm::ArrayType* arrTy = llvm::ArrayType::get(infoTy, gIR->irDsymbol[cd].irStruct->interfaceVec.size());
+        const llvm::ArrayType* arrTy = llvm::ArrayType::get(infoTy, cd->ir.irStruct->interfaceVec.size());
         // declare global
         irstruct->interfaceInfosTy = arrTy;
         irstruct->interfaceInfos = new llvm::GlobalVariable(arrTy, true, _linkage, NULL, nam, gIR->module);
@@ -408,8 +408,8 @@
         initname.append(cd->mangle());
         initname.append("6__initZ");
 
-        llvm::GlobalVariable* initvar = new llvm::GlobalVariable(gIR->irType[ts].type->get(), true, _linkage, NULL, initname, gIR->module);
-        gIR->irDsymbol[cd].irStruct->init = initvar;
+        llvm::GlobalVariable* initvar = new llvm::GlobalVariable(ts->ir.type->get(), true, _linkage, NULL, initname, gIR->module);
+        cd->ir.irStruct->init = initvar;
     }
 
     gIR->classes.pop_back();
@@ -431,8 +431,8 @@
 
 void DtoConstInitClass(ClassDeclaration* cd)
 {
-    if (gIR->irDsymbol[cd].initialized) return;
-    gIR->irDsymbol[cd].initialized = true;
+    if (cd->ir.initialized) return;
+    cd->ir.initialized = true;
 
     if (cd->isInterfaceDeclaration())
         return; // nothing to do
@@ -440,15 +440,15 @@
     Logger::println("DtoConstInitClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
     LOG_SCOPE;
 
-    IrStruct* irstruct = gIR->irDsymbol[cd].irStruct;
+    IrStruct* irstruct = cd->ir.irStruct;
     gIR->structs.push_back(irstruct);
     gIR->classes.push_back(cd);
 
     // get the struct (class) type
     assert(cd->type->ty == Tclass);
     TypeClass* ts = (TypeClass*)cd->type;
-    const llvm::StructType* structtype = isaStruct(gIR->irType[ts].type->get());
-    const llvm::StructType* vtbltype = isaStruct(gIR->irType[ts].vtblType->get());
+    const llvm::StructType* structtype = isaStruct(ts->ir.type->get());
+    const llvm::StructType* vtbltype = isaStruct(ts->ir.vtblType->get());
 
     // make sure each offset knows its default initializer
     for (IrStruct::OffsetMap::iterator i=irstruct->offsets.begin(); i!=irstruct->offsets.end(); ++i)
@@ -456,7 +456,7 @@
         IrStruct::Offset* so = &i->second;
         llvm::Constant* finit = DtoConstFieldInitializer(so->var->type, so->var->init);
         so->init = finit;
-        gIR->irDsymbol[so->var].irField->constInit = finit;
+        so->var->ir.irField->constInit = finit;
     }
 
     // fill out fieldtypes/inits
@@ -468,15 +468,15 @@
         fieldinits.push_back(
             llvm::ConstantPointerNull::get(
                 getPtrToType(
-                    gIR->irType[ts].vtblType->get()
+                    ts->ir.vtblType->get()
                 )
             )
         );
     }
     else
     {
-        assert(gIR->irDsymbol[cd].irStruct->vtbl != 0);
-        fieldinits.push_back(gIR->irDsymbol[cd].irStruct->vtbl);
+        assert(cd->ir.irStruct->vtbl != 0);
+        fieldinits.push_back(cd->ir.irStruct->vtbl);
     }
 
     // then comes monitor
@@ -487,7 +487,7 @@
     for (size_t i=0; i<nfi; ++i) {
         llvm::Constant* c;
         if (irstruct->defaultFields[i]) {
-            c = gIR->irDsymbol[irstruct->defaultFields[i]].irField->constInit;
+            c = irstruct->defaultFields[i]->ir.irField->constInit;
             assert(c);
         }
         else {
@@ -536,7 +536,7 @@
 
     llvm::Constant* _init = llvm::ConstantStruct::get(structtype, fieldinits);
     assert(_init);
-    gIR->irDsymbol[cd].irStruct->constInit = _init;
+    cd->ir.irStruct->constInit = _init;
 
     // abstract classes have no static vtable
     // neither do interfaces (on their own, the implementing class supplies the vtable)
@@ -553,23 +553,23 @@
 
             if (FuncDeclaration* fd = dsym->isFuncDeclaration()) {
                 DtoForceDeclareDsymbol(fd);
-                assert(gIR->irDsymbol[fd].irFunc->func);
-                llvm::Constant* c = llvm::cast<llvm::Constant>(gIR->irDsymbol[fd].irFunc->func);
+                assert(fd->ir.irFunc->func);
+                llvm::Constant* c = llvm::cast<llvm::Constant>(fd->ir.irFunc->func);
                 // cast if necessary (overridden method)
                 if (c->getType() != vtbltype->getElementType(k))
                     c = llvm::ConstantExpr::getBitCast(c, vtbltype->getElementType(k));
                 sinits.push_back(c);
             }
             else if (ClassDeclaration* cd2 = dsym->isClassDeclaration()) {
-                assert(gIR->irDsymbol[cd].irStruct->classInfo);
-                llvm::Constant* c = gIR->irDsymbol[cd].irStruct->classInfo;
+                assert(cd->ir.irStruct->classInfo);
+                llvm::Constant* c = cd->ir.irStruct->classInfo;
                 sinits.push_back(c);
             }
             else
             assert(0);
         }
 
-        const llvm::StructType* svtbl_ty = isaStruct(gIR->irType[ts].vtblType->get());
+        const llvm::StructType* svtbl_ty = isaStruct(ts->ir.vtblType->get());
 
 #if 0
         for (size_t i=0; i< sinits.size(); ++i)
@@ -581,7 +581,7 @@
 #endif
 
         llvm::Constant* cvtblInit = llvm::ConstantStruct::get(svtbl_ty, sinits);
-        gIR->irDsymbol[cd].irStruct->constVtbl = llvm::cast<llvm::ConstantStruct>(cvtblInit);
+        cd->ir.irStruct->constVtbl = llvm::cast<llvm::ConstantStruct>(cvtblInit);
 
         // create interface vtable const initalizers
         for (IrStruct::InterfaceVectorIter i=irstruct->interfaceVec.begin(); i!=irstruct->interfaceVec.end(); ++i)
@@ -593,14 +593,14 @@
             assert(id->type->ty == Tclass);
             TypeClass* its = (TypeClass*)id->type;
 
-            const llvm::StructType* ivtbl_ty = isaStruct(gIR->irType[its].vtblType->get());
+            const llvm::StructType* ivtbl_ty = isaStruct(its->ir.vtblType->get());
 
             // generate interface info initializer
             std::vector<llvm::Constant*> infoInits;
 
             // classinfo
-            assert(gIR->irDsymbol[id].irStruct->classInfo);
-            llvm::Constant* c = gIR->irDsymbol[id].irStruct->classInfo;
+            assert(id->ir.irStruct->classInfo);
+            llvm::Constant* c = id->ir.irStruct->classInfo;
             infoInits.push_back(c);
 
             // vtbl
@@ -612,11 +612,11 @@
             // offset
             // generate target independent offset with constGEP
             /*llvm::Value* cidx = DtoConstInt(iri->index);
-            Logger::cout() << "offset to interface in class type: " << *gIR->irType[cd->type].type->get() << '\n';
-            size_t ioff = gTargetData->getIndexedOffset(gIR->irType[cd->type].type->get(), &cidx, 1);
+            Logger::cout() << "offset to interface in class type: " << *cd->type->ir.type->get() << '\n';
+            size_t ioff = gTargetData->getIndexedOffset(cd->type->ir.type->get(), &cidx, 1);
             infoInits.push_back(DtoConstUint(ioff));*/
             assert(iri->index >= 0);
-            size_t ioff = gTargetData->getStructLayout(isaStruct(gIR->irType[cd->type].type->get()))->getElementOffset(iri->index);
+            size_t ioff = gTargetData->getStructLayout(isaStruct(cd->type->ir.type->get()))->getElementOffset(iri->index);
             infoInits.push_back(DtoConstUint(ioff));
 
             // create interface info initializer constant
@@ -636,8 +636,8 @@
                 FuncDeclaration* fd = dsym->isFuncDeclaration();
                 assert(fd);
                 DtoForceDeclareDsymbol(fd);
-                assert(gIR->irDsymbol[fd].irFunc->func);
-                llvm::Constant* c = llvm::cast<llvm::Constant>(gIR->irDsymbol[fd].irFunc->func);
+                assert(fd->ir.irFunc->func);
+                llvm::Constant* c = llvm::cast<llvm::Constant>(fd->ir.irFunc->func);
 
                 // we have to bitcast, as the type created in ResolveClass expects a different this type
                 c = llvm::ConstantExpr::getBitCast(c, iri->vtblTy->getContainedType(k));
@@ -673,8 +673,8 @@
             std::vector<llvm::Constant*> infoInits;
 
             // classinfo
-            assert(gIR->irDsymbol[id].irStruct->classInfo);
-            llvm::Constant* c = gIR->irDsymbol[id].irStruct->classInfo;
+            assert(id->ir.irStruct->classInfo);
+            llvm::Constant* c = id->ir.irStruct->classInfo;
             infoInits.push_back(c);
 
             // vtbl
@@ -698,8 +698,8 @@
 
 void DtoDefineClass(ClassDeclaration* cd)
 {
-    if (gIR->irDsymbol[cd].defined) return;
-    gIR->irDsymbol[cd].defined = true;
+    if (cd->ir.defined) return;
+    cd->ir.defined = true;
 
     Logger::println("DtoDefineClass(%s): %s", cd->toPrettyChars(), cd->loc.toChars());
     LOG_SCOPE;
@@ -713,11 +713,11 @@
         // neither do abstract classes
         if (!cd->isInterfaceDeclaration() && !cd->isAbstract())
         {
-            gIR->irDsymbol[cd].irStruct->init->setInitializer(gIR->irDsymbol[cd].irStruct->constInit);
-            gIR->irDsymbol[cd].irStruct->vtbl->setInitializer(gIR->irDsymbol[cd].irStruct->constVtbl);
+            cd->ir.irStruct->init->setInitializer(cd->ir.irStruct->constInit);
+            cd->ir.irStruct->vtbl->setInitializer(cd->ir.irStruct->constVtbl);
 
             // initialize interface vtables
-            IrStruct* irstruct = gIR->irDsymbol[cd].irStruct;
+            IrStruct* irstruct = cd->ir.irStruct;
             std::vector<llvm::Constant*> infoInits;
             for (IrStruct::InterfaceVectorIter i=irstruct->interfaceVec.begin(); i!=irstruct->interfaceVec.end(); ++i)
             {
@@ -755,7 +755,7 @@
     {
         llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass");
         std::vector<llvm::Value*> args;
-        args.push_back(gIR->irDsymbol[tc->sym].irStruct->classInfo);
+        args.push_back(tc->sym->ir.irStruct->classInfo);
         mem = gIR->ir->CreateCall(fn, args.begin(), args.end(), "newclass_gc_alloc");
         mem = DtoBitCast(mem, DtoType(tc), "newclass_gc");
     }
@@ -769,7 +769,7 @@
         Logger::println("Resolving outer class");
         LOG_SCOPE;
         DValue* thisval = newexp->thisexp->toElem(gIR);
-        size_t idx = 2 + gIR->irDsymbol[tc->sym->vthis].irField->index;
+        size_t idx = 2 + tc->sym->vthis->ir.irField->index;
         llvm::Value* src = thisval->getRVal();
         llvm::Value* dst = DtoGEPi(mem,0,idx,"tmp");
         Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
@@ -781,10 +781,10 @@
         Logger::println("Resolving nested context");
         LOG_SCOPE;
         size_t idx = 2;
-        //idx += gIR->irDsymbol[tc->sym].irStruct->interfaces.size();
-        llvm::Value* nest = gIR->irDsymbol[gIR->func()->decl].irFunc->nestedVar;
+        //idx += tc->sym->ir.irStruct->interfaces.size();
+        llvm::Value* nest = gIR->func()->decl->ir.irFunc->nestedVar;
         if (!nest)
-            nest = gIR->irDsymbol[gIR->func()->decl].irFunc->thisVar;
+            nest = gIR->func()->decl->ir.irFunc->thisVar;
         assert(nest);
         llvm::Value* gep = DtoGEPi(mem,0,idx,"tmp");
         nest = DtoBitCast(nest, gep->getType()->getContainedType(0));
@@ -807,11 +807,11 @@
 void DtoInitClass(TypeClass* tc, llvm::Value* dst)
 {
     size_t presz = 2*getABITypeSize(DtoSize_t());
-    uint64_t n = getABITypeSize(gIR->irType[tc].type->get()) - presz;
+    uint64_t n = getABITypeSize(tc->ir.type->get()) - presz;
 
     // set vtable field seperately, this might give better optimization
-    assert(gIR->irDsymbol[tc->sym].irStruct->vtbl);
-    DtoStore(gIR->irDsymbol[tc->sym].irStruct->vtbl, DtoGEPi(dst,0,0,"vtbl"));
+    assert(tc->sym->ir.irStruct->vtbl);
+    DtoStore(tc->sym->ir.irStruct->vtbl, DtoGEPi(dst,0,0,"vtbl"));
 
     // monitor always defaults to zero
     llvm::Value* tmp = DtoGEPi(dst,0,1,"monitor");
@@ -822,15 +822,15 @@
         return;
 
     // copy the rest from the static initializer
-    assert(gIR->irDsymbol[tc->sym].irStruct->init);
-    assert(dst->getType() == gIR->irDsymbol[tc->sym].irStruct->init->getType());
+    assert(tc->sym->ir.irStruct->init);
+    assert(dst->getType() == tc->sym->ir.irStruct->init->getType());
 
     const llvm::Type* arrty = getPtrToType(llvm::Type::Int8Ty);
 
     llvm::Value* dstarr = DtoGEPi(dst,0,2,"tmp");
     dstarr = DtoBitCast(dstarr, arrty);
 
-    llvm::Value* srcarr = DtoGEPi(gIR->irDsymbol[tc->sym].irStruct->init,0,2,"tmp");
+    llvm::Value* srcarr = DtoGEPi(tc->sym->ir.irStruct->init,0,2,"tmp");
     srcarr = DtoBitCast(srcarr, arrty);
 
     llvm::Function* fn = LLVM_DeclareMemCpy32();
@@ -853,7 +853,7 @@
 
     assert(ctor);
     DtoForceDeclareDsymbol(ctor);
-    llvm::Function* fn = gIR->irDsymbol[ctor].irFunc->func;
+    llvm::Function* fn = ctor->ir.irFunc->func;
     TypeFunction* tf = (TypeFunction*)DtoDType(ctor->type);
 
     std::vector<llvm::Value*> ctorargs;
@@ -883,8 +883,8 @@
     for (size_t i=0; i<arr->dim; i++)
     {
         FuncDeclaration* fd = (FuncDeclaration*)arr->data[i];
-        assert(gIR->irDsymbol[fd].irFunc->func);
-        new llvm::CallInst(gIR->irDsymbol[fd].irFunc->func, instance, "", gIR->scopebb());
+        assert(fd->ir.irFunc->func);
+        new llvm::CallInst(fd->ir.irFunc->func, instance, "", gIR->scopebb());
     }
 }
 
@@ -963,8 +963,8 @@
     // ClassInfo c
     TypeClass* to = (TypeClass*)DtoDType(_to);
     DtoForceDeclareDsymbol(to->sym);
-    assert(gIR->irDsymbol[to->sym].irStruct->classInfo);
-    tmp = gIR->irDsymbol[to->sym].irStruct->classInfo;
+    assert(to->sym->ir.irStruct->classInfo);
+    tmp = to->sym->ir.irStruct->classInfo;
     // unfortunately this is needed as the implementation of object differs somehow from the declaration
     // this could happen in user code as well :/
     tmp = DtoBitCast(tmp, funcTy->getParamType(1));
@@ -1029,8 +1029,8 @@
     // ClassInfo c
     TypeClass* to = (TypeClass*)DtoDType(_to);
     DtoForceDeclareDsymbol(to->sym);
-    assert(gIR->irDsymbol[to->sym].irStruct->classInfo);
-    tmp = gIR->irDsymbol[to->sym].irStruct->classInfo;
+    assert(to->sym->ir.irStruct->classInfo);
+    tmp = to->sym->ir.irStruct->classInfo;
     // unfortunately this is needed as the implementation of object differs somehow from the declaration
     // this could happen in user code as well :/
     tmp = DtoBitCast(tmp, funcTy->getParamType(1));
@@ -1095,14 +1095,14 @@
 
     const llvm::Type* st = DtoType(cd->type);
     if (ptr->getType() != st) {
-        //assert(gIR->irDsymbol[cd].irStruct->hasUnions);
+        //assert(cd->ir.irStruct->hasUnions);
         ptr = gIR->ir->CreateBitCast(ptr, st, "tmp");
     }
 
     const llvm::Type* llt = getPtrToType(DtoType(t));
     unsigned dataoffset = 2;
 
-    IrStruct* irstruct = gIR->irDsymbol[cd].irStruct;
+    IrStruct* irstruct = cd->ir.irStruct;
     for (IrStruct::OffsetMap::iterator i=irstruct->offsets.begin(); i!=irstruct->offsets.end(); ++i) {
     //for (unsigned i=0; i<cd->fields.dim; ++i) {
         //VarDeclaration* vd = (VarDeclaration*)cd->fields.data[i];
@@ -1110,30 +1110,30 @@
         assert(vd);
         Type* vdtype = DtoDType(vd->type);
         //Logger::println("found %u type %s", vd->offset, vdtype->toChars());
-        assert(gIR->irDsymbol[vd].irField->index >= 0);
+        assert(vd->ir.irField->index >= 0);
         if (os == vd->offset && vdtype == t) {
             Logger::println("found %s %s", vdtype->toChars(), vd->toChars());
-            idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset);
+            idxs.push_back(vd->ir.irField->index + dataoffset);
             //Logger::cout() << "indexing: " << *ptr << '\n';
             ptr = DtoGEP(ptr, idxs, "tmp");
             if (ptr->getType() != llt)
                 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
             //Logger::cout() << "indexing: " << *ptr << '\n';
-            if (gIR->irDsymbol[vd].irField->indexOffset)
-                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
+            if (vd->ir.irField->indexOffset)
+                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb());
             //Logger::cout() << "indexing: " << *ptr << '\n';
             return ptr;
         }
         else if (vdtype->ty == Tstruct && (vd->offset + vdtype->size()) > os) {
             TypeStruct* ts = (TypeStruct*)vdtype;
             StructDeclaration* ssd = ts->sym;
-            idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset);
-            if (gIR->irDsymbol[vd].irField->indexOffset) {
+            idxs.push_back(vd->ir.irField->index + dataoffset);
+            if (vd->ir.irField->indexOffset) {
                 Logger::println("has union field offset");
                 ptr = DtoGEP(ptr, idxs, "tmp");
                 if (ptr->getType() != llt)
                     ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
-                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
+                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb());
                 std::vector<unsigned> tmp;
                 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, tmp);
             }
@@ -1186,8 +1186,8 @@
 
 void DtoDeclareClassInfo(ClassDeclaration* cd)
 {
-    if (gIR->irDsymbol[cd].irStruct->classDeclared) return;
-    gIR->irDsymbol[cd].irStruct->classDeclared = true;
+    if (cd->ir.irStruct->classDeclared) return;
+    cd->ir.irStruct->classDeclared = true;
 
     Logger::println("DtoDeclareClassInfo(%s)", cd->toChars());
     LOG_SCOPE;
@@ -1202,9 +1202,9 @@
     else
         gname.append("11__InterfaceZ");
 
-    const llvm::Type* st = gIR->irType[cinfo->type].type->get();
+    const llvm::Type* st = cinfo->type->ir.type->get();
 
-    gIR->irDsymbol[cd].irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module);
+    cd->ir.irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module);
 }
 
 static llvm::Constant* build_offti_entry(VarDeclaration* vd)
@@ -1225,9 +1225,9 @@
     vd->type->getTypeInfo(NULL);
     assert(vd->type->vtinfo);
     DtoForceDeclareDsymbol(vd->type->vtinfo);
-    llvm::Constant* c = isaConstant(gIR->irDsymbol[vd->type->vtinfo].getIrValue());
+    llvm::Constant* c = isaConstant(vd->type->vtinfo->ir.getIrValue());
 
-    const llvm::Type* tiTy = getPtrToType(gIR->irType[Type::typeinfo->type].type->get());
+    const llvm::Type* tiTy = getPtrToType(Type::typeinfo->type->ir.type->get());
     //Logger::cout() << "tiTy = " << *tiTy << '\n';
 
     types.push_back(tiTy);
@@ -1268,7 +1268,7 @@
         // OffsetTypeInfo type
         std::vector<const llvm::Type*> elemtypes;
         elemtypes.push_back(DtoSize_t());
-        const llvm::Type* tiTy = getPtrToType(gIR->irType[Type::typeinfo->type].type->get());
+        const llvm::Type* tiTy = getPtrToType(Type::typeinfo->type->ir.type->get());
         elemtypes.push_back(tiTy);
         const llvm::StructType* sTy = llvm::StructType::get(elemtypes);
 
@@ -1293,7 +1293,7 @@
 {
     // construct the function
     std::vector<const llvm::Type*> paramTypes;
-    paramTypes.push_back(getPtrToType(gIR->irType[cd->type].type->get()));
+    paramTypes.push_back(getPtrToType(cd->type->ir.type->get()));
 
     const llvm::FunctionType* fnTy = llvm::FunctionType::get(llvm::Type::VoidTy, paramTypes, false);
 
@@ -1303,8 +1303,8 @@
     else if (cd->dtors.dim == 1) {
         DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[0];
         DtoForceDeclareDsymbol(d);
-        assert(gIR->irDsymbol[d].irFunc->func);
-        return llvm::ConstantExpr::getBitCast(isaConstant(gIR->irDsymbol[d].irFunc->func), getPtrToType(llvm::Type::Int8Ty));
+        assert(d->ir.irFunc->func);
+        return llvm::ConstantExpr::getBitCast(isaConstant(d->ir.irFunc->func), getPtrToType(llvm::Type::Int8Ty));
     }
 
     std::string gname("_D");
@@ -1322,8 +1322,8 @@
     {
         DtorDeclaration *d = (DtorDeclaration *)cd->dtors.data[i];
         DtoForceDeclareDsymbol(d);
-        assert(gIR->irDsymbol[d].irFunc->func);
-        builder.CreateCall(gIR->irDsymbol[d].irFunc->func, thisptr);
+        assert(d->ir.irFunc->func);
+        builder.CreateCall(d->ir.irFunc->func, thisptr);
     }
     builder.CreateRetVoid();
 
@@ -1378,21 +1378,21 @@
 //         void *defaultConstructor;
 //        }
 
-    if (gIR->irDsymbol[cd].irStruct->classDefined) return;
-    gIR->irDsymbol[cd].irStruct->classDefined = true;
+    if (cd->ir.irStruct->classDefined) return;
+    cd->ir.irStruct->classDefined = true;
 
     Logger::println("DtoDefineClassInfo(%s)", cd->toChars());
     LOG_SCOPE;
 
     assert(cd->type->ty == Tclass);
-    assert(gIR->irDsymbol[cd].irStruct->classInfo);
+    assert(cd->ir.irStruct->classInfo);
 
     TypeClass* cdty = (TypeClass*)cd->type;
     if (!cd->isInterfaceDeclaration() && !cd->isAbstract()) {
-        assert(gIR->irDsymbol[cd].irStruct->init);
-        assert(gIR->irDsymbol[cd].irStruct->constInit);
-        assert(gIR->irDsymbol[cd].irStruct->vtbl);
-        assert(gIR->irDsymbol[cd].irStruct->constVtbl);
+        assert(cd->ir.irStruct->init);
+        assert(cd->ir.irStruct->constInit);
+        assert(cd->ir.irStruct->vtbl);
+        assert(cd->ir.irStruct->constVtbl);
     }
 
     // holds the list of initializers for llvm
@@ -1400,28 +1400,28 @@
 
     ClassDeclaration* cinfo = ClassDeclaration::classinfo;
     DtoForceConstInitDsymbol(cinfo);
-    assert(gIR->irDsymbol[cinfo].irStruct->constInit);
+    assert(cinfo->ir.irStruct->constInit);
 
     llvm::Constant* c;
 
     // own vtable
-    c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(0);
+    c = cinfo->ir.irStruct->constInit->getOperand(0);
     assert(c);
     inits.push_back(c);
 
     // monitor
-    c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(1);
+    c = cinfo->ir.irStruct->constInit->getOperand(1);
     inits.push_back(c);
 
     // byte[] init
     const llvm::Type* byteptrty = getPtrToType(llvm::Type::Int8Ty);
     if (cd->isInterfaceDeclaration() || cd->isAbstract()) {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(2);
+        c = cinfo->ir.irStruct->constInit->getOperand(2);
     }
     else {
-        c = llvm::ConstantExpr::getBitCast(gIR->irDsymbol[cd].irStruct->init, byteptrty);
-        assert(!gIR->irDsymbol[cd].irStruct->constInit->getType()->isAbstract());
-        size_t initsz = getABITypeSize(gIR->irDsymbol[cd].irStruct->constInit->getType());
+        c = llvm::ConstantExpr::getBitCast(cd->ir.irStruct->init, byteptrty);
+        assert(!cd->ir.irStruct->constInit->getType()->isAbstract());
+        size_t initsz = getABITypeSize(cd->ir.irStruct->constInit->getType());
         c = DtoConstSlice(DtoConstSize_t(initsz), c);
     }
     inits.push_back(c);
@@ -1440,25 +1440,25 @@
 
     // vtbl array
     if (cd->isInterfaceDeclaration() || cd->isAbstract()) {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(4);
+        c = cinfo->ir.irStruct->constInit->getOperand(4);
     }
     else {
         const llvm::Type* byteptrptrty = getPtrToType(byteptrty);
-        assert(!gIR->irDsymbol[cd].irStruct->vtbl->getType()->isAbstract());
-        c = llvm::ConstantExpr::getBitCast(gIR->irDsymbol[cd].irStruct->vtbl, byteptrptrty);
-        assert(!gIR->irDsymbol[cd].irStruct->constVtbl->getType()->isAbstract());
-        size_t vtblsz = gIR->irDsymbol[cd].irStruct->constVtbl->getType()->getNumElements();
+        assert(!cd->ir.irStruct->vtbl->getType()->isAbstract());
+        c = llvm::ConstantExpr::getBitCast(cd->ir.irStruct->vtbl, byteptrptrty);
+        assert(!cd->ir.irStruct->constVtbl->getType()->isAbstract());
+        size_t vtblsz = cd->ir.irStruct->constVtbl->getType()->getNumElements();
         c = DtoConstSlice(DtoConstSize_t(vtblsz), c);
     }
     inits.push_back(c);
 
     // interfaces array
-    IrStruct* irstruct = gIR->irDsymbol[cd].irStruct;
+    IrStruct* irstruct = cd->ir.irStruct;
     if (cd->isInterfaceDeclaration() || !irstruct->interfaceInfos || cd->isAbstract()) {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(5);
+        c = cinfo->ir.irStruct->constInit->getOperand(5);
     }
     else {
-        const llvm::Type* t = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(5)->getType()->getContainedType(1);
+        const llvm::Type* t = cinfo->ir.irStruct->constInit->getOperand(5)->getType()->getContainedType(1);
         c = llvm::ConstantExpr::getBitCast(irstruct->interfaceInfos, t);
         size_t iisz = irstruct->interfaceInfosTy->getNumElements();
         c = DtoConstSlice(DtoConstSize_t(iisz), c);
@@ -1468,19 +1468,19 @@
     // base classinfo
     if (cd->baseClass && !cd->isInterfaceDeclaration() && !cd->isAbstract()) {
         DtoDeclareClassInfo(cd->baseClass);
-        c = gIR->irDsymbol[cd->baseClass].irStruct->classInfo;
+        c = cd->baseClass->ir.irStruct->classInfo;
         assert(c);
         inits.push_back(c);
     }
     else {
         // null
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(6);
+        c = cinfo->ir.irStruct->constInit->getOperand(6);
         inits.push_back(c);
     }
 
     // destructor
     if (cd->isInterfaceDeclaration() || cd->isAbstract()) {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(7);
+        c = cinfo->ir.irStruct->constInit->getOperand(7);
     }
     else {
         c = build_class_dtor(cd);
@@ -1489,12 +1489,12 @@
 
     // invariant
     // TODO
-    c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(8);
+    c = cinfo->ir.irStruct->constInit->getOperand(8);
     inits.push_back(c);
 
     // uint flags
     if (cd->isInterfaceDeclaration() || cd->isAbstract()) {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(9);
+        c = cinfo->ir.irStruct->constInit->getOperand(9);
     }
     else {
         uint flags = build_classinfo_flags(cd);
@@ -1504,27 +1504,27 @@
 
     // allocator
     // TODO
-    c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(10);
+    c = cinfo->ir.irStruct->constInit->getOperand(10);
     inits.push_back(c);
 
     // offset typeinfo
     if (cd->isInterfaceDeclaration() || cd->isAbstract()) {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(11);
+        c = cinfo->ir.irStruct->constInit->getOperand(11);
     }
     else {
-        c = build_offti_array(cd, gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(11));
+        c = build_offti_array(cd, cinfo->ir.irStruct->constInit->getOperand(11));
     }
     inits.push_back(c);
 
     // default constructor
     if (cd->defaultCtor && !cd->isInterfaceDeclaration() && !cd->isAbstract()) {
         DtoForceDeclareDsymbol(cd->defaultCtor);
-        c = isaConstant(gIR->irDsymbol[cd->defaultCtor].irFunc->func);
-        const llvm::Type* toTy = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(12)->getType();
+        c = isaConstant(cd->defaultCtor->ir.irFunc->func);
+        const llvm::Type* toTy = cinfo->ir.irStruct->constInit->getOperand(12)->getType();
         c = llvm::ConstantExpr::getBitCast(c, toTy);
     }
     else {
-        c = gIR->irDsymbol[cinfo].irStruct->constInit->getOperand(12);
+        c = cinfo->ir.irStruct->constInit->getOperand(12);
     }
     inits.push_back(c);
 
@@ -1535,10 +1535,10 @@
     }*/
 
     // build the initializer
-    const llvm::StructType* st = isaStruct(gIR->irDsymbol[cinfo].irStruct->constInit->getType());
+    const llvm::StructType* st = isaStruct(cinfo->ir.irStruct->constInit->getType());
     llvm::Constant* finalinit = llvm::ConstantStruct::get(st, inits);
     //Logger::cout() << "built the classinfo initializer:\n" << *finalinit <<'\n';
 
-    gIR->irDsymbol[cd].irStruct->constClassInfo = finalinit;
-    gIR->irDsymbol[cd].irStruct->classInfo->setInitializer(finalinit);
+    cd->ir.irStruct->constClassInfo = finalinit;
+    cd->ir.irStruct->classInfo->setInitializer(finalinit);
 }
--- a/gen/functions.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/functions.cpp	Tue May 06 07:56:03 2008 +0200
@@ -23,8 +23,8 @@
     TypeFunction* f = (TypeFunction*)type;
     assert(f != 0);
 
-    if (gIR->irType[type].type != NULL) {
-        return llvm::cast<llvm::FunctionType>(gIR->irType[type].type->get());
+    if (type->ir.type != NULL) {
+        return llvm::cast<llvm::FunctionType>(type->ir.type->get());
     }
 
     bool typesafeVararg = false;
@@ -79,10 +79,10 @@
         ClassDeclaration* ti = Type::typeinfo;
         ti->toObjFile();
         DtoForceConstInitDsymbol(ti);
-        assert(gIR->irDsymbol[ti].irStruct->constInit);
+        assert(ti->ir.irStruct->constInit);
         std::vector<const llvm::Type*> types;
         types.push_back(DtoSize_t());
-        types.push_back(getPtrToType(getPtrToType(gIR->irDsymbol[ti].irStruct->constInit->getType())));
+        types.push_back(getPtrToType(getPtrToType(ti->ir.irStruct->constInit->getType())));
         const llvm::Type* t1 = llvm::StructType::get(types);
         paramvec.push_back(getPtrToType(t1));
         paramvec.push_back(getPtrToType(llvm::Type::Int8Ty));
@@ -135,10 +135,10 @@
     f->llvmRetInPtr = retinptr;
     f->llvmUsesThis = usesthis;
 
-    //if (!gIR->irType[f].type)
-        gIR->irType[f].type = new llvm::PATypeHolder(functype);
+    //if (!f->ir.type)
+        f->ir.type = new llvm::PATypeHolder(functype);
     //else
-        //assert(functype == gIR->irType[f].type->get());
+        //assert(functype == f->ir.type->get());
 
     return functype;
 }
@@ -148,8 +148,8 @@
 static const llvm::FunctionType* DtoVaFunctionType(FuncDeclaration* fdecl)
 {
     // type has already been resolved
-    if (gIR->irType[fdecl->type].type != 0) {
-        return llvm::cast<llvm::FunctionType>(gIR->irType[fdecl->type].type->get());
+    if (fdecl->type->ir.type != 0) {
+        return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
     }
 
     TypeFunction* f = (TypeFunction*)fdecl->type;
@@ -172,7 +172,7 @@
 
     const llvm::FunctionType* fty = llvm::FunctionType::get(llvm::Type::VoidTy, args, false);
 
-    gIR->irType[f].type = new llvm::PATypeHolder(fty);
+    f->ir.type = new llvm::PATypeHolder(fty);
 
     return fty;
 }
@@ -192,8 +192,8 @@
     }*/
 
     // type has already been resolved
-    if (gIR->irType[fdecl->type].type != 0) {
-        return llvm::cast<llvm::FunctionType>(gIR->irType[fdecl->type].type->get());
+    if (fdecl->type->ir.type != 0) {
+        return llvm::cast<llvm::FunctionType>(fdecl->type->ir.type->get());
     }
 
     const llvm::Type* thisty = NULL;
@@ -241,7 +241,7 @@
     llvm::Function* func = llvm::dyn_cast<llvm::Function>(fn);
     assert(func);
     assert(func->isIntrinsic());
-    gIR->irDsymbol[fdecl].irFunc->func = func;
+    fdecl->ir.irFunc->func = func;
     return func;
 }
 
@@ -260,8 +260,8 @@
             return;
     }
 
-    if (gIR->irDsymbol[fdecl].resolved) return;
-    gIR->irDsymbol[fdecl].resolved = true;
+    if (fdecl->ir.resolved) return;
+    fdecl->ir.resolved = true;
 
     Logger::println("DtoResolveFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars());
     LOG_SCOPE;
@@ -281,9 +281,9 @@
         {
             Logger::println("magic va_arg found");
             fdecl->llvmInternal = LLVMva_arg;
-            gIR->irDsymbol[fdecl].declared = true;
-            gIR->irDsymbol[fdecl].initialized = true;
-            gIR->irDsymbol[fdecl].defined = true;
+            fdecl->ir.declared = true;
+            fdecl->ir.initialized = true;
+            fdecl->ir.defined = true;
             return; // this gets mapped to an instruction so a declaration makes no sence
         }
         else if (tempdecl->llvmInternal == LLVMva_start)
@@ -304,8 +304,8 @@
 
 void DtoDeclareFunction(FuncDeclaration* fdecl)
 {
-    if (gIR->irDsymbol[fdecl].declared) return;
-    gIR->irDsymbol[fdecl].declared = true;
+    if (fdecl->ir.declared) return;
+    fdecl->ir.declared = true;
 
     Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars());
     LOG_SCOPE;
@@ -320,9 +320,9 @@
 
     if (fdecl->runTimeHack) {
         Logger::println("runtime hack func chars: %s", fdecl->toChars());
-        if (!gIR->irDsymbol[fdecl].irFunc) {
-            gIR->irDsymbol[fdecl].irFunc = new IrFunction(fdecl);
-            gIR->irDsymbol[fdecl].irFunc->func = LLVM_D_GetRuntimeFunction(gIR->module, fdecl->toChars());
+        if (!fdecl->ir.irFunc) {
+            fdecl->ir.irFunc = new IrFunction(fdecl);
+            fdecl->ir.irFunc->func = LLVM_D_GetRuntimeFunction(gIR->module, fdecl->toChars());
         }
         return;
     }
@@ -339,8 +339,8 @@
     else if (fdecl->llvmInternal == LLVMva_start)
         declareOnly = true;
 
-    if (!gIR->irDsymbol[fdecl].irFunc) {
-        gIR->irDsymbol[fdecl].irFunc = new IrFunction(fdecl);
+    if (!fdecl->ir.irFunc) {
+        fdecl->ir.irFunc = new IrFunction(fdecl);
     }
 
     // mangled name
@@ -367,7 +367,7 @@
         assert(func->getFunctionType() == functype);
 
     // add func to IRFunc
-    gIR->irDsymbol[fdecl].irFunc->func = func;
+    fdecl->ir.irFunc->func = func;
 
     // calling convention
     if (!vafunc && fdecl->llvmInternal != LLVMintrinsic)
@@ -375,8 +375,8 @@
     else // fall back to C, it should be the right thing to do
         func->setCallingConv(llvm::CallingConv::C);
 
-    gIR->irDsymbol[fdecl].irFunc->func = func;
-    assert(llvm::isa<llvm::FunctionType>(gIR->irType[f].type->get()));
+    fdecl->ir.irFunc->func = func;
+    assert(llvm::isa<llvm::FunctionType>(f->ir.type->get()));
 
     // main
     if (fdecl->isMain()) {
@@ -400,22 +400,22 @@
         int k = 0;
         if (f->llvmRetInPtr) {
             iarg->setName("retval");
-            gIR->irDsymbol[fdecl].irFunc->retArg = iarg;
+            fdecl->ir.irFunc->retArg = iarg;
             ++iarg;
         }
         if (f->llvmUsesThis) {
             iarg->setName("this");
-            gIR->irDsymbol[fdecl].irFunc->thisVar = iarg;
-            assert(gIR->irDsymbol[fdecl].irFunc->thisVar);
+            fdecl->ir.irFunc->thisVar = iarg;
+            assert(fdecl->ir.irFunc->thisVar);
             ++iarg;
         }
 
         if (f->linkage == LINKd && f->varargs == 1) {
             iarg->setName("_arguments");
-            gIR->irDsymbol[fdecl].irFunc->_arguments = iarg;
+            fdecl->ir.irFunc->_arguments = iarg;
             ++iarg;
             iarg->setName("_argptr");
-            gIR->irDsymbol[fdecl].irFunc->_argptr = iarg;
+            fdecl->ir.irFunc->_argptr = iarg;
             ++iarg;
         }
 
@@ -426,9 +426,9 @@
                 Dsymbol* argsym = (Dsymbol*)fdecl->parameters->data[k++];
                 VarDeclaration* argvd = argsym->isVarDeclaration();
                 assert(argvd);
-                assert(!gIR->irDsymbol[argvd].irLocal);
-                gIR->irDsymbol[argvd].irLocal = new IrLocal(argvd);
-                gIR->irDsymbol[argvd].irLocal->value = iarg;
+                assert(!argvd->ir.irLocal);
+                argvd->ir.irLocal = new IrLocal(argvd);
+                argvd->ir.irLocal->value = iarg;
                 iarg->setName(argvd->ident->toChars());
             }
             else
@@ -453,10 +453,10 @@
 
 void DtoDefineFunc(FuncDeclaration* fd)
 {
-    if (gIR->irDsymbol[fd].defined) return;
-    gIR->irDsymbol[fd].defined = true;
+    if (fd->ir.defined) return;
+    fd->ir.defined = true;
 
-    assert(gIR->irDsymbol[fd].declared);
+    assert(fd->ir.declared);
 
     Logger::println("DtoDefineFunc(%s): %s", fd->toPrettyChars(), fd->loc.toChars());
     LOG_SCOPE;
@@ -464,27 +464,27 @@
     // debug info
     if (global.params.symdebug) {
         Module* mo = fd->getModule();
-        gIR->irDsymbol[fd].irFunc->dwarfSubProg = DtoDwarfSubProgram(fd, DtoDwarfCompileUnit(mo));
+        fd->ir.irFunc->dwarfSubProg = DtoDwarfSubProgram(fd, DtoDwarfCompileUnit(mo));
     }
 
     Type* t = DtoDType(fd->type);
     TypeFunction* f = (TypeFunction*)t;
-    assert(gIR->irType[f].type);
+    assert(f->ir.type);
 
-    llvm::Function* func = gIR->irDsymbol[fd].irFunc->func;
+    llvm::Function* func = fd->ir.irFunc->func;
     const llvm::FunctionType* functype = func->getFunctionType();
 
     // only members of the current module or template instances maybe be defined
     if (fd->getModule() == gIR->dmodule || DtoIsTemplateInstance(fd->parent))
     {
-        gIR->irDsymbol[fd].DModule = gIR->dmodule;
+        fd->ir.DModule = gIR->dmodule;
 
         // function definition
         if (fd->fbody != 0)
         {
             Logger::println("Doing function body for: %s", fd->toChars());
-            assert(gIR->irDsymbol[fd].irFunc);
-            gIR->functions.push_back(gIR->irDsymbol[fd].irFunc);
+            assert(fd->ir.irFunc);
+            gIR->functions.push_back(fd->ir.irFunc);
 
             if (fd->isMain())
                 gIR->emitMain = true;
@@ -502,8 +502,8 @@
                 // need result variable? (not nested)
                 if (fd->vresult && !fd->vresult->nestedref) {
                     Logger::println("non-nested vresult value");
-                    gIR->irDsymbol[fd->vresult].irLocal = new IrLocal(fd->vresult);
-                    gIR->irDsymbol[fd->vresult].irLocal->value = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",allocaPoint);
+                    fd->vresult->ir.irLocal = new IrLocal(fd->vresult);
+                    fd->vresult->ir.irLocal->value = new llvm::AllocaInst(DtoType(fd->vresult->type),"function_vresult",allocaPoint);
                 }
 
                 // give arguments storage
@@ -519,7 +519,7 @@
                         if (!vd->needsStorage || vd->nestedref || vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type))
                             continue;
 
-                        llvm::Value* a = gIR->irDsymbol[vd].irLocal->value;
+                        llvm::Value* a = vd->ir.irLocal->value;
                         assert(a);
                         std::string s(a->getName());
                         Logger::println("giving argument '%s' storage", s.c_str());
@@ -527,7 +527,7 @@
 
                         llvm::Value* v = new llvm::AllocaInst(a->getType(),s,allocaPoint);
                         gIR->ir->CreateStore(a,v);
-                        gIR->irDsymbol[vd].irLocal->value = v;
+                        vd->ir.irLocal->value = v;
                     }
                 }
 
@@ -537,7 +537,7 @@
                 llvm::Value* parentNested = NULL;
                 if (FuncDeclaration* fd2 = fd->toParent2()->isFuncDeclaration()) {
                     if (!fd->isStatic()) // huh?
-                        parentNested = gIR->irDsymbol[fd2].irFunc->nestedVar;
+                        parentNested = fd2->ir.irFunc->nestedVar;
                 }
 
                 // need result variable? (nested)
@@ -557,16 +557,16 @@
                     for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) {
                         VarDeclaration* vd = *i;
                         Logger::println("referenced nested variable %s", vd->toChars());
-                        if (!gIR->irDsymbol[vd].irLocal)
-                            gIR->irDsymbol[vd].irLocal = new IrLocal(vd);
-                        gIR->irDsymbol[vd].irLocal->nestedIndex = j++;
+                        if (!vd->ir.irLocal)
+                            vd->ir.irLocal = new IrLocal(vd);
+                        vd->ir.irLocal->nestedIndex = j++;
                         if (vd->isParameter()) {
-                            if (!gIR->irDsymbol[vd].irLocal->value) {
+                            if (!vd->ir.irLocal->value) {
                                 assert(vd == fd->vthis);
-                                gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[fd].irFunc->thisVar;
+                                vd->ir.irLocal->value = fd->ir.irFunc->thisVar;
                             }
-                            assert(gIR->irDsymbol[vd].irLocal->value);
-                            nestTypes.push_back(gIR->irDsymbol[vd].irLocal->value->getType());
+                            assert(vd->ir.irLocal->value);
+                            nestTypes.push_back(vd->ir.irLocal->value->getType());
                         }
                         else {
                             nestTypes.push_back(DtoType(vd->type));
@@ -574,18 +574,18 @@
                     }
                     const llvm::StructType* nestSType = llvm::StructType::get(nestTypes);
                     Logger::cout() << "nested var struct has type:" << *nestSType << '\n';
-                    gIR->irDsymbol[fd].irFunc->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint);
+                    fd->ir.irFunc->nestedVar = new llvm::AllocaInst(nestSType,"nestedvars",allocaPoint);
                     if (parentNested) {
-                        assert(gIR->irDsymbol[fd].irFunc->thisVar);
-                        llvm::Value* ptr = gIR->ir->CreateBitCast(gIR->irDsymbol[fd].irFunc->thisVar, parentNested->getType(), "tmp");
-                        gIR->ir->CreateStore(ptr, DtoGEPi(gIR->irDsymbol[fd].irFunc->nestedVar, 0,0, "tmp"));
+                        assert(fd->ir.irFunc->thisVar);
+                        llvm::Value* ptr = gIR->ir->CreateBitCast(fd->ir.irFunc->thisVar, parentNested->getType(), "tmp");
+                        gIR->ir->CreateStore(ptr, DtoGEPi(fd->ir.irFunc->nestedVar, 0,0, "tmp"));
                     }
                     for (std::set<VarDeclaration*>::iterator i=fd->nestedVars.begin(); i!=fd->nestedVars.end(); ++i) {
                         VarDeclaration* vd = *i;
                         if (vd->isParameter()) {
-                            assert(gIR->irDsymbol[vd].irLocal);
-                            gIR->ir->CreateStore(gIR->irDsymbol[vd].irLocal->value, DtoGEPi(gIR->irDsymbol[fd].irFunc->nestedVar, 0, gIR->irDsymbol[vd].irLocal->nestedIndex, "tmp"));
-                            gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[fd].irFunc->nestedVar;
+                            assert(vd->ir.irLocal);
+                            gIR->ir->CreateStore(vd->ir.irLocal->value, DtoGEPi(fd->ir.irFunc->nestedVar, 0, vd->ir.irLocal->nestedIndex, "tmp"));
+                            vd->ir.irLocal->value = fd->ir.irFunc->nestedVar;
                         }
                     }
                 }
@@ -593,9 +593,9 @@
                 // copy _argptr to a memory location
                 if (f->linkage == LINKd && f->varargs == 1)
                 {
-                    llvm::Value* argptrmem = new llvm::AllocaInst(gIR->irDsymbol[fd].irFunc->_argptr->getType(), "_argptrmem", gIR->topallocapoint());
-                    new llvm::StoreInst(gIR->irDsymbol[fd].irFunc->_argptr, argptrmem, gIR->scopebb());
-                    gIR->irDsymbol[fd].irFunc->_argptr = argptrmem;
+                    llvm::Value* argptrmem = new llvm::AllocaInst(fd->ir.irFunc->_argptr->getType(), "_argptrmem", gIR->topallocapoint());
+                    new llvm::StoreInst(fd->ir.irFunc->_argptr, argptrmem, gIR->scopebb());
+                    fd->ir.irFunc->_argptr = argptrmem;
                 }
 
                 // output function body
--- a/gen/irstate.h	Tue May 06 07:26:27 2008 +0200
+++ b/gen/irstate.h	Tue May 06 07:56:03 2008 +0200
@@ -3,7 +3,6 @@
 
 #include <vector>
 #include <list>
-#include <map>
 
 #include "root.h"
 #include "aggregate.h"
@@ -11,8 +10,6 @@
 #include "ir/irfunction.h"
 #include "ir/irstruct.h"
 #include "ir/irvar.h"
-#include "ir/irsymbol.h"
-#include "ir/irtype.h"
 
 // global ir state for current module
 struct IRState;
@@ -80,12 +77,6 @@
     // interface info type, used in DtoInterfaceInfoType
     llvm::StructType* interfaceInfoType;
 
-    // ir data associated with DMD Dsymbol nodes 
-    std::map<Dsymbol*, IrDsymbol> irDsymbol;
-
-    // ir data associated with DMD Type instances
-    std::map<Type*, IrType> irType;
-
     // functions
     typedef std::vector<IrFunction*> FunctionVector;
     FunctionVector functions;
--- a/gen/runtime.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/runtime.cpp	Tue May 06 07:56:03 2008 +0200
@@ -189,9 +189,9 @@
     const llvm::Type* stringTy = rt_array(byteTy);
     const llvm::Type* wstringTy = rt_array(shortTy);
     const llvm::Type* dstringTy = rt_array(intTy);
-    const llvm::Type* objectTy = rt_ptr(gIR->irType[ClassDeclaration::object->type].type->get());
-    const llvm::Type* classInfoTy = rt_ptr(gIR->irType[ClassDeclaration::classinfo->type].type->get());
-    const llvm::Type* typeInfoTy = rt_ptr(gIR->irType[Type::typeinfo->type].type->get());
+    const llvm::Type* objectTy = rt_ptr(ClassDeclaration::object->type->ir.type->get());
+    const llvm::Type* classInfoTy = rt_ptr(ClassDeclaration::classinfo->type->ir.type->get());
+    const llvm::Type* typeInfoTy = rt_ptr(Type::typeinfo->type->ir.type->get());
     const llvm::Type* aaTy = rt_ptr(llvm::OpaqueType::get());
 
     /////////////////////////////////////////////////////////////////////////////////////
--- a/gen/statements.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/statements.cpp	Tue May 06 07:56:03 2008 +0200
@@ -77,11 +77,11 @@
         if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
             IrFunction* f = p->func();
             assert(f->type->llvmRetInPtr);
-            assert(gIR->irDsymbol[f->decl].irFunc->retArg);
+            assert(f->decl->ir.irFunc->retArg);
 
             if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
 
-            DValue* rvar = new DVarValue(f->type->next, gIR->irDsymbol[f->decl].irFunc->retArg, true);
+            DValue* rvar = new DVarValue(f->type->next, f->decl->ir.irFunc->retArg, true);
 
             p->exps.push_back(IRExp(NULL,exp,rvar));
             DValue* e = exp->toElem(p);
@@ -156,8 +156,8 @@
     if (match)
     {
         llvm::Value* allocainst = new llvm::AllocaInst(DtoType(match->type), "._tmp_if_var", p->topallocapoint());
-        gIR->irDsymbol[match].irLocal = new IrLocal(match);
-        gIR->irDsymbol[match].irLocal->value = allocainst;
+        match->ir.irLocal = new IrLocal(match);
+        match->ir.irLocal->value = allocainst;
     }
 
     DValue* cond_e = condition->toElem(p);
@@ -808,9 +808,9 @@
     if (key)
     {
         //key->llvmValue = keyvar;
-        assert(!gIR->irDsymbol[key].irLocal);
-        gIR->irDsymbol[key].irLocal = new IrLocal(key);
-        gIR->irDsymbol[key].irLocal->value = keyvar;
+        assert(!key->ir.irLocal);
+        key->ir.irLocal = new IrLocal(key);
+        key->ir.irLocal->value = keyvar;
     }
     llvm::Value* zerokey = llvm::ConstantInt::get(keytype,0,false);
 
@@ -819,8 +819,8 @@
     llvm::Value* valvar = NULL;
     if (!value->isRef() && !value->isOut())
         valvar = new llvm::AllocaInst(valtype, "foreachval", p->topallocapoint());
-    assert(!gIR->irDsymbol[value].irLocal);
-    gIR->irDsymbol[value].irLocal = new IrLocal(value);
+    assert(!value->ir.irLocal);
+    value->ir.irLocal = new IrLocal(value);
 
     // what to iterate
     DValue* aggrval = aggr->toElem(p);
@@ -916,15 +916,15 @@
     llvm::Constant* zero = llvm::ConstantInt::get(keytype,0,false);
     llvm::Value* loadedKey = p->ir->CreateLoad(keyvar,"tmp");
     if (aggrtype->ty == Tsarray)
-        gIR->irDsymbol[value].irLocal->value = DtoGEP(val,zero,loadedKey,"tmp");
+        value->ir.irLocal->value = DtoGEP(val,zero,loadedKey,"tmp");
     else if (aggrtype->ty == Tarray)
-        gIR->irDsymbol[value].irLocal->value = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb());
+        value->ir.irLocal->value = new llvm::GetElementPtrInst(val,loadedKey,"tmp",p->scopebb());
 
     if (!value->isRef() && !value->isOut()) {
         DValue* dst = new DVarValue(value->type, valvar, true);
-        DValue* src = new DVarValue(value->type, gIR->irDsymbol[value].irLocal->value, true);
+        DValue* src = new DVarValue(value->type, value->ir.irLocal->value, true);
         DtoAssign(dst, src);
-        gIR->irDsymbol[value].irLocal->value = valvar;
+        value->ir.irLocal->value = valvar;
     }
 
     // emit body
@@ -1053,7 +1053,7 @@
     assert(body);
 
     DValue* e = exp->toElem(p);
-    gIR->irDsymbol[wthis].irLocal->value = e->getRVal();
+    wthis->ir.irLocal->value = e->getRVal();
     delete e;
 
     body->toIR(p);
--- a/gen/structs.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/structs.cpp	Tue May 06 07:56:03 2008 +0200
@@ -82,7 +82,7 @@
 
     TypeStruct* ts = (TypeStruct*)si->ad->type;
 
-    const llvm::StructType* structtype = isaStruct(gIR->irType[ts].type->get());
+    const llvm::StructType* structtype = isaStruct(ts->ir.type->get());
     Logger::cout() << "llvm struct type: " << *structtype << '\n';
 
     assert(si->value.dim == si->vars.dim);
@@ -95,11 +95,11 @@
         VarDeclaration* vd = (VarDeclaration*)si->vars.data[i];
         assert(vd);
         llvm::Constant* v = DtoConstInitializer(vd->type, ini);
-        inits.push_back(DUnionIdx(gIR->irDsymbol[vd].irField->index, gIR->irDsymbol[vd].irField->indexOffset, v));
+        inits.push_back(DUnionIdx(vd->ir.irField->index, vd->ir.irField->indexOffset, v));
     }
 
     DtoConstInitStruct((StructDeclaration*)si->ad);
-    return gIR->irDsymbol[si->ad].irStruct->dunion->getConst(inits);
+    return si->ad->ir.irStruct->dunion->getConst(inits);
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
@@ -115,7 +115,7 @@
     const llvm::Type* llt = getPtrToType(DtoType(t));
     const llvm::Type* st = getPtrToType(DtoType(sd->type));
     if (ptr->getType() != st) {
-        assert(gIR->irDsymbol[sd].irStruct->hasUnions);
+        assert(sd->ir.irStruct->hasUnions);
         ptr = gIR->ir->CreateBitCast(ptr, st, "tmp");
     }
 
@@ -123,26 +123,26 @@
         VarDeclaration* vd = (VarDeclaration*)sd->fields.data[i];
         Type* vdtype = DtoDType(vd->type);
         //Logger::println("found %u type %s", vd->offset, vdtype->toChars());
-        assert(gIR->irDsymbol[vd].irField->index >= 0);
+        assert(vd->ir.irField->index >= 0);
         if (os == vd->offset && vdtype == t) {
-            idxs.push_back(gIR->irDsymbol[vd].irField->index);
+            idxs.push_back(vd->ir.irField->index);
             ptr = DtoGEP(ptr, idxs, "tmp");
             if (ptr->getType() != llt)
                 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
-            if (gIR->irDsymbol[vd].irField->indexOffset)
-                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
+            if (vd->ir.irField->indexOffset)
+                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb());
             return ptr;
         }
         else if (vdtype->ty == Tstruct && (vd->offset + vdtype->size()) > os) {
             TypeStruct* ts = (TypeStruct*)vdtype;
             StructDeclaration* ssd = ts->sym;
-            idxs.push_back(gIR->irDsymbol[vd].irField->index);
-            if (gIR->irDsymbol[vd].irField->indexOffset) {
+            idxs.push_back(vd->ir.irField->index);
+            if (vd->ir.irField->indexOffset) {
                 Logger::println("has union field offset");
                 ptr = DtoGEP(ptr, idxs, "tmp");
                 if (ptr->getType() != llt)
                     ptr = DtoBitCast(ptr, llt);
-                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
+                ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(vd->ir.irField->indexOffset), "tmp", gIR->scopebb());
                 std::vector<unsigned> tmp;
                 return DtoIndexStruct(ptr, ssd, t, os-vd->offset, tmp);
             }
@@ -170,8 +170,8 @@
 
 void DtoResolveStruct(StructDeclaration* sd)
 {
-    if (gIR->irDsymbol[sd].resolved) return;
-    gIR->irDsymbol[sd].resolved = true;
+    if (sd->ir.resolved) return;
+    sd->ir.resolved = true;
 
     Logger::println("DtoResolveStruct(%s): %s", sd->toChars(), sd->loc.toChars());
     LOG_SCOPE;
@@ -182,7 +182,7 @@
     TypeStruct* ts = (TypeStruct*)DtoDType(sd->type);
 
     IrStruct* irstruct = new IrStruct(ts);
-    gIR->irDsymbol[sd].irStruct = irstruct;
+    sd->ir.irStruct = irstruct;
     gIR->structs.push_back(irstruct);
 
     // fields
@@ -246,7 +246,7 @@
                 fieldtype = i->second.type;
                 fieldinit = i->second.var;
                 prevsize = getABITypeSize(fieldtype);
-                gIR->irDsymbol[i->second.var].irField->index = idx;
+                i->second.var->ir.irField->index = idx;
             }
             // colliding offset?
             else if (lastoffset == i->first) {
@@ -255,16 +255,16 @@
                     fieldpad += s - prevsize;
                     prevsize = s;
                 }
-                gIR->irDsymbol[sd].irStruct->hasUnions = true;
-                gIR->irDsymbol[i->second.var].irField->index = idx;
+                sd->ir.irStruct->hasUnions = true;
+                i->second.var->ir.irField->index = idx;
             }
             // intersecting offset?
             else if (i->first < (lastoffset + prevsize)) {
                 size_t s = getABITypeSize(i->second.type);
                 assert((i->first + s) <= (lastoffset + prevsize)); // this holds because all types are aligned to their size
-                gIR->irDsymbol[sd].irStruct->hasUnions = true;
-                gIR->irDsymbol[i->second.var].irField->index = idx;
-                gIR->irDsymbol[i->second.var].irField->indexOffset = (i->first - lastoffset) / s;
+                sd->ir.irStruct->hasUnions = true;
+                i->second.var->ir.irField->index = idx;
+                i->second.var->ir.irField->indexOffset = (i->first - lastoffset) / s;
             }
             // fresh offset
             else {
@@ -284,7 +284,7 @@
                 fieldtype = i->second.type;
                 fieldinit = i->second.var;
                 prevsize = getABITypeSize(fieldtype);
-                gIR->irDsymbol[i->second.var].irField->index = idx;
+                i->second.var->ir.irField->index = idx;
                 fieldpad = 0;
             }
         }
@@ -307,8 +307,8 @@
         structtype = isaStruct(pa.get());
     }
 
-    assert(gIR->irType[ts].type == 0);
-    gIR->irType[ts].type = new llvm::PATypeHolder(structtype);
+    assert(ts->ir.type == 0);
+    ts->ir.type = new llvm::PATypeHolder(structtype);
 
     if (sd->parent->isModule()) {
         gIR->module->addTypeName(sd->mangle(),structtype);
@@ -323,8 +323,8 @@
 
 void DtoDeclareStruct(StructDeclaration* sd)
 {
-    if (gIR->irDsymbol[sd].declared) return;
-    gIR->irDsymbol[sd].declared = true;
+    if (sd->ir.declared) return;
+    sd->ir.declared = true;
 
     Logger::println("DtoDeclareStruct(%s): %s", sd->toChars(), sd->loc.toChars());
     LOG_SCOPE;
@@ -336,8 +336,8 @@
     initname.append("6__initZ");
 
     llvm::GlobalValue::LinkageTypes _linkage = DtoExternalLinkage(sd);
-    llvm::GlobalVariable* initvar = new llvm::GlobalVariable(gIR->irType[ts].type->get(), true, _linkage, NULL, initname, gIR->module);
-    gIR->irDsymbol[sd].irStruct->init = initvar;
+    llvm::GlobalVariable* initvar = new llvm::GlobalVariable(ts->ir.type->get(), true, _linkage, NULL, initname, gIR->module);
+    sd->ir.irStruct->init = initvar;
 
     gIR->constInitList.push_back(sd);
     if (DtoIsTemplateInstance(sd) || sd->getModule() == gIR->dmodule)
@@ -348,13 +348,13 @@
 
 void DtoConstInitStruct(StructDeclaration* sd)
 {
-    if (gIR->irDsymbol[sd].initialized) return;
-    gIR->irDsymbol[sd].initialized = true;
+    if (sd->ir.initialized) return;
+    sd->ir.initialized = true;
 
     Logger::println("DtoConstInitStruct(%s): %s", sd->toChars(), sd->loc.toChars());
     LOG_SCOPE;
 
-    IrStruct* irstruct = gIR->irDsymbol[sd].irStruct;
+    IrStruct* irstruct = sd->ir.irStruct;
     gIR->structs.push_back(irstruct);
 
     // make sure each offset knows its default initializer
@@ -363,10 +363,10 @@
         IrStruct::Offset* so = &i->second;
         llvm::Constant* finit = DtoConstFieldInitializer(so->var->type, so->var->init);
         so->init = finit;
-        gIR->irDsymbol[so->var].irField->constInit = finit;
+        so->var->ir.irField->constInit = finit;
     }
 
-    const llvm::StructType* structtype = isaStruct(gIR->irType[sd->type].type->get());
+    const llvm::StructType* structtype = isaStruct(sd->type->ir.type->get());
 
     // go through the field inits and build the default initializer
     std::vector<llvm::Constant*> fieldinits_ll;
@@ -374,7 +374,7 @@
     for (size_t i=0; i<nfi; ++i) {
         llvm::Constant* c;
         if (irstruct->defaultFields[i] != NULL) {
-            c = gIR->irDsymbol[irstruct->defaultFields[i]].irField->constInit;
+            c = irstruct->defaultFields[i]->ir.irField->constInit;
             assert(c);
         }
         else {
@@ -386,7 +386,7 @@
     }
 
     // generate the union mapper
-    gIR->irDsymbol[sd].irStruct->dunion = new DUnion; // uses gIR->topstruct()
+    sd->ir.irStruct->dunion = new DUnion; // uses gIR->topstruct()
 
     // always generate the constant initalizer
     if (!sd->zeroInit) {
@@ -402,11 +402,11 @@
         }
         Logger::cout() << "Initializer printed" << '\n';
         #endif
-        gIR->irDsymbol[sd].irStruct->constInit = llvm::ConstantStruct::get(structtype,fieldinits_ll);
+        sd->ir.irStruct->constInit = llvm::ConstantStruct::get(structtype,fieldinits_ll);
     }
     else {
         Logger::println("Zero initialized");
-        gIR->irDsymbol[sd].irStruct->constInit = llvm::ConstantAggregateZero::get(structtype);
+        sd->ir.irStruct->constInit = llvm::ConstantAggregateZero::get(structtype);
     }
 
     gIR->structs.pop_back();
@@ -420,17 +420,17 @@
 
 void DtoDefineStruct(StructDeclaration* sd)
 {
-    if (gIR->irDsymbol[sd].defined) return;
-    gIR->irDsymbol[sd].defined = true;
+    if (sd->ir.defined) return;
+    sd->ir.defined = true;
 
     Logger::println("DtoDefineStruct(%s): %s", sd->toChars(), sd->loc.toChars());
     LOG_SCOPE;
 
     assert(sd->type->ty == Tstruct);
     TypeStruct* ts = (TypeStruct*)sd->type;
-    gIR->irDsymbol[sd].irStruct->init->setInitializer(gIR->irDsymbol[sd].irStruct->constInit);
+    sd->ir.irStruct->init->setInitializer(sd->ir.irStruct->constInit);
 
-    gIR->irDsymbol[sd].DModule = gIR->dmodule;
+    sd->ir.DModule = gIR->dmodule;
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
--- a/gen/todebug.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/todebug.cpp	Tue May 06 07:56:03 2008 +0200
@@ -114,12 +114,12 @@
 
 llvm::GlobalVariable* DtoDwarfCompileUnit(Module* m)
 {
-    if (!gIR->irDsymbol[m].irModule)
-        gIR->irDsymbol[m].irModule = new IrModule(m);
-    else if (gIR->irDsymbol[m].irModule->dwarfCompileUnit)
+    if (!m->ir.irModule)
+        m->ir.irModule = new IrModule(m);
+    else if (m->ir.irModule->dwarfCompileUnit)
     {
-        if (gIR->irDsymbol[m].irModule->dwarfCompileUnit->getParent() == gIR->module)
-            return gIR->irDsymbol[m].irModule->dwarfCompileUnit;
+        if (m->ir.irModule->dwarfCompileUnit->getParent() == gIR->module)
+            return m->ir.irModule->dwarfCompileUnit;
     }
 
     // create a valid compile unit constant for the current module
@@ -148,7 +148,7 @@
     llvm::GlobalVariable* gv = new llvm::GlobalVariable(GetDwarfCompileUnitType(), true, llvm::GlobalValue::InternalLinkage, c, "llvm.dbg.compile_unit", gIR->module);
     gv->setSection("llvm.metadata");
 
-    gIR->irDsymbol[m].irModule->dwarfCompileUnit = gv;
+    m->ir.irModule->dwarfCompileUnit = gv;
     return gv;
 }
 
@@ -182,14 +182,14 @@
 
 void DtoDwarfFuncStart(FuncDeclaration* fd)
 {
-    assert(gIR->irDsymbol[fd].irFunc->dwarfSubProg);
-    gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), dbgToArrTy(gIR->irDsymbol[fd].irFunc->dwarfSubProg));
+    assert(fd->ir.irFunc->dwarfSubProg);
+    gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), dbgToArrTy(fd->ir.irFunc->dwarfSubProg));
 }
 
 void DtoDwarfFuncEnd(FuncDeclaration* fd)
 {
-    assert(gIR->irDsymbol[fd].irFunc->dwarfSubProg);
-    gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.region.end"), dbgToArrTy(gIR->irDsymbol[fd].irFunc->dwarfSubProg));
+    assert(fd->ir.irFunc->dwarfSubProg);
+    gIR->ir->CreateCall(gIR->module->getFunction("llvm.dbg.region.end"), dbgToArrTy(fd->ir.irFunc->dwarfSubProg));
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
--- a/gen/toir.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/toir.cpp	Tue May 06 07:56:03 2008 +0200
@@ -61,10 +61,10 @@
             // referenced by nested delegate?
             if (vd->nestedref) {
                 Logger::println("has nestedref set");
-                assert(gIR->irDsymbol[vd].irLocal);
-                gIR->irDsymbol[vd].irLocal->value = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
-                assert(gIR->irDsymbol[vd].irLocal->value);
-                assert(gIR->irDsymbol[vd].irLocal->nestedIndex >= 0);
+                assert(vd->ir.irLocal);
+                vd->ir.irLocal->value = p->func()->decl->ir.irFunc->nestedVar;
+                assert(vd->ir.irLocal->value);
+                assert(vd->ir.irLocal->nestedIndex >= 0);
             }
             // normal stack variable
             else {
@@ -72,16 +72,16 @@
                 const llvm::Type* lltype = DtoType(vd->type);
                 llvm::AllocaInst* allocainst = new llvm::AllocaInst(lltype, vd->toChars(), p->topallocapoint());
                 //allocainst->setAlignment(vd->type->alignsize()); // TODO
-                assert(!gIR->irDsymbol[vd].irLocal);
-                gIR->irDsymbol[vd].irLocal = new IrLocal(vd);
-                gIR->irDsymbol[vd].irLocal->value = allocainst;
+                assert(!vd->ir.irLocal);
+                vd->ir.irLocal = new IrLocal(vd);
+                vd->ir.irLocal->value = allocainst;
             }
 
-            Logger::cout() << "llvm value for decl: " << *gIR->irDsymbol[vd].irLocal->value << '\n';
+            Logger::cout() << "llvm value for decl: " << *vd->ir.irLocal->value << '\n';
             DValue* ie = DtoInitializer(vd->init);
         }
 
-        return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
+        return new DVarValue(vd, vd->ir.getIrValue(), true);
     }
     // struct declaration
     else if (StructDeclaration* s = declaration->isStructDeclaration())
@@ -153,11 +153,11 @@
         if (vd->ident == Id::_arguments)
         {
             Logger::println("Id::_arguments");
-            /*if (!gIR->irDsymbol[vd].getIrValue())
-                gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_arguments;
-            assert(gIR->irDsymbol[vd].getIrValue());
-            return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/
-            llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_arguments;
+            /*if (!vd->ir.getIrValue())
+                vd->ir.getIrValue() = p->func()->decl->irFunc->_arguments;
+            assert(vd->ir.getIrValue());
+            return new DVarValue(vd, vd->ir.getIrValue(), true);*/
+            llvm::Value* v = p->func()->decl->ir.irFunc->_arguments;
             assert(v);
             return new DVarValue(vd, v, true);
         }
@@ -165,11 +165,11 @@
         else if (vd->ident == Id::_argptr)
         {
             Logger::println("Id::_argptr");
-            /*if (!gIR->irDsymbol[vd].getIrValue())
-                gIR->irDsymbol[vd].getIrValue() = p->func()->decl->irFunc->_argptr;
-            assert(gIR->irDsymbol[vd].getIrValue());
-            return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);*/
-            llvm::Value* v = gIR->irDsymbol[p->func()->decl].irFunc->_argptr;
+            /*if (!vd->ir.getIrValue())
+                vd->ir.getIrValue() = p->func()->decl->irFunc->_argptr;
+            assert(vd->ir.getIrValue());
+            return new DVarValue(vd, vd->ir.getIrValue(), true);*/
+            llvm::Value* v = p->func()->decl->ir.irFunc->_argptr;
             assert(v);
             return new DVarValue(vd, v, true);
         }
@@ -186,13 +186,13 @@
         {
             Logger::println("TypeInfoDeclaration");
             DtoForceDeclareDsymbol(tid);
-            assert(gIR->irDsymbol[tid].getIrValue());
+            assert(tid->ir.getIrValue());
             const llvm::Type* vartype = DtoType(type);
             llvm::Value* m;
-            if (gIR->irDsymbol[tid].getIrValue()->getType() != getPtrToType(vartype))
-                m = p->ir->CreateBitCast(gIR->irDsymbol[tid].getIrValue(), vartype, "tmp");
+            if (tid->ir.getIrValue()->getType() != getPtrToType(vartype))
+                m = p->ir->CreateBitCast(tid->ir.getIrValue(), vartype, "tmp");
             else
-                m = gIR->irDsymbol[tid].getIrValue();
+                m = tid->ir.getIrValue();
             return new DVarValue(vd, m, true);
         }
         // classinfo
@@ -200,8 +200,8 @@
         {
             Logger::println("ClassInfoDeclaration: %s", cid->cd->toChars());
             DtoDeclareClassInfo(cid->cd);
-            assert(gIR->irDsymbol[cid->cd].irStruct->classInfo);
-            return new DVarValue(vd, gIR->irDsymbol[cid->cd].irStruct->classInfo, true);
+            assert(cid->cd->ir.irStruct->classInfo);
+            return new DVarValue(vd, cid->cd->ir.irStruct->classInfo, true);
         }
         // nested variable
         else if (vd->nestedref) {
@@ -211,11 +211,11 @@
         // function parameter
         else if (vd->isParameter()) {
             Logger::println("function param");
-            if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[vd].getIrValue())) {
-                return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
+            if (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type) || llvm::isa<llvm::AllocaInst>(vd->ir.getIrValue())) {
+                return new DVarValue(vd, vd->ir.getIrValue(), true);
             }
-            else if (llvm::isa<llvm::Argument>(gIR->irDsymbol[vd].getIrValue())) {
-                return new DImValue(type, gIR->irDsymbol[vd].getIrValue());
+            else if (llvm::isa<llvm::Argument>(vd->ir.getIrValue())) {
+                return new DImValue(type, vd->ir.getIrValue());
             }
             else assert(0);
         }
@@ -225,12 +225,12 @@
                 vd->toObjFile();
                 DtoConstInitGlobal(vd);
             }
-            if (!gIR->irDsymbol[vd].getIrValue() || DtoType(vd->type)->isAbstract()) {
+            if (!vd->ir.getIrValue() || DtoType(vd->type)->isAbstract()) {
                 Logger::println("global variable not resolved :/ %s", vd->toChars());
                 Logger::cout() << *DtoType(vd->type) << '\n';
                 assert(0);
             }
-            return new DVarValue(vd, gIR->irDsymbol[vd].getIrValue(), true);
+            return new DVarValue(vd, vd->ir.getIrValue(), true);
         }
     }
     else if (FuncDeclaration* fdecl = var->isFuncDeclaration())
@@ -239,7 +239,7 @@
         if (fdecl->llvmInternal != LLVMva_arg) {// && fdecl->llvmValue == 0)
             DtoForceDeclareDsymbol(fdecl);
         }
-        return new DFuncValue(fdecl, gIR->irDsymbol[fdecl].irFunc->func);
+        return new DFuncValue(fdecl, fdecl->ir.irFunc->func);
     }
     else if (SymbolDeclaration* sdecl = var->isSymbolDeclaration())
     {
@@ -250,8 +250,8 @@
         TypeStruct* ts = (TypeStruct*)sdecltype;
         assert(ts->sym);
         DtoForceConstInitDsymbol(ts->sym);
-        assert(gIR->irDsymbol[ts->sym].irStruct->init);
-        return new DVarValue(type, gIR->irDsymbol[ts->sym].irStruct->init, true);
+        assert(ts->sym->ir.irStruct->init);
+        return new DVarValue(type, ts->sym->ir.irStruct->init, true);
     }
     else
     {
@@ -275,17 +275,17 @@
         assert(sdecltype->ty == Tstruct);
         TypeStruct* ts = (TypeStruct*)sdecltype;
         DtoForceConstInitDsymbol(ts->sym);
-        assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
-        return gIR->irDsymbol[ts->sym].irStruct->constInit;
+        assert(ts->sym->ir.irStruct->constInit);
+        return ts->sym->ir.irStruct->constInit;
     }
     else if (TypeInfoDeclaration* ti = var->isTypeInfoDeclaration())
     {
         DtoForceDeclareDsymbol(ti);
-        assert(gIR->irDsymbol[ti].getIrValue());
+        assert(ti->ir.getIrValue());
         const llvm::Type* vartype = DtoType(type);
-        llvm::Constant* m = isaConstant(gIR->irDsymbol[ti].getIrValue());
+        llvm::Constant* m = isaConstant(ti->ir.getIrValue());
         assert(m);
-        if (gIR->irDsymbol[ti].getIrValue()->getType() != getPtrToType(vartype))
+        if (ti->ir.getIrValue()->getType() != getPtrToType(vartype))
             m = llvm::ConstantExpr::getBitCast(m, vartype);
         return m;
     }
@@ -1083,7 +1083,7 @@
             }
 
             // build type info array
-            assert(gIR->irDsymbol[Type::typeinfo].irStruct->constInit);
+            assert(Type::typeinfo->ir.irStruct->constInit);
             const llvm::Type* typeinfotype = DtoType(Type::typeinfo->type);
             const llvm::ArrayType* typeinfoarraytype = llvm::ArrayType::get(typeinfotype,vtype->getNumElements());
 
@@ -1094,8 +1094,8 @@
                 Expression* argexp = (Expression*)arguments->data[i];
                 TypeInfoDeclaration* tidecl = argexp->type->getTypeInfoDeclaration();
                 DtoForceDeclareDsymbol(tidecl);
-                assert(gIR->irDsymbol[tidecl].getIrValue());
-                vtypeinfos.push_back(gIR->irDsymbol[tidecl].getIrValue());
+                assert(tidecl->ir.getIrValue());
+                vtypeinfos.push_back(tidecl->ir.getIrValue());
                 llvm::Value* v = p->ir->CreateBitCast(vtypeinfos[k], typeinfotype, "tmp");
                 p->ir->CreateStore(v, DtoGEPi(typeinfomem,0,k,"tmp"));
             }
@@ -1237,16 +1237,16 @@
         Logger::println("VarDeclaration");
 
         // handle forward reference
-        if (!gIR->irDsymbol[vd].declared && vd->isDataseg()) {
+        if (!vd->ir.declared && vd->isDataseg()) {
             vd->toObjFile(); // TODO
         }
 
-        assert(gIR->irDsymbol[vd].getIrValue());
+        assert(vd->ir.getIrValue());
         Type* t = DtoDType(type);
         Type* tnext = DtoDType(t->next);
         Type* vdtype = DtoDType(vd->type);
 
-        llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : gIR->irDsymbol[vd].getIrValue();
+        llvm::Value* llvalue = vd->nestedref ? DtoNestedVariable(vd) : vd->ir.getIrValue();
         llvm::Value* varmem = 0;
 
         if (vdtype->ty == Tstruct && !(t->ty == Tpointer && t->next == vdtype)) {
@@ -1321,7 +1321,7 @@
         FuncDeclaration* fd = fv->func;
         assert(fd);
         DtoForceDeclareDsymbol(fd);
-        return new DFuncValue(fd, gIR->irDsymbol[fd].irFunc->func);
+        return new DFuncValue(fd, fd->ir.irFunc->func);
     }
     else if (DImValue* im = v->isIm()) {
         Logger::println("is immediate");
@@ -1427,7 +1427,7 @@
         // super call
         if (e1->op == TOKsuper) {
             DtoForceDeclareDsymbol(fdecl);
-            funcval = gIR->irDsymbol[fdecl].irFunc->func;
+            funcval = fdecl->ir.irFunc->func;
             assert(funcval);
         }
         // normal virtual call
@@ -1448,7 +1448,7 @@
         // static call
         else {
             DtoForceDeclareDsymbol(fdecl);
-            funcval = gIR->irDsymbol[fdecl].irFunc->func;
+            funcval = fdecl->ir.irFunc->func;
             assert(funcval);
             //assert(funcval->getType() == DtoType(fdecl->type));
         }
@@ -1471,7 +1471,7 @@
 
     if (VarDeclaration* vd = var->isVarDeclaration()) {
         llvm::Value* v;
-        v = gIR->irDsymbol[p->func()->decl].irFunc->thisVar;
+        v = p->func()->decl->ir.irFunc->thisVar;
         if (llvm::isa<llvm::AllocaInst>(v))
             v = new llvm::LoadInst(v, "tmp", p->scopebb());
         return new DThisValue(vd, v);
@@ -1938,7 +1938,7 @@
         }
         else {
             assert(ts->sym);
-            DtoStructCopy(emem,gIR->irDsymbol[ts->sym].irStruct->init);
+            DtoStructCopy(emem,ts->sym->ir.irStruct->init);
         }
     }
 
@@ -2223,7 +2223,7 @@
     if (DFuncValue* f = u->isFunc()) {
         //assert(f->vthis);
         //uval = f->vthis;
-        llvm::Value* nestvar = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
+        llvm::Value* nestvar = p->func()->decl->ir.irFunc->nestedVar;
         if (nestvar)
             uval = nestvar;
         else
@@ -2263,7 +2263,7 @@
     else
     {
         DtoForceDeclareDsymbol(func);
-        castfptr = gIR->irDsymbol[func].irFunc->func;
+        castfptr = func->ir.irFunc->func;
     }
 
     castfptr = DtoBitCast(castfptr, fptr->getType()->getContainedType(0));
@@ -2521,7 +2521,7 @@
 
     llvm::Value* context = DtoGEPi(lval,0,0,"tmp",p->scopebb());
     const llvm::PointerType* pty = isaPointer(context->getType()->getContainedType(0));
-    llvm::Value* llvmNested = gIR->irDsymbol[p->func()->decl].irFunc->nestedVar;
+    llvm::Value* llvmNested = p->func()->decl->ir.irFunc->nestedVar;
     if (llvmNested == NULL) {
         llvm::Value* nullcontext = llvm::ConstantPointerNull::get(pty);
         p->ir->CreateStore(nullcontext, context);
@@ -2533,8 +2533,8 @@
 
     llvm::Value* fptr = DtoGEPi(lval,0,1,"tmp",p->scopebb());
 
-    assert(gIR->irDsymbol[fd].irFunc->func);
-    llvm::Value* castfptr = new llvm::BitCastInst(gIR->irDsymbol[fd].irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
+    assert(fd->ir.irFunc->func);
+    llvm::Value* castfptr = new llvm::BitCastInst(fd->ir.irFunc->func,fptr->getType()->getContainedType(0),"tmp",p->scopebb());
     new llvm::StoreInst(castfptr, fptr, p->scopebb());
 
     if (temp)
@@ -2663,7 +2663,7 @@
     unsigned n = elements->dim;
 
     // unions might have different types for each literal
-    if (gIR->irDsymbol[sd].irStruct->hasUnions) {
+    if (sd->ir.irStruct->hasUnions) {
         // build the type of the literal
         std::vector<const llvm::Type*> tys;
         for (unsigned i=0; i<n; ++i) {
--- a/gen/tollvm.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/tollvm.cpp	Tue May 06 07:56:03 2008 +0200
@@ -98,7 +98,7 @@
 
     // aggregates
     case Tstruct:    {
-        if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
+        if (!t->ir.type || *t->ir.type == NULL) {
             // recursive or cyclic declaration
             if (!gIR->structs.empty())
             {
@@ -116,11 +116,11 @@
         TypeStruct* ts = (TypeStruct*)t;
         assert(ts->sym);
         DtoResolveDsymbol(ts->sym);
-        return gIR->irDsymbol[ts->sym].irStruct->recty.get(); // gIR->irType[t].type->get();
+        return ts->sym->ir.irStruct->recty.get(); // t->ir.type->get();
     }
 
     case Tclass:    {
-        /*if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
+        /*if (!t].type || *gIR->irType[t->ir.type == NULL) {
             // recursive or cyclic declaration
             if (!gIR->structs.empty())
             {
@@ -139,28 +139,28 @@
         TypeClass* tc = (TypeClass*)t;
         assert(tc->sym);
         DtoResolveDsymbol(tc->sym);
-        return getPtrToType(gIR->irDsymbol[tc->sym].irStruct->recty.get()); // gIR->irType[t].type->get());
+        return getPtrToType(tc->sym->ir.irStruct->recty.get()); // t->ir.type->get());
     }
 
     // functions
     case Tfunction:
     {
-        if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
+        if (!t->ir.type || *t->ir.type == NULL) {
             return DtoFunctionType(t,NULL);
         }
         else {
-            return gIR->irType[t].type->get();
+            return t->ir.type->get();
         }
     }
 
     // delegates
     case Tdelegate:
     {
-        if (!gIR->irType[t].type || *gIR->irType[t].type == NULL) {
+        if (!t->ir.type || *t->ir.type == NULL) {
             return DtoDelegateType(t);
         }
         else {
-            return gIR->irType[t].type->get();
+            return t->ir.type->get();
         }
     }
 
@@ -561,8 +561,8 @@
             TypeStruct* ts = (TypeStruct*)t;
             assert(ts);
             assert(ts->sym);
-            assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
-            _init = gIR->irDsymbol[ts->sym].irStruct->constInit;
+            assert(ts->sym->ir.irStruct->constInit);
+            _init = ts->sym->ir.irStruct->constInit;
         }
         else if (t->ty == Tclass)
         {
@@ -724,7 +724,7 @@
     assert(p->isFuncDeclaration() || p->isClassDeclaration());
     if (FuncDeclaration* fd = p->isFuncDeclaration())
     {
-        llvm::Value* v = gIR->irDsymbol[fd].irFunc->nestedVar;
+        llvm::Value* v = fd->ir.irFunc->nestedVar;
         assert(v);
         return v->getType();
     }
@@ -754,9 +754,9 @@
 
         if (fd->toParent2() == func)
         {
-            if (!gIR->irDsymbol[func].irFunc->nestedVar)
+            if (!func->ir.irFunc->nestedVar)
                 return NULL;
-            return DtoBitCast(v, gIR->irDsymbol[func].irFunc->nestedVar->getType());
+            return DtoBitCast(v, func->ir.irFunc->nestedVar->getType());
         }
 
         v = DtoBitCast(v, get_next_frame_ptr_type(fd));
@@ -770,7 +770,7 @@
         else if (ClassDeclaration* cd = fd->toParent2()->isClassDeclaration())
         {
             size_t idx = 2;
-            //idx += gIR->irDsymbol[cd].irStruct->interfaceVec.size();
+            //idx += cd->ir.irStruct->interfaceVec.size();
             v = DtoGEPi(v,0,idx,"tmp");
             v = DtoLoad(v);
         }
@@ -807,10 +807,10 @@
 
     // in the right scope already
     if (func == irfunc->decl)
-        return gIR->irDsymbol[irfunc->decl].irFunc->nestedVar;
+        return irfunc->decl->ir.irFunc->nestedVar;
 
     // use the 'this' pointer
-    llvm::Value* ptr = gIR->irDsymbol[irfunc->decl].irFunc->thisVar;
+    llvm::Value* ptr = irfunc->decl->ir.irFunc->thisVar;
     assert(ptr);
 
     // return the fully resolved frame pointer
@@ -878,10 +878,10 @@
     assert(ptr && "nested var, but no context");
 
     // we must cast here to be sure. nested classes just have a void*
-    ptr = DtoBitCast(ptr, gIR->irDsymbol[func].irFunc->nestedVar->getType());
+    ptr = DtoBitCast(ptr, func->ir.irFunc->nestedVar->getType());
 
     // index nested var and load (if necessary)
-    llvm::Value* v = DtoGEPi(ptr, 0, gIR->irDsymbol[vd].irLocal->nestedIndex, "tmp");
+    llvm::Value* v = DtoGEPi(ptr, 0, vd->ir.irLocal->nestedIndex, "tmp");
     // references must be loaded, for normal variables this IS already the variable storage!!!
     if (vd->isParameter() && (vd->isRef() || vd->isOut() || DtoIsPassedByRef(vd->type)))
         v = DtoLoad(v);
@@ -964,9 +964,9 @@
             llvm::Value* tmp = rhs->getRVal();
             FuncDeclaration* fdecl = gIR->func()->decl;
             // respecify the this param
-            if (!llvm::isa<llvm::AllocaInst>(gIR->irDsymbol[fdecl].irFunc->thisVar))
-                gIR->irDsymbol[fdecl].irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
-            DtoStore(tmp, gIR->irDsymbol[fdecl].irFunc->thisVar);
+            if (!llvm::isa<llvm::AllocaInst>(fdecl->ir.irFunc->thisVar))
+                fdecl->ir.irFunc->thisVar = new llvm::AllocaInst(tmp->getType(), "newthis", gIR->topallocapoint());
+            DtoStore(tmp, fdecl->ir.irFunc->thisVar);
         }
         // regular class ref -> class ref assignment
         else {
@@ -1572,8 +1572,8 @@
 
 void DtoConstInitGlobal(VarDeclaration* vd)
 {
-    if (gIR->irDsymbol[vd].initialized) return;
-    gIR->irDsymbol[vd].initialized = gIR->dmodule;
+    if (vd->ir.initialized) return;
+    vd->ir.initialized = gIR->dmodule;
 
     Logger::println("* DtoConstInitGlobal(%s)", vd->toChars());
     LOG_SCOPE;
@@ -1605,8 +1605,8 @@
             llvm::GlobalVariable* gv = llvm::cast<llvm::GlobalVariable>(_init);
             assert(t->ty == Tstruct);
             TypeStruct* ts = (TypeStruct*)t;
-            assert(gIR->irDsymbol[ts->sym].irStruct->constInit);
-            _init = gIR->irDsymbol[ts->sym].irStruct->constInit;
+            assert(ts->sym->ir.irStruct->constInit);
+            _init = ts->sym->ir.irStruct->constInit;
         }
         // array single value init
         else if (isaArray(_type))
@@ -1626,12 +1626,12 @@
 
     if (_init && _init->getType() != _type)
         _type = _init->getType();
-    llvm::cast<llvm::OpaqueType>(gIR->irDsymbol[vd].irGlobal->type.get())->refineAbstractTypeTo(_type);
-    _type = gIR->irDsymbol[vd].irGlobal->type.get();
+    llvm::cast<llvm::OpaqueType>(vd->ir.irGlobal->type.get())->refineAbstractTypeTo(_type);
+    _type = vd->ir.irGlobal->type.get();
     //_type->dump();
     assert(!_type->isAbstract());
 
-    llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(gIR->irDsymbol[vd].irGlobal->value);
+    llvm::GlobalVariable* gvar = llvm::cast<llvm::GlobalVariable>(vd->ir.irGlobal->value);
     if (!(vd->storage_class & STCextern) && (vd->getModule() == gIR->dmodule || istempl))
     {
         gvar->setInitializer(_init);
@@ -1729,7 +1729,7 @@
 
 void DtoForceDeclareDsymbol(Dsymbol* dsym)
 {
-    if (gIR->irDsymbol[dsym].declared) return;
+    if (dsym->ir.declared) return;
     Logger::println("DtoForceDeclareDsymbol(%s)", dsym->toPrettyChars());
     LOG_SCOPE;
     DtoResolveDsymbol(dsym);
@@ -1743,7 +1743,7 @@
 
 void DtoForceConstInitDsymbol(Dsymbol* dsym)
 {
-    if (gIR->irDsymbol[dsym].initialized) return;
+    if (dsym->ir.initialized) return;
     Logger::println("DtoForceConstInitDsymbol(%s)", dsym->toPrettyChars());
     LOG_SCOPE;
     DtoResolveDsymbol(dsym);
@@ -1758,7 +1758,7 @@
 
 void DtoForceDefineDsymbol(Dsymbol* dsym)
 {
-    if (gIR->irDsymbol[dsym].defined) return;
+    if (dsym->ir.defined) return;
     Logger::println("DtoForceDefineDsymbol(%s)", dsym->toPrettyChars());
     LOG_SCOPE;
     DtoResolveDsymbol(dsym);
@@ -1797,7 +1797,7 @@
     // ClassInfo classinfo
     ClassDeclaration* cd2 = ClassDeclaration::classinfo;
     DtoResolveClass(cd2);
-    types.push_back(getPtrToType(gIR->irType[cd2->type].type->get()));
+    types.push_back(getPtrToType(cd2->type->ir.type->get()));
     // void*[] vtbl
     std::vector<const llvm::Type*> vtbltypes;
     vtbltypes.push_back(DtoSize_t());
--- a/gen/toobj.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/toobj.cpp	Tue May 06 07:56:03 2008 +0200
@@ -65,9 +65,13 @@
     gIR = &ir;
     ir.dmodule = this;
 
+    // reset all IR data stored in Dsymbols and Types
+    IrDsymbol::resetAll();
+    IrType::resetAll();
+
     // module ir state
     // might already exist via import, just overwrite...
-    gIR->irDsymbol[this].irModule = new IrModule(this);
+    this->ir.irModule = new IrModule(this);
 
     // name the module
     std::string mname(toChars());
@@ -98,17 +102,17 @@
     }
 
     // start out by providing opaque for the built-in class types
-    if (!gIR->irType[ClassDeclaration::object->type].type)
-        gIR->irType[ClassDeclaration::object->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get());
+    if (!ClassDeclaration::object->type->ir.type)
+        ClassDeclaration::object->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());
 
-    if (!gIR->irType[Type::typeinfo->type].type)
-        gIR->irType[Type::typeinfo->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get());
+    if (!Type::typeinfo->type->ir.type)
+        Type::typeinfo->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());
 
-    if (!gIR->irType[ClassDeclaration::classinfo->type].type)
-        gIR->irType[ClassDeclaration::classinfo->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get());
+    if (!ClassDeclaration::classinfo->type->ir.type)
+        ClassDeclaration::classinfo->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());
 
-    /*if (!gIR->irType[Type::typeinfoclass->type].type)
-        gIR->irType[Type::typeinfoclass->type].type = new llvm::PATypeHolder(llvm::OpaqueType::get());*/
+    /*if (!Type::typeinfoclass->type->ir.type)
+        Type::typeinfoclass->type->ir.type = new llvm::PATypeHolder(llvm::OpaqueType::get());*/
 
     // process module members
     for (int k=0; k < members->dim; k++) {
@@ -177,7 +181,7 @@
 
     size_t n = gIR->ctors.size();
     if (n == 1)
-        return gIR->irDsymbol[gIR->ctors[0]].irFunc->func;
+        return gIR->ctors[0]->ir.irFunc->func;
 
     std::string name("_D");
     name.append(gIR->dmodule->mangle());
@@ -192,7 +196,7 @@
     LLVMBuilder builder(bb);
 
     for (size_t i=0; i<n; i++) {
-        llvm::Function* f = gIR->irDsymbol[gIR->ctors[i]].irFunc->func;
+        llvm::Function* f = gIR->ctors[i]->ir.irFunc->func;
         llvm::CallInst* call = builder.CreateCall(f,"");
         call->setCallingConv(llvm::CallingConv::Fast);
     }
@@ -210,7 +214,7 @@
 
     size_t n = gIR->dtors.size();
     if (n == 1)
-        return gIR->irDsymbol[gIR->dtors[0]].irFunc->func;
+        return gIR->dtors[0]->ir.irFunc->func;
 
     std::string name("_D");
     name.append(gIR->dmodule->mangle());
@@ -225,7 +229,7 @@
     LLVMBuilder builder(bb);
 
     for (size_t i=0; i<n; i++) {
-        llvm::Function* f = gIR->irDsymbol[gIR->dtors[i]].irFunc->func;
+        llvm::Function* f = gIR->dtors[i]->ir.irFunc->func;
         llvm::CallInst* call = builder.CreateCall(f,"");
         call->setCallingConv(llvm::CallingConv::Fast);
     }
@@ -243,7 +247,7 @@
 
     size_t n = gIR->unitTests.size();
     if (n == 1)
-        return gIR->irDsymbol[gIR->unitTests[0]].irFunc->func;
+        return gIR->unitTests[0]->ir.irFunc->func;
 
     std::string name("_D");
     name.append(gIR->dmodule->mangle());
@@ -258,7 +262,7 @@
     LLVMBuilder builder(bb);
 
     for (size_t i=0; i<n; i++) {
-        llvm::Function* f = gIR->irDsymbol[gIR->unitTests[i]].irFunc->func;
+        llvm::Function* f = gIR->unitTests[i]->ir.irFunc->func;
         llvm::CallInst* call = builder.CreateCall(f,"");
         call->setCallingConv(llvm::CallingConv::Fast);
     }
@@ -289,17 +293,17 @@
     DtoForceConstInitDsymbol(moduleinfo);
 
     // moduleinfo llvm struct type
-    const llvm::StructType* moduleinfoTy = isaStruct(gIR->irType[moduleinfo->type].type->get());
+    const llvm::StructType* moduleinfoTy = isaStruct(moduleinfo->type->ir.type->get());
 
     // classinfo llvm struct type
-    const llvm::StructType* classinfoTy = isaStruct(gIR->irType[ClassDeclaration::classinfo->type].type->get());
+    const llvm::StructType* classinfoTy = isaStruct(ClassDeclaration::classinfo->type->ir.type->get());
 
     // initializer vector
     std::vector<llvm::Constant*> initVec;
     llvm::Constant* c = 0;
 
     // vtable
-    c = gIR->irDsymbol[moduleinfo].irStruct->vtbl;
+    c = moduleinfo->ir.irStruct->vtbl;
     initVec.push_back(c);
 
     // monitor
@@ -343,7 +347,7 @@
         c = DtoConstSlice(DtoConstSize_t(importInits.size()), c);
     }
     else
-        c = gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(3);
+        c = moduleinfo->ir.irStruct->constInit->getOperand(3);
     initVec.push_back(c);
 
     // localClasses[]
@@ -368,8 +372,8 @@
             continue;
         }
         Logger::println("class: %s", cd->toPrettyChars());
-        assert(gIR->irDsymbol[cd].irStruct->classInfo);
-        classInits.push_back(gIR->irDsymbol[cd].irStruct->classInfo);
+        assert(cd->ir.irStruct->classInfo);
+        classInits.push_back(cd->ir.irStruct->classInfo);
     }
     // has class array?
     if (!classInits.empty())
@@ -384,7 +388,7 @@
         c = DtoConstSlice(DtoConstSize_t(classInits.size()), c);
     }
     else
-        c = gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(4);
+        c = moduleinfo->ir.irStruct->constInit->getOperand(4);
     initVec.push_back(c);
 
     // flags
@@ -395,25 +399,25 @@
 
     // ctor
     llvm::Function* fctor = build_module_ctor();
-    c = fctor ? fctor : gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(6);
+    c = fctor ? fctor : moduleinfo->ir.irStruct->constInit->getOperand(6);
     initVec.push_back(c);
 
     // dtor
     llvm::Function* fdtor = build_module_dtor();
-    c = fdtor ? fdtor : gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(7);
+    c = fdtor ? fdtor : moduleinfo->ir.irStruct->constInit->getOperand(7);
     initVec.push_back(c);
 
     // unitTest
     llvm::Function* unittest = build_module_unittest();
-    c = unittest ? unittest : gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(8);
+    c = unittest ? unittest : moduleinfo->ir.irStruct->constInit->getOperand(8);
     initVec.push_back(c);
 
     // xgetMembers
-    c = gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(9);
+    c = moduleinfo->ir.irStruct->constInit->getOperand(9);
     initVec.push_back(c);
 
     // ictor
-    c = gIR->irDsymbol[moduleinfo].irStruct->constInit->getOperand(10);
+    c = moduleinfo->ir.irStruct->constInit->getOperand(10);
     initVec.push_back(c);
 
     /*Logger::println("MODULE INFO INITIALIZERS");
@@ -513,11 +517,11 @@
             return;
 
         // don't duplicate work
-        if (gIR->irDsymbol[this].resolved) return;
-        gIR->irDsymbol[this].resolved = true;
-        gIR->irDsymbol[this].declared = true;
+        if (this->ir.resolved) return;
+        this->ir.resolved = true;
+        this->ir.declared = true;
 
-        gIR->irDsymbol[this].irGlobal = new IrGlobal(this);
+        this->ir.irGlobal = new IrGlobal(this);
 
         Logger::println("parent: %s (%s)", parent->toChars(), parent->kind());
 
@@ -534,12 +538,12 @@
 
         Logger::println("Creating global variable");
 
-        const llvm::Type* _type = gIR->irDsymbol[this].irGlobal->type.get();
+        const llvm::Type* _type = this->ir.irGlobal->type.get();
         llvm::GlobalValue::LinkageTypes _linkage = DtoLinkage(this);
         std::string _name(mangle());
 
         llvm::GlobalVariable* gvar = new llvm::GlobalVariable(_type,_isconst,_linkage,NULL,_name,gIR->module);
-        gIR->irDsymbol[this].irGlobal->value = gvar;
+        this->ir.irGlobal->value = gvar;
 
         Logger::cout() << *gvar << '\n';
 
@@ -555,7 +559,7 @@
         Logger::println("Aggregate var declaration: '%s' offset=%d", toChars(), offset);
 
         const llvm::Type* _type = DtoType(type);
-        gIR->irDsymbol[this].irField = new IrField(this);
+        this->ir.irField = new IrField(this);
 
         // add the field in the IRStruct
         gIR->topstruct()->offsets.insert(std::make_pair(offset, IrStruct::Offset(this, _type)));
--- a/gen/typinf.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/gen/typinf.cpp	Tue May 06 07:56:03 2008 +0200
@@ -250,21 +250,21 @@
 
 void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
 {
-    if (gIR->irDsymbol[tid].resolved) return;
-    gIR->irDsymbol[tid].resolved = true;
+    if (tid->ir.resolved) return;
+    tid->ir.resolved = true;
 
     Logger::println("DtoResolveTypeInfo(%s)", tid->toChars());
     LOG_SCOPE;
 
-    gIR->irDsymbol[tid].irGlobal = new IrGlobal(tid);
+    tid->ir.irGlobal = new IrGlobal(tid);
 
     gIR->declareList.push_back(tid);
 }
 
 void DtoDeclareTypeInfo(TypeInfoDeclaration* tid)
 {
-    if (gIR->irDsymbol[tid].declared) return;
-    gIR->irDsymbol[tid].declared = true;
+    if (tid->ir.declared) return;
+    tid->ir.declared = true;
 
     Logger::println("DtoDeclareTypeInfo(%s)", tid->toChars());
     LOG_SCOPE;
@@ -282,19 +282,19 @@
             const llvm::Type* t = llvm::OpaqueType::get();
             llvm::GlobalVariable* g = new llvm::GlobalVariable(t, true, llvm::GlobalValue::ExternalLinkage, NULL, mangled, gIR->module);
             assert(g);
-            /*if (!gIR->irDsymbol[tid].irGlobal)
-                gIR->irDsymbol[tid].irGlobal = new IrGlobal(tid);*/
-            gIR->irDsymbol[tid].irGlobal->value = g;
+            /*if (!tid->ir.irGlobal)
+                tid->ir.irGlobal = new IrGlobal(tid);*/
+            tid->ir.irGlobal->value = g;
             mangled.append("__TYPE");
-            gIR->module->addTypeName(mangled, gIR->irDsymbol[tid].irGlobal->value->getType()->getContainedType(0));
-            Logger::println("Got typeinfo var: %s", gIR->irDsymbol[tid].irGlobal->value->getName().c_str());
-            gIR->irDsymbol[tid].initialized = true;
-            gIR->irDsymbol[tid].defined = true;
+            gIR->module->addTypeName(mangled, tid->ir.irGlobal->value->getType()->getContainedType(0));
+            Logger::println("Got typeinfo var: %s", tid->ir.irGlobal->value->getName().c_str());
+            tid->ir.initialized = true;
+            tid->ir.defined = true;
         }
-        else if (!gIR->irDsymbol[tid].irGlobal->value) {
-            gIR->irDsymbol[tid].irGlobal->value = found;
-            gIR->irDsymbol[tid].initialized = true;
-            gIR->irDsymbol[tid].defined = true;
+        else if (!tid->ir.irGlobal->value) {
+            tid->ir.irGlobal->value = found;
+            tid->ir.initialized = true;
+            tid->ir.defined = true;
         }
     }
     // custom typedef
@@ -306,8 +306,8 @@
 
 void DtoConstInitTypeInfo(TypeInfoDeclaration* tid)
 {
-    if (gIR->irDsymbol[tid].initialized) return;
-    gIR->irDsymbol[tid].initialized = true;
+    if (tid->ir.initialized) return;
+    tid->ir.initialized = true;
 
     Logger::println("DtoConstInitTypeInfo(%s)", tid->toChars());
     LOG_SCOPE;
@@ -317,8 +317,8 @@
 
 void DtoDefineTypeInfo(TypeInfoDeclaration* tid)
 {
-    if (gIR->irDsymbol[tid].defined) return;
-    gIR->irDsymbol[tid].defined = true;
+    if (tid->ir.defined) return;
+    tid->ir.defined = true;
 
     Logger::println("DtoDefineTypeInfo(%s)", tid->toChars());
     LOG_SCOPE;
@@ -353,10 +353,10 @@
     ClassDeclaration* base = Type::typeinfotypedef;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoTypedefDeclaration::llvmDefine()
@@ -367,12 +367,12 @@
     ClassDeclaration* base = Type::typeinfotypedef;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
     Logger::cout() << "got stype: " << *stype << '\n';
 
     // vtbl
     std::vector<llvm::Constant*> sinits;
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(getNullPtr(getPtrToType(llvm::Type::Int8Ty)));
@@ -391,9 +391,9 @@
     assert(sd->basetype->vtinfo);
     DtoForceDeclareDsymbol(sd->basetype->vtinfo);
 
-    assert(gIR->irDsymbol[sd->basetype->vtinfo].irGlobal->value);
-    assert(llvm::isa<llvm::Constant>(gIR->irDsymbol[sd->basetype->vtinfo].irGlobal->value));
-    llvm::Constant* castbase = llvm::cast<llvm::Constant>(gIR->irDsymbol[sd->basetype->vtinfo].irGlobal->value);
+    assert(sd->basetype->vtinfo->ir.irGlobal->value);
+    assert(llvm::isa<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value));
+    llvm::Constant* castbase = llvm::cast<llvm::Constant>(sd->basetype->vtinfo->ir.irGlobal->value);
     castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
     sinits.push_back(castbase);
 
@@ -421,7 +421,7 @@
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoTypedefDeclaration::toDt(dt_t **pdt)
@@ -439,10 +439,10 @@
     ClassDeclaration* base = Type::typeinfoenum;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoEnumDeclaration::llvmDefine()
@@ -453,11 +453,11 @@
     ClassDeclaration* base = Type::typeinfoenum;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // vtbl
     std::vector<llvm::Constant*> sinits;
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -476,8 +476,8 @@
     assert(sd->memtype->vtinfo);
     DtoForceDeclareDsymbol(sd->memtype->vtinfo);
 
-    assert(llvm::isa<llvm::Constant>(gIR->irDsymbol[sd->memtype->vtinfo].irGlobal->value));
-    llvm::Constant* castbase = llvm::cast<llvm::Constant>(gIR->irDsymbol[sd->memtype->vtinfo].irGlobal->value);
+    assert(llvm::isa<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value));
+    llvm::Constant* castbase = llvm::cast<llvm::Constant>(sd->memtype->vtinfo->ir.irGlobal->value);
     castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
     sinits.push_back(castbase);
 
@@ -506,7 +506,7 @@
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoEnumDeclaration::toDt(dt_t **pdt)
@@ -521,10 +521,10 @@
     ClassDeclaration* base = cd;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[tid].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module);
+    tid->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,tid->toChars(),gIR->module);
 }
 
 static llvm::Constant* LLVM_D_Define_TypeInfoBase(Type* basetype, TypeInfoDeclaration* tid, ClassDeclaration* cd)
@@ -532,11 +532,11 @@
     ClassDeclaration* base = cd;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // vtbl
     std::vector<llvm::Constant*> sinits;
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -546,14 +546,14 @@
     basetype->getTypeInfo(NULL);
     assert(basetype->vtinfo);
     DtoForceDeclareDsymbol(basetype->vtinfo);
-    assert(llvm::isa<llvm::Constant>(gIR->irDsymbol[basetype->vtinfo].irGlobal->value));
-    llvm::Constant* castbase = llvm::cast<llvm::Constant>(gIR->irDsymbol[basetype->vtinfo].irGlobal->value);
+    assert(llvm::isa<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value));
+    llvm::Constant* castbase = llvm::cast<llvm::Constant>(basetype->vtinfo->ir.irGlobal->value);
     castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
     sinits.push_back(castbase);
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[tid].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(tid->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 /* ========================================================================= */
@@ -626,10 +626,10 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoStaticArrayDeclaration::llvmDefine()
@@ -642,12 +642,12 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<llvm::Constant*> sinits;
     // first is always the vtable
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -660,7 +660,7 @@
     // get symbol
     assert(tc->next->vtinfo);
     DtoForceDeclareDsymbol(tc->next->vtinfo);
-    llvm::Constant* castbase = isaConstant(gIR->irDsymbol[tc->next->vtinfo].irGlobal->value);
+    llvm::Constant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value);
     castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
     sinits.push_back(castbase);
 
@@ -669,7 +669,7 @@
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoStaticArrayDeclaration::toDt(dt_t **pdt)
@@ -689,10 +689,10 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoAssociativeArrayDeclaration::llvmDefine()
@@ -705,12 +705,12 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<llvm::Constant*> sinits;
     // first is always the vtable
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -725,7 +725,7 @@
     // get symbol
     assert(tc->next->vtinfo);
     DtoForceDeclareDsymbol(tc->next->vtinfo);
-    llvm::Constant* castbase = isaConstant(gIR->irDsymbol[tc->next->vtinfo].irGlobal->value);
+    llvm::Constant* castbase = isaConstant(tc->next->vtinfo->ir.irGlobal->value);
     castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(2));
     sinits.push_back(castbase);
 
@@ -735,13 +735,13 @@
     // get symbol
     assert(tc->index->vtinfo);
     DtoForceDeclareDsymbol(tc->index->vtinfo);
-    castbase = isaConstant(gIR->irDsymbol[tc->index->vtinfo].irGlobal->value);
+    castbase = isaConstant(tc->index->vtinfo->ir.irGlobal->value);
     castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(3));
     sinits.push_back(castbase);
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoAssociativeArrayDeclaration::toDt(dt_t **pdt)
@@ -822,10 +822,10 @@
     ClassDeclaration* base = Type::typeinfostruct;
     DtoResolveClass(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoStructDeclaration::llvmDefine()
@@ -841,11 +841,11 @@
     ClassDeclaration* base = Type::typeinfostruct;
     DtoForceConstInitDsymbol(base);
 
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // vtbl
     std::vector<llvm::Constant*> sinits;
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -864,8 +864,8 @@
     }
     else
     {
-        size_t cisize = getTypeStoreSize(gIR->irType[tc].type->get());
-        llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(gIR->irDsymbol[sd].irStruct->init, initpt);
+        size_t cisize = getTypeStoreSize(tc->ir.type->get());
+        llvm::Constant* cicast = llvm::ConstantExpr::getBitCast(sd->ir.irStruct->init, initpt);
         sinits.push_back(DtoConstSlice(DtoConstSize_t(cisize), cicast));
     }
 
@@ -925,8 +925,8 @@
         fd = fdx->overloadExactMatch(tftohash);
         if (fd) {
             DtoForceDeclareDsymbol(fd);
-            assert(gIR->irDsymbol[fd].irFunc->func != 0);
-            llvm::Constant* c = isaConstant(gIR->irDsymbol[fd].irFunc->func);
+            assert(fd->ir.irFunc->func != 0);
+            llvm::Constant* c = isaConstant(fd->ir.irFunc->func);
             assert(c);
             c = llvm::ConstantExpr::getBitCast(c, ptty);
             sinits.push_back(c);
@@ -951,8 +951,8 @@
             fd = fdx->overloadExactMatch(tfeqptr);
             if (fd) {
                 DtoForceDeclareDsymbol(fd);
-                assert(gIR->irDsymbol[fd].irFunc->func != 0);
-                llvm::Constant* c = isaConstant(gIR->irDsymbol[fd].irFunc->func);
+                assert(fd->ir.irFunc->func != 0);
+                llvm::Constant* c = isaConstant(fd->ir.irFunc->func);
                 assert(c);
                 c = llvm::ConstantExpr::getBitCast(c, ptty);
                 sinits.push_back(c);
@@ -979,8 +979,8 @@
         fd = fdx->overloadExactMatch(tftostring);
         if (fd) {
             DtoForceDeclareDsymbol(fd);
-            assert(gIR->irDsymbol[fd].irFunc->func != 0);
-            llvm::Constant* c = isaConstant(gIR->irDsymbol[fd].irFunc->func);
+            assert(fd->ir.irFunc->func != 0);
+            llvm::Constant* c = isaConstant(fd->ir.irFunc->func);
             assert(c);
             c = llvm::ConstantExpr::getBitCast(c, ptty);
             sinits.push_back(c);
@@ -1001,7 +1001,7 @@
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
     llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module);
 
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoStructDeclaration::toDt(dt_t **pdt)
@@ -1022,10 +1022,10 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoClassDeclaration::llvmDefine()
@@ -1039,12 +1039,12 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<llvm::Constant*> sinits;
     // first is always the vtable
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -1053,12 +1053,12 @@
     assert(tinfo->ty == Tclass);
     TypeClass *tc = (TypeClass *)tinfo;
     DtoForceDeclareDsymbol(tc->sym);
-    assert(gIR->irDsymbol[tc->sym].irStruct->classInfo);
-    sinits.push_back(gIR->irDsymbol[tc->sym].irStruct->classInfo);
+    assert(tc->sym->ir.irStruct->classInfo);
+    sinits.push_back(tc->sym->ir.irStruct->classInfo);
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoClassDeclaration::toDt(dt_t **pdt)
@@ -1079,10 +1079,10 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoInterfaceDeclaration::llvmDefine()
@@ -1096,12 +1096,12 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<llvm::Constant*> sinits;
     // first is always the vtable
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -1109,12 +1109,12 @@
     // get classinfo
     assert(tinfo->ty == Tclass);
     TypeClass *tc = (TypeClass *)tinfo;
-    assert(gIR->irDsymbol[tc->sym].irStruct->classInfo);
-    sinits.push_back(gIR->irDsymbol[tc->sym].irStruct->classInfo);
+    assert(tc->sym->ir.irStruct->classInfo);
+    sinits.push_back(tc->sym->ir.irStruct->classInfo);
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoInterfaceDeclaration::toDt(dt_t **pdt)
@@ -1135,10 +1135,10 @@
     DtoResolveClass(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // create the symbol
-    gIR->irDsymbol[this].irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
+    this->ir.irGlobal->value = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,NULL,toChars(),gIR->module);
 }
 
 void TypeInfoTupleDeclaration::llvmDefine()
@@ -1152,12 +1152,12 @@
     DtoForceConstInitDsymbol(base);
 
     // get type of typeinfo class
-    const llvm::StructType* stype = isaStruct(gIR->irType[base->type].type->get());
+    const llvm::StructType* stype = isaStruct(base->type->ir.type->get());
 
     // initializer vector
     std::vector<llvm::Constant*> sinits;
     // first is always the vtable
-    sinits.push_back(gIR->irDsymbol[base].irStruct->vtbl);
+    sinits.push_back(base->ir.irStruct->vtbl);
 
     // monitor
     sinits.push_back(llvm::ConstantPointerNull::get(getPtrToType(llvm::Type::Int8Ty)));
@@ -1169,7 +1169,7 @@
     size_t dim = tu->arguments->dim;
     std::vector<llvm::Constant*> arrInits;
 
-    const llvm::Type* tiTy = gIR->irType[Type::typeinfo->type].type->get();
+    const llvm::Type* tiTy = Type::typeinfo->type->ir.type->get();
     tiTy = getPtrToType(tiTy);
 
     for (size_t i = 0; i < dim; i++)
@@ -1177,8 +1177,8 @@
         Argument *arg = (Argument *)tu->arguments->data[i];
         arg->type->getTypeInfo(NULL);
         DtoForceDeclareDsymbol(arg->type->vtinfo);
-        assert(gIR->irDsymbol[arg->type->vtinfo].irGlobal->value);
-        llvm::Constant* c = isaConstant(gIR->irDsymbol[arg->type->vtinfo].irGlobal->value);
+        assert(arg->type->vtinfo->ir.irGlobal->value);
+        llvm::Constant* c = isaConstant(arg->type->vtinfo->ir.irGlobal->value);
         c = llvm::ConstantExpr::getBitCast(c, tiTy);
         arrInits.push_back(c);
     }
@@ -1193,7 +1193,7 @@
 
     // create the symbol
     llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits);
-    isaGlobalVar(gIR->irDsymbol[this].irGlobal->value)->setInitializer(tiInit);
+    isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit);
 }
 
 void TypeInfoTupleDeclaration::toDt(dt_t **pdt)
--- a/ir/irstruct.cpp	Tue May 06 07:26:27 2008 +0200
+++ b/ir/irstruct.cpp	Tue May 06 07:56:03 2008 +0200
@@ -27,7 +27,7 @@
 //////////////////////////////////////////////////////////////////////////////
 
 IrStruct::IrStruct(Type* t)
- : recty((gIR && gIR->irType[t].type) ? *gIR->irType[t].type : llvm::OpaqueType::get())
+ : recty((t->ir.type) ? *t->ir.type : llvm::OpaqueType::get())
 {
     type = t;
     defined = false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ir/irsymbol.cpp	Tue May 06 07:56:03 2008 +0200
@@ -0,0 +1,60 @@
+#include "gen/llvm.h"
+#include "ir/ir.h"
+#include "ir/irsymbol.h"
+#include "ir/irvar.h"
+
+std::set<IrDsymbol*> IrDsymbol::list;
+
+void IrDsymbol::resetAll()
+{
+    std::set<IrDsymbol*>::iterator it;
+    for(it = list.begin(); it != list.end(); ++it)
+        (*it)->reset();
+}
+
+IrDsymbol::IrDsymbol()
+{
+    list.insert(this);
+    reset();
+}
+
+IrDsymbol::IrDsymbol(const IrDsymbol& s)
+{
+    list.insert(this);
+    DModule = s.DModule;
+    irModule = s.irModule;
+    irStruct = s.irStruct;
+    irFunc = s.irFunc;
+    resolved = s.resolved;
+    declared = s.declared;
+    initialized = s.initialized;
+    defined = s.defined;
+    irGlobal = s.irGlobal;
+    irLocal = s.irLocal;
+    irField = s.irField;
+}
+
+IrDsymbol::~IrDsymbol()
+{
+    list.erase(this);
+}
+
+void IrDsymbol::reset()
+{
+    DModule = NULL;
+    irModule = NULL;
+    irStruct = NULL;
+    irFunc = NULL;
+    resolved = declared = initialized = defined = false;
+    irGlobal = NULL;
+    irLocal = NULL;
+    irField = NULL;
+}
+
+IrVar* IrDsymbol::getIrVar()
+{
+    assert(irGlobal || irLocal || irField);
+    return irGlobal ? (IrVar*)irGlobal : irLocal ? (IrVar*)irLocal : (IrVar*)irField;
+}
+
+llvm::Value*& IrDsymbol::getIrValue() { return getIrVar()->value; }
--- a/ir/irsymbol.h	Tue May 06 07:26:27 2008 +0200
+++ b/ir/irsymbol.h	Tue May 06 07:56:03 2008 +0200
@@ -1,7 +1,7 @@
 #ifndef LLVMDC_IR_IRSYMBOL_H
 #define LLVMDC_IR_IRSYMBOL_H
 
-#include "ir/ir.h"
+#include <set>
 
 struct IrModule;
 struct IrFunction;
@@ -10,9 +10,25 @@
 struct IrLocal;
 struct IrField;
 struct IrVar;
+struct Dsymbol;
+
+namespace llvm {
+    struct Value;
+}
 
 struct IrDsymbol
 {
+    static std::set<IrDsymbol*> list;
+    static void resetAll();
+
+    // overload all of these to make sure
+    // the static list is up to date
+    IrDsymbol();
+    IrDsymbol(const IrDsymbol& s);
+    ~IrDsymbol();
+
+    void reset();
+
     Module* DModule;
 
     bool resolved;
@@ -29,12 +45,8 @@
     IrGlobal* irGlobal;
     IrLocal* irLocal;
     IrField* irField;
-    IrVar* getIrVar()
-    {
-        assert(irGlobal || irLocal || irField);
-        return irGlobal ? (IrVar*)irGlobal : irLocal ? (IrVar*)irLocal : (IrVar*)irField;
-    }
-    llvm::Value*& getIrValue() { return getIrVar()->value; }
+    IrVar* getIrVar();
+    llvm::Value*& getIrValue();
 };
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ir/irtype.cpp	Tue May 06 07:56:03 2008 +0200
@@ -0,0 +1,36 @@
+#include "gen/llvm.h"
+#include "ir/ir.h"
+#include "ir/irtype.h"
+
+std::set<IrType*> IrType::list;
+
+void IrType::resetAll()
+{
+    std::set<IrType*>::iterator it;
+    for(it = list.begin(); it != list.end(); ++it)
+        (*it)->reset();
+}
+
+IrType::IrType()
+{
+    list.insert(this);
+    reset();
+}
+
+IrType::IrType(const IrType& s)
+{
+    list.insert(this);
+    type = s.type;
+    vtblType = s.type;
+}
+
+IrType::~IrType()
+{
+    list.erase(this);
+}
+
+void IrType::reset()
+{
+    type = NULL;
+    vtblType = NULL;
+}
--- a/ir/irtype.h	Tue May 06 07:26:27 2008 +0200
+++ b/ir/irtype.h	Tue May 06 07:56:03 2008 +0200
@@ -1,7 +1,7 @@
 #ifndef LLVMDC_IR_IRTYPE_H
 #define LLVMDC_IR_IRTYPE_H
 
-#include "ir/ir.h"
+#include <set>
 
 namespace llvm {
     class PATypeHolder;
@@ -9,6 +9,17 @@
 
 struct IrType
 {
+    static std::set<IrType*> list;
+    static void resetAll();
+
+    // overload all of these to make sure
+    // the static list is up to date
+    IrType();
+    IrType(const IrType& s);
+    ~IrType();
+
+    void reset();
+
     llvm::PATypeHolder* type;
     llvm::PATypeHolder* vtblType;
 };