[llvm] r269750 - Factor PrologEpilogInserter around spilling, frame finalization, and scavenging

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Mon May 23 14:49:06 PDT 2016


Justin Bogner <mail at justinbogner.com> writes:
> Derek Schuff via llvm-commits <llvm-commits at lists.llvm.org> writes:
>> Author: dschuff
>> Date: Tue May 17 03:49:59 2016
>> New Revision: 269750
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=269750&view=rev
>> Log:
>> Factor PrologEpilogInserter around spilling, frame finalization, and
> scavenging
>>
>> PrologEpilogInserter has these 3 phases, which are related, but not
>> all of them are needed by all targets. This patch reorganizes PEI's
>> varous functions around those phases for more clear separation. It also
>> introduces a new TargetMachine hook, usesPhysRegsForPEI, which is true
>> for non-virtual targets. When it is true, all the phases operate as
>> before, and PEI requires the AllVRegsAllocated property on
>> MachineFunctions. Otherwise, CSR spilling and scavenging are skipped and
>> only prolog/epilog insertion/frame finalization is done.
...
>> /// AdjustStackOffset - Helper function used to adjust the stack
> frame offset.
>>  static inline void
>>  AdjustStackOffset(MachineFrameInfo *MFI, int FrameIdx,
>> @@ -604,8 +655,8 @@ void PEI::calculateFrameObjectOffsets(Ma
>>        MFI->setObjectOffset(i, -Offset);        // Set the computed offset
>>      }
>>    } else {
>> -    int MaxCSFI = MaxCSFrameIndex, MinCSFI = MinCSFrameIndex;
>> -    for (int i = MaxCSFI; i >= MinCSFI ; --i) {
>> +    unsigned MaxCSFI = MaxCSFrameIndex, MinCSFI = MinCSFrameIndex;
>> +    for (unsigned i = MaxCSFI; i >= MinCSFI; --i) {
>
> This doesn't work. When MinCSFI == 0 we'll wrap to UINT_MAX and get an
> infinite loop (well, an assert in getObjectAlignment). Presumably the
> way this was awkwardly doing this loop in a signed int was a cute way to
> avoid this previously.

I went ahead and fixed this in r270492.


More information about the llvm-commits mailing list