+/* Append ccs1 to ccs2 (ignoring any CAF cost centre at the root of ccs1 */
+
+#ifdef DEBUG
+CostCentreStack *_AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 );
+CostCentreStack *
+AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
+#define AppendCCS _AppendCCS
+{
+ CostCentreStack *ccs;
+ IF_DEBUG(prof,
+ fprintf(stderr,"Appending ");
+ printCCS(ccs1);
+ fprintf(stderr," to ");
+ printCCS(ccs2);
+ fprintf(stderr,"\n"));
+ return AppendCCS(ccs1,ccs2);
+}
+#endif
+
+CostCentreStack *
+AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 )
+{
+ CostCentreStack *ccs;
+
+ /* Optimisation: if we attempt to append a CCS to itself, we're
+ * going to end up with the same ccs after a great deal of pushing
+ * and removing of cost centres. Furthermore, we'll generate a lot
+ * of intermediate CCSs which would not otherwise be generated. So:
+ * let's cope with this common case first.
+ */
+ if (ccs1 == ccs2) {
+ return ccs1;
+ }
+
+ if (ccs2->cc->is_subsumed != CC_IS_BORING) {
+ return ccs1;
+ }
+
+ ASSERT(ccs2->prevStack != NULL);
+ ccs = AppendCCS(ccs1, ccs2->prevStack);
+ return PushCostCentre(ccs,ccs2->cc);
+}