diff --git a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp --- a/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp @@ -1366,11 +1366,13 @@ void PPCFrameLowering::inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologMBB) const { - // TODO: Generate CFI instructions. bool isPPC64 = Subtarget.isPPC64(); const PPCTargetLowering &TLI = *Subtarget.getTargetLowering(); const PPCInstrInfo &TII = *Subtarget.getInstrInfo(); MachineFrameInfo &MFI = MF.getFrameInfo(); + MachineModuleInfo &MMI = MF.getMMI(); + const MCRegisterInfo *MRI = MMI.getContext().getRegisterInfo(); + const bool needsCFI = MF.needsFrameMoves() && !Subtarget.isAIXABI(); auto StackAllocMIPos = llvm::find_if(PrologMBB, [](MachineInstr &MI) { int Opc = MI.getOpcode(); return Opc == PPC::PROBED_STACKALLOC_64 || Opc == PPC::PROBED_STACKALLOC_32; @@ -1394,6 +1396,22 @@ // Initialize current frame pointer. const MCInstrDesc &CopyInst = TII.get(isPPC64 ? PPC::OR8 : PPC::OR); BuildMI(PrologMBB, {MI}, DL, CopyInst, FPReg).addReg(SPReg).addReg(SPReg); + // Subroutines to generate .cfi_* directives. + auto buildDefCFAReg = [&](MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, Register Reg) { + unsigned RegNum = MRI->getDwarfRegNum(Reg, true); + unsigned CFIIndex = MF.addFrameInst( + MCCFIInstruction::createDefCfaRegister(nullptr, RegNum)); + BuildMI(MBB, MBBI, DL, TII.get(TargetOpcode::CFI_INSTRUCTION)) + .addCFIIndex(CFIIndex); + }; + auto buildCFAOffset = [&](MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, int Offset) { + unsigned CFIIndex = MBB.getParent()->addFrameInst( + MCCFIInstruction::cfiDefCfaOffset(nullptr, Offset)); + BuildMI(MBB, MBBI, DL, TII.get(TargetOpcode::CFI_INSTRUCTION)) + .addCFIIndex(CFIIndex); + }; // Subroutine to determine if we can use the Imm as part of d-form. auto CanUseDForm = [](int64_t Imm) { return isInt<16>(Imm) && Imm % 4 == 0; }; // Subroutine to materialize the Imm into TempReg. @@ -1415,7 +1433,8 @@ // Subroutine to store frame pointer and decrease stack pointer by probe size. auto allocateAndProbe = [&](MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, int64_t NegSize, - Register NegSizeReg, bool UseDForm) { + Register NegSizeReg, bool UseDForm, + bool EmitCFI) { if (UseDForm) BuildMI(MBB, MBBI, DL, TII.get(isPPC64 ? PPC::STDU : PPC::STWU), SPReg) .addReg(FPReg) @@ -1426,7 +1445,13 @@ .addReg(FPReg) .addReg(SPReg) .addReg(NegSizeReg); + if (needsCFI && EmitCFI) { + // Presume using FPReg to calculate CFA. + buildCFAOffset(MBB, MBBI, 0); + } }; + // Use FPReg to calculate CFA. + buildDefCFAReg(PrologMBB, {MI}, FPReg); // For case HasBP && MaxAlign > 1, we have to align the SP by performing // SP = SP - SP % MaxAlign. if (HasBP && MaxAlign > 1) { @@ -1453,7 +1478,7 @@ if (!ResidualUseDForm) MaterializeImm(PrologMBB, {MI}, NegResidualSize, ScratchReg); allocateAndProbe(PrologMBB, {MI}, NegResidualSize, ScratchReg, - ResidualUseDForm); + ResidualUseDForm, true); } bool UseDForm = CanUseDForm(NegProbeSize); // If number of blocks is small, just probe them directly. @@ -1461,7 +1486,10 @@ if (!UseDForm) MaterializeImm(PrologMBB, {MI}, NegProbeSize, ScratchReg); for (int i = 0; i < NumBlocks; ++i) - allocateAndProbe(PrologMBB, {MI}, NegProbeSize, ScratchReg, UseDForm); + allocateAndProbe(PrologMBB, {MI}, NegProbeSize, ScratchReg, UseDForm, + true); + // Restore using SPReg to calculate CFA. + buildDefCFAReg(PrologMBB, {MI}, SPReg); } else { // Since CTR is a volatile register and current shrinkwrap implementation // won't choose an MBB in a loop as the PrologMBB, it's safe to synthesize a @@ -1481,7 +1509,7 @@ MF.insert(MBBInsertPoint, ExitMBB); // Synthesize the loop body. allocateAndProbe(*LoopMBB, LoopMBB->end(), NegProbeSize, ScratchReg, - UseDForm); + UseDForm, false); BuildMI(LoopMBB, DL, TII.get(isPPC64 ? PPC::BDNZ8 : PPC::BDNZ)) .addMBB(LoopMBB); LoopMBB->addSuccessor(ExitMBB); @@ -1492,6 +1520,8 @@ PrologMBB.end()); ExitMBB->transferSuccessorsAndUpdatePHIs(&PrologMBB); PrologMBB.addSuccessor(LoopMBB); + // Restore using SPReg to calculate CFA. + buildDefCFAReg(*ExitMBB, ExitMBB->begin(), SPReg); // Update liveins. recomputeLiveIns(*LoopMBB); recomputeLiveIns(*ExitMBB); diff --git a/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll b/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll --- a/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll +++ b/llvm/test/CodeGen/PowerPC/stack-clash-prologue.ll @@ -10,7 +10,7 @@ ; RUN: -check-prefix=CHECK-32 %s ; Free probe -define i8 @f0() #0 nounwind { +define i8 @f0() #0 { ; CHECK-LE-LABEL: f0: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: li r3, 3 @@ -28,6 +28,7 @@ ; CHECK-32-LABEL: f0: ; CHECK-32: # %bb.0: # %entry ; CHECK-32-NEXT: stwu r1, -80(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 80 ; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: lbz r3, 16(r1) @@ -41,10 +42,11 @@ ret i8 %c } -define i8 @f1() #0 "stack-probe-size"="0" nounwind { +define i8 @f1() #0 "stack-probe-size"="0" { ; CHECK-LE-LABEL: f1: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: mr r12, r1 +; CHECK-LE-NEXT: .cfi_def_cfa_register r12 ; CHECK-LE-NEXT: li r0, 259 ; CHECK-LE-NEXT: mtctr r0 ; CHECK-LE-NEXT: .LBB1_1: # %entry @@ -52,6 +54,8 @@ ; CHECK-LE-NEXT: stdu r12, -16(r1) ; CHECK-LE-NEXT: bdnz .LBB1_1 ; CHECK-LE-NEXT: # %bb.2: # %entry +; CHECK-LE-NEXT: .cfi_def_cfa_register r1 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 4144 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 48(r1) ; CHECK-LE-NEXT: lbz r3, 48(r1) @@ -61,6 +65,7 @@ ; CHECK-BE-LABEL: f1: ; CHECK-BE: # %bb.0: # %entry ; CHECK-BE-NEXT: mr r12, r1 +; CHECK-BE-NEXT: .cfi_def_cfa_register r12 ; CHECK-BE-NEXT: li r0, 260 ; CHECK-BE-NEXT: mtctr r0 ; CHECK-BE-NEXT: .LBB1_1: # %entry @@ -68,6 +73,8 @@ ; CHECK-BE-NEXT: stdu r12, -16(r1) ; CHECK-BE-NEXT: bdnz .LBB1_1 ; CHECK-BE-NEXT: # %bb.2: # %entry +; CHECK-BE-NEXT: .cfi_def_cfa_register r1 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 4160 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 64(r1) ; CHECK-BE-NEXT: lbz r3, 64(r1) @@ -77,6 +84,7 @@ ; CHECK-32-LABEL: f1: ; CHECK-32: # %bb.0: # %entry ; CHECK-32-NEXT: mr r12, r1 +; CHECK-32-NEXT: .cfi_def_cfa_register r12 ; CHECK-32-NEXT: li r0, 257 ; CHECK-32-NEXT: mtctr r0 ; CHECK-32-NEXT: .LBB1_1: # %entry @@ -84,10 +92,12 @@ ; CHECK-32-NEXT: stwu r12, -16(r1) ; CHECK-32-NEXT: bdnz .LBB1_1 ; CHECK-32-NEXT: # %bb.2: # %entry -; CHECK-32-NEXT: li r3, 3 +; CHECK-32-NEXT: .cfi_def_cfa_register r1 ; CHECK-32-NEXT: sub r0, r1, r12 -; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 4112 +; CHECK-32-NEXT: li r3, 3 +; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: lbz r3, 16(r1) ; CHECK-32-NEXT: addi r1, r1, 4112 ; CHECK-32-NEXT: blr @@ -99,11 +109,13 @@ ret i8 %c } -define i8 @f2() #0 nounwind { +define i8 @f2() #0 { ; CHECK-LE-LABEL: f2: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: mr r12, r1 +; CHECK-LE-NEXT: .cfi_def_cfa_register r12 ; CHECK-LE-NEXT: stdu r12, -48(r1) +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-LE-NEXT: li r0, 16 ; CHECK-LE-NEXT: mtctr r0 ; CHECK-LE-NEXT: .LBB2_1: # %entry @@ -111,6 +123,8 @@ ; CHECK-LE-NEXT: stdu r12, -4096(r1) ; CHECK-LE-NEXT: bdnz .LBB2_1 ; CHECK-LE-NEXT: # %bb.2: # %entry +; CHECK-LE-NEXT: .cfi_def_cfa_register r1 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 65584 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 48(r1) ; CHECK-LE-NEXT: lbz r3, 48(r1) @@ -120,7 +134,9 @@ ; CHECK-BE-LABEL: f2: ; CHECK-BE: # %bb.0: # %entry ; CHECK-BE-NEXT: mr r12, r1 +; CHECK-BE-NEXT: .cfi_def_cfa_register r12 ; CHECK-BE-NEXT: stdu r12, -64(r1) +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-BE-NEXT: li r0, 16 ; CHECK-BE-NEXT: mtctr r0 ; CHECK-BE-NEXT: .LBB2_1: # %entry @@ -128,6 +144,8 @@ ; CHECK-BE-NEXT: stdu r12, -4096(r1) ; CHECK-BE-NEXT: bdnz .LBB2_1 ; CHECK-BE-NEXT: # %bb.2: # %entry +; CHECK-BE-NEXT: .cfi_def_cfa_register r1 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 65600 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 64(r1) ; CHECK-BE-NEXT: lbz r3, 64(r1) @@ -137,7 +155,9 @@ ; CHECK-32-LABEL: f2: ; CHECK-32: # %bb.0: # %entry ; CHECK-32-NEXT: mr r12, r1 +; CHECK-32-NEXT: .cfi_def_cfa_register r12 ; CHECK-32-NEXT: stwu r12, -16(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 ; CHECK-32-NEXT: li r0, 16 ; CHECK-32-NEXT: mtctr r0 ; CHECK-32-NEXT: .LBB2_1: # %entry @@ -145,9 +165,11 @@ ; CHECK-32-NEXT: stwu r12, -4096(r1) ; CHECK-32-NEXT: bdnz .LBB2_1 ; CHECK-32-NEXT: # %bb.2: # %entry +; CHECK-32-NEXT: .cfi_def_cfa_register r1 ; CHECK-32-NEXT: sub r0, r1, r12 -; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 65552 +; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: mr r0, r31 ; CHECK-32-NEXT: lbz r3, 16(r1) @@ -163,13 +185,19 @@ ret i8 %c } -define i8 @f3() #0 "stack-probe-size"="32768" nounwind { +define i8 @f3() #0 "stack-probe-size"="32768" { ; CHECK-LE-LABEL: f3: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: mr r12, r1 +; CHECK-LE-NEXT: .cfi_def_cfa_register r12 ; CHECK-LE-NEXT: stdu r12, -48(r1) +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-LE-NEXT: stdu r12, -32768(r1) +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-LE-NEXT: stdu r12, -32768(r1) +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 +; CHECK-LE-NEXT: .cfi_def_cfa_register r1 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 65584 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 48(r1) ; CHECK-LE-NEXT: lbz r3, 48(r1) @@ -179,9 +207,15 @@ ; CHECK-BE-LABEL: f3: ; CHECK-BE: # %bb.0: # %entry ; CHECK-BE-NEXT: mr r12, r1 +; CHECK-BE-NEXT: .cfi_def_cfa_register r12 ; CHECK-BE-NEXT: stdu r12, -64(r1) +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-BE-NEXT: stdu r12, -32768(r1) +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-BE-NEXT: stdu r12, -32768(r1) +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 +; CHECK-BE-NEXT: .cfi_def_cfa_register r1 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 65600 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 64(r1) ; CHECK-BE-NEXT: lbz r3, 64(r1) @@ -191,12 +225,18 @@ ; CHECK-32-LABEL: f3: ; CHECK-32: # %bb.0: # %entry ; CHECK-32-NEXT: mr r12, r1 +; CHECK-32-NEXT: .cfi_def_cfa_register r12 ; CHECK-32-NEXT: stwu r12, -16(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 ; CHECK-32-NEXT: stwu r12, -32768(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 ; CHECK-32-NEXT: stwu r12, -32768(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 +; CHECK-32-NEXT: .cfi_def_cfa_register r1 ; CHECK-32-NEXT: sub r0, r1, r12 -; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 65552 +; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: mr r0, r31 ; CHECK-32-NEXT: lbz r3, 16(r1) @@ -213,12 +253,13 @@ } ; Same as f2, but without protection. -define i8 @f4() nounwind { +define i8 @f4() { ; CHECK-LE-LABEL: f4: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: lis r0, -2 ; CHECK-LE-NEXT: ori r0, r0, 65488 ; CHECK-LE-NEXT: stdux r1, r1, r0 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 65584 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 48(r1) ; CHECK-LE-NEXT: lbz r3, 48(r1) @@ -230,6 +271,7 @@ ; CHECK-BE-NEXT: lis r0, -2 ; CHECK-BE-NEXT: ori r0, r0, 65472 ; CHECK-BE-NEXT: stdux r1, r1, r0 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 65600 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 64(r1) ; CHECK-BE-NEXT: lbz r3, 64(r1) @@ -241,8 +283,9 @@ ; CHECK-32-NEXT: lis r0, -2 ; CHECK-32-NEXT: ori r0, r0, 65520 ; CHECK-32-NEXT: stwux r1, r1, r0 -; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 65552 +; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: mr r0, r31 ; CHECK-32-NEXT: lbz r3, 16(r1) @@ -258,11 +301,13 @@ ret i8 %c } -define i8 @f5() #0 "stack-probe-size"="65536" nounwind { +define i8 @f5() #0 "stack-probe-size"="65536" { ; CHECK-LE-LABEL: f5: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: mr r12, r1 +; CHECK-LE-NEXT: .cfi_def_cfa_register r12 ; CHECK-LE-NEXT: stdu r12, -48(r1) +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-LE-NEXT: li r0, 16 ; CHECK-LE-NEXT: mtctr r0 ; CHECK-LE-NEXT: lis r0, -1 @@ -272,6 +317,8 @@ ; CHECK-LE-NEXT: stdux r12, r1, r0 ; CHECK-LE-NEXT: bdnz .LBB5_1 ; CHECK-LE-NEXT: # %bb.2: # %entry +; CHECK-LE-NEXT: .cfi_def_cfa_register r1 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 1048624 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 48(r1) ; CHECK-LE-NEXT: lbz r3, 48(r1) @@ -281,7 +328,9 @@ ; CHECK-BE-LABEL: f5: ; CHECK-BE: # %bb.0: # %entry ; CHECK-BE-NEXT: mr r12, r1 +; CHECK-BE-NEXT: .cfi_def_cfa_register r12 ; CHECK-BE-NEXT: stdu r12, -64(r1) +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-BE-NEXT: li r0, 16 ; CHECK-BE-NEXT: mtctr r0 ; CHECK-BE-NEXT: lis r0, -1 @@ -291,6 +340,8 @@ ; CHECK-BE-NEXT: stdux r12, r1, r0 ; CHECK-BE-NEXT: bdnz .LBB5_1 ; CHECK-BE-NEXT: # %bb.2: # %entry +; CHECK-BE-NEXT: .cfi_def_cfa_register r1 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 1048640 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 64(r1) ; CHECK-BE-NEXT: lbz r3, 64(r1) @@ -300,7 +351,9 @@ ; CHECK-32-LABEL: f5: ; CHECK-32: # %bb.0: # %entry ; CHECK-32-NEXT: mr r12, r1 +; CHECK-32-NEXT: .cfi_def_cfa_register r12 ; CHECK-32-NEXT: stwu r12, -16(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 ; CHECK-32-NEXT: li r0, 16 ; CHECK-32-NEXT: mtctr r0 ; CHECK-32-NEXT: lis r0, -1 @@ -310,9 +363,11 @@ ; CHECK-32-NEXT: stwux r12, r1, r0 ; CHECK-32-NEXT: bdnz .LBB5_1 ; CHECK-32-NEXT: # %bb.2: # %entry +; CHECK-32-NEXT: .cfi_def_cfa_register r1 ; CHECK-32-NEXT: sub r0, r1, r12 -; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 1048592 +; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: mr r0, r31 ; CHECK-32-NEXT: lbz r3, 16(r1) @@ -328,11 +383,13 @@ ret i8 %c } -define i8 @f6() #0 nounwind { +define i8 @f6() #0 { ; CHECK-LE-LABEL: f6: ; CHECK-LE: # %bb.0: # %entry ; CHECK-LE-NEXT: mr r12, r1 +; CHECK-LE-NEXT: .cfi_def_cfa_register r12 ; CHECK-LE-NEXT: stdu r12, -48(r1) +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-LE-NEXT: lis r0, 4 ; CHECK-LE-NEXT: nop ; CHECK-LE-NEXT: mtctr r0 @@ -341,6 +398,8 @@ ; CHECK-LE-NEXT: stdu r12, -4096(r1) ; CHECK-LE-NEXT: bdnz .LBB6_1 ; CHECK-LE-NEXT: # %bb.2: # %entry +; CHECK-LE-NEXT: .cfi_def_cfa_register r1 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 1073741872 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 48(r1) ; CHECK-LE-NEXT: lbz r3, 48(r1) @@ -350,7 +409,9 @@ ; CHECK-BE-LABEL: f6: ; CHECK-BE: # %bb.0: # %entry ; CHECK-BE-NEXT: mr r12, r1 +; CHECK-BE-NEXT: .cfi_def_cfa_register r12 ; CHECK-BE-NEXT: stdu r12, -64(r1) +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-BE-NEXT: lis r0, 4 ; CHECK-BE-NEXT: nop ; CHECK-BE-NEXT: mtctr r0 @@ -359,6 +420,8 @@ ; CHECK-BE-NEXT: stdu r12, -4096(r1) ; CHECK-BE-NEXT: bdnz .LBB6_1 ; CHECK-BE-NEXT: # %bb.2: # %entry +; CHECK-BE-NEXT: .cfi_def_cfa_register r1 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 1073741888 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 64(r1) ; CHECK-BE-NEXT: lbz r3, 64(r1) @@ -368,7 +431,9 @@ ; CHECK-32-LABEL: f6: ; CHECK-32: # %bb.0: # %entry ; CHECK-32-NEXT: mr r12, r1 +; CHECK-32-NEXT: .cfi_def_cfa_register r12 ; CHECK-32-NEXT: stwu r12, -16(r1) +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 ; CHECK-32-NEXT: lis r0, 4 ; CHECK-32-NEXT: nop ; CHECK-32-NEXT: mtctr r0 @@ -377,9 +442,11 @@ ; CHECK-32-NEXT: stwu r12, -4096(r1) ; CHECK-32-NEXT: bdnz .LBB6_1 ; CHECK-32-NEXT: # %bb.2: # %entry +; CHECK-32-NEXT: .cfi_def_cfa_register r1 ; CHECK-32-NEXT: sub r0, r1, r12 -; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 1073741840 +; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 16(r1) ; CHECK-32-NEXT: mr r0, r31 ; CHECK-32-NEXT: lbz r3, 16(r1) @@ -395,13 +462,15 @@ ret i8 %c } -define i8 @f7() #0 "stack-probe-size"="65536" nounwind { +define i8 @f7() #0 "stack-probe-size"="65536" { ; CHECK-LE-LABEL: f7: ; CHECK-LE: # %bb.0: # %entry -; CHECK-LE-NEXT: lis r0, -1 ; CHECK-LE-NEXT: mr r12, r1 +; CHECK-LE-NEXT: .cfi_def_cfa_register r12 +; CHECK-LE-NEXT: lis r0, -1 ; CHECK-LE-NEXT: ori r0, r0, 13776 ; CHECK-LE-NEXT: stdux r12, r1, r0 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-LE-NEXT: li r0, 15258 ; CHECK-LE-NEXT: mtctr r0 ; CHECK-LE-NEXT: lis r0, -1 @@ -411,6 +480,8 @@ ; CHECK-LE-NEXT: stdux r12, r1, r0 ; CHECK-LE-NEXT: bdnz .LBB7_1 ; CHECK-LE-NEXT: # %bb.2: # %entry +; CHECK-LE-NEXT: .cfi_def_cfa_register r1 +; CHECK-LE-NEXT: .cfi_def_cfa_offset 1000000048 ; CHECK-LE-NEXT: li r3, 3 ; CHECK-LE-NEXT: stb r3, 41(r1) ; CHECK-LE-NEXT: lbz r3, 41(r1) @@ -419,10 +490,12 @@ ; ; CHECK-BE-LABEL: f7: ; CHECK-BE: # %bb.0: # %entry -; CHECK-BE-NEXT: lis r0, -1 ; CHECK-BE-NEXT: mr r12, r1 +; CHECK-BE-NEXT: .cfi_def_cfa_register r12 +; CHECK-BE-NEXT: lis r0, -1 ; CHECK-BE-NEXT: ori r0, r0, 13760 ; CHECK-BE-NEXT: stdux r12, r1, r0 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 0 ; CHECK-BE-NEXT: li r0, 15258 ; CHECK-BE-NEXT: mtctr r0 ; CHECK-BE-NEXT: lis r0, -1 @@ -432,6 +505,8 @@ ; CHECK-BE-NEXT: stdux r12, r1, r0 ; CHECK-BE-NEXT: bdnz .LBB7_1 ; CHECK-BE-NEXT: # %bb.2: # %entry +; CHECK-BE-NEXT: .cfi_def_cfa_register r1 +; CHECK-BE-NEXT: .cfi_def_cfa_offset 1000000064 ; CHECK-BE-NEXT: li r3, 3 ; CHECK-BE-NEXT: stb r3, 57(r1) ; CHECK-BE-NEXT: lbz r3, 57(r1) @@ -440,10 +515,12 @@ ; ; CHECK-32-LABEL: f7: ; CHECK-32: # %bb.0: # %entry -; CHECK-32-NEXT: lis r0, -1 ; CHECK-32-NEXT: mr r12, r1 +; CHECK-32-NEXT: .cfi_def_cfa_register r12 +; CHECK-32-NEXT: lis r0, -1 ; CHECK-32-NEXT: ori r0, r0, 13808 ; CHECK-32-NEXT: stwux r12, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 0 ; CHECK-32-NEXT: li r0, 15258 ; CHECK-32-NEXT: mtctr r0 ; CHECK-32-NEXT: lis r0, -1 @@ -453,9 +530,11 @@ ; CHECK-32-NEXT: stwux r12, r1, r0 ; CHECK-32-NEXT: bdnz .LBB7_1 ; CHECK-32-NEXT: # %bb.2: # %entry +; CHECK-32-NEXT: .cfi_def_cfa_register r1 ; CHECK-32-NEXT: sub r0, r1, r12 -; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: sub r0, r1, r0 +; CHECK-32-NEXT: .cfi_def_cfa_offset 1000000016 +; CHECK-32-NEXT: li r3, 3 ; CHECK-32-NEXT: stb r3, 9(r1) ; CHECK-32-NEXT: mr r0, r31 ; CHECK-32-NEXT: lbz r3, 9(r1)