[llvm-commits] [llvm] r141859 - in /llvm/trunk: lib/Target/X86/X86FrameLowering.cpp test/CodeGen/X86/segmented-stacks.ll
Bill Wendling
wendling at apple.com
Thu Oct 13 01:27:55 PDT 2011
Should have mentioned that the patch was by Sanjoy Das!
-bw
On Oct 13, 2011, at 1:24 AM, Bill Wendling wrote:
> Author: void
> Date: Thu Oct 13 03:24:19 2011
> New Revision: 141859
>
> URL: http://llvm.org/viewvc/llvm-project?rev=141859&view=rev
> Log:
> More closely follow libgcc, which has code after the `ret' instruction to
> release the stack segment and reset the stack pointer. Place the code in its own
> MBB to make the verifier happy.
>
> Modified:
> llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
> llvm/trunk/test/CodeGen/X86/segmented-stacks.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=141859&r1=141858&r2=141859&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Thu Oct 13 03:24:19 2011
> @@ -1336,15 +1336,28 @@
> if (Is64Bit)
> IsNested = HasNestArgument(&MF);
>
> + // The MOV R10, RAX needs to be in a different block, since the RET we emit in
> + // allocMBB needs to be last (terminating) instruction.
> + MachineBasicBlock *restoreR10MBB = NULL;
> + if (IsNested)
> + restoreR10MBB = MF.CreateMachineBasicBlock();
> +
> for (MachineBasicBlock::livein_iterator i = prologueMBB.livein_begin(),
> e = prologueMBB.livein_end(); i != e; i++) {
> allocMBB->addLiveIn(*i);
> checkMBB->addLiveIn(*i);
> +
> + if (IsNested)
> + restoreR10MBB->addLiveIn(*i);
> }
>
> - if (IsNested)
> + if (IsNested) {
> allocMBB->addLiveIn(X86::R10);
> + restoreR10MBB->addLiveIn(X86::RAX);
> + }
>
> + if (IsNested)
> + MF.push_front(restoreR10MBB);
> MF.push_front(allocMBB);
> MF.push_front(checkMBB);
>
> @@ -1414,13 +1427,19 @@
> if (!Is64Bit)
> BuildMI(allocMBB, DL, TII.get(X86::ADD32ri), X86::ESP).addReg(X86::ESP)
> .addImm(8);
> + BuildMI(allocMBB, DL, TII.get(X86::RET));
>
> - if (Is64Bit && IsNested)
> - BuildMI(allocMBB, DL, TII.get(X86::MOV64rr), X86::R10).addReg(X86::RAX);
> + if (IsNested)
> + BuildMI(restoreR10MBB, DL, TII.get(X86::MOV64rr), X86::R10)
> + .addReg(X86::RAX);
>
> - BuildMI(allocMBB, DL, TII.get(X86::RET));
> + if (IsNested) {
> + allocMBB->addSuccessor(restoreR10MBB);
> + restoreR10MBB->addSuccessor(&prologueMBB);
> + } else {
> + allocMBB->addSuccessor(&prologueMBB);
> + }
>
> - allocMBB->addSuccessor(&prologueMBB);
> checkMBB->addSuccessor(allocMBB);
> checkMBB->addSuccessor(&prologueMBB);
>
>
> Modified: llvm/trunk/test/CodeGen/X86/segmented-stacks.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/segmented-stacks.ll?rev=141859&r1=141858&r2=141859&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/segmented-stacks.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/segmented-stacks.ll Thu Oct 13 03:24:19 2011
> @@ -81,7 +81,7 @@
> ; X64-NEXT: movabsq $0, %r10
> ; X64-NEXT: movabsq $0, %r11
> ; X64-NEXT: callq __morestack
> -; X64-NEXT: movq %rax, %r10
> ; X64-NEXT: ret
> +; X64: movq %rax, %r10
>
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list