+ if (!dontIgnore) // Don't ignore nonignorables!
+ if (D->getType() == Type::VoidTy || // Ignore void type nodes
+ (IgnoreNamedNodes && // Ignore named and constants
+ (D->hasName() || isa<Constant>(D)) && !isa<Type>(D))) {
+ SC_DEBUG("ignored value " << D << endl);
+ return -1; // We do need types unconditionally though
+ }
+
+ // If it's a type, make sure that all subtypes of the type are included...
+ if (const Type *TheTy = dyn_cast<const Type>(D)) {
+
+ // Insert the current type before any subtypes. This is important because
+ // recursive types elements are inserted in a bottom up order. Changing
+ // this here can break things. For example:
+ //
+ // global { \2 * } { { \2 }* null }
+ //
+ int ResultSlot;
+ if ((ResultSlot = getValSlot(TheTy)) == -1) {
+ ResultSlot = doInsertVal(TheTy);
+ SC_DEBUG(" Inserted type: " << TheTy->getDescription() << " slot=" <<
+ ResultSlot << endl);
+ }
+
+ // Loop over any contained types in the definition... in reverse depth first
+ // order. This assures that all of the leafs of a type are output before
+ // the type itself is. This also assures us that we will not hit infinite
+ // recursion on recursive types...
+ //
+ for (df_iterator<const Type*> I = df_begin(TheTy, true),
+ E = df_end(TheTy); I != E; ++I)
+ if (*I != TheTy) {
+ // If we haven't seen this sub type before, add it to our type table!
+ const Type *SubTy = *I;
+ if (getValSlot(SubTy) == -1) {
+ SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << endl);
+ int Slot = doInsertVal(SubTy);
+ SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() <<
+ " slot=" << Slot << endl);
+ }
+ }
+ return ResultSlot;
+ }
+
+ // Okay, everything is happy, actually insert the silly value now...
+ return doInsertVal(D);
+}
+