Index: lib/CodeGen/StackSlotColoring.cpp =================================================================== --- lib/CodeGen/StackSlotColoring.cpp +++ lib/CodeGen/StackSlotColoring.cpp @@ -79,6 +79,9 @@ // OrigSizes - Sizess of stack objects before coloring. SmallVector OrigSizes; + // OrigStackIDs - Identifier for stack memory type, before coloring. + SmallVector OrigStackIDs; + // AllColors - If index is set, it's a spill slot, i.e. color. // FIXME: This assumes PEI locate spill slot with smaller indices // closest to stack pointer / frame pointer. Therefore, smaller @@ -198,6 +201,7 @@ int LastFI = MFI->getObjectIndexEnd(); OrigAlignments.resize(LastFI); OrigSizes.resize(LastFI); + OrigStackIDs.resize(LastFI); AllColors.resize(LastFI); UsedColors.resize(LastFI); Assignments.resize(LastFI); @@ -223,6 +227,7 @@ SSIntervals.push_back(&li); OrigAlignments[FI] = MFI->getObjectAlignment(FI); OrigSizes[FI] = MFI->getObjectSize(FI); + OrigStackIDs[FI] = MFI->getStackID(FI); AllColors.set(FI); } DEBUG(dbgs() << '\n'); @@ -266,7 +271,7 @@ } } - if (Color != -1 && MFI->getStackID(Color) != MFI->getStackID(FI)) { + if (Color != -1 && MFI->getStackID(Color) != OrigStackIDs[FI]) { DEBUG(dbgs() << "cannot share FIs with different stack IDs\n"); Share = false; } @@ -286,13 +291,14 @@ // Change size and alignment of the allocated slot. If there are multiple // objects sharing the same slot, then make sure the size and alignment - // are large enough for all. + // are large enough for all. Also copy across the StackID. unsigned Align = OrigAlignments[FI]; if (!Share || Align > MFI->getObjectAlignment(Color)) MFI->setObjectAlignment(Color, Align); int64_t Size = OrigSizes[FI]; if (!Share || Size > MFI->getObjectSize(Color)) MFI->setObjectSize(Color, Size); + MFI->setStackID(Color, OrigStackIDs[FI]); return Color; } @@ -493,6 +499,7 @@ SSRefs.clear(); OrigAlignments.clear(); OrigSizes.clear(); + OrigStackIDs.clear(); AllColors.clear(); UsedColors.clear(); for (unsigned i = 0, e = Assignments.size(); i != e; ++i)