diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index d6595d202bd8..b9a1010e46f9 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -519,7 +519,6 @@ static void doSpillCalleeSavedRegs(MachineFunction &Fn, RegScavenger *RS, const Function *F = Fn.getFunction(); const TargetFrameLowering *TFI = Fn.getSubtarget().getFrameLowering(); MachineFrameInfo &MFI = Fn.getFrameInfo(); - ArrayRef CSI = MFI.getCalleeSavedInfo(); MinCSFrameIndex = std::numeric_limits::max(); MaxCSFrameIndex = 0; @@ -534,6 +533,7 @@ static void doSpillCalleeSavedRegs(MachineFunction &Fn, RegScavenger *RS, if (!F->hasFnAttribute(Attribute::Naked)) { MFI.setCalleeSavedInfoValid(true); + ArrayRef CSI = MFI.getCalleeSavedInfo(); if (!CSI.empty()) { for (MachineBasicBlock *SaveBlock : SaveBlocks) { insertCSRSaves(*SaveBlock, CSI);