llvm.org GIT mirror llvm / 4e68054
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141859 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
2 changed file(s) with 27 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
13351335 if (Is64Bit)
13361336 IsNested = HasNestArgument(&MF);
13371337
1338 // The MOV R10, RAX needs to be in a different block, since the RET we emit in
1339 // allocMBB needs to be last (terminating) instruction.
1340 MachineBasicBlock *restoreR10MBB = NULL;
1341 if (IsNested)
1342 restoreR10MBB = MF.CreateMachineBasicBlock();
1343
13381344 for (MachineBasicBlock::livein_iterator i = prologueMBB.livein_begin(),
13391345 e = prologueMBB.livein_end(); i != e; i++) {
13401346 allocMBB->addLiveIn(*i);
13411347 checkMBB->addLiveIn(*i);
1348
1349 if (IsNested)
1350 restoreR10MBB->addLiveIn(*i);
1351 }
1352
1353 if (IsNested) {
1354 allocMBB->addLiveIn(X86::R10);
1355 restoreR10MBB->addLiveIn(X86::RAX);
13421356 }
13431357
13441358 if (IsNested)
1345 allocMBB->addLiveIn(X86::R10);
1346
1359 MF.push_front(restoreR10MBB);
13471360 MF.push_front(allocMBB);
13481361 MF.push_front(checkMBB);
13491362
14131426 if (!Is64Bit)
14141427 BuildMI(allocMBB, DL, TII.get(X86::ADD32ri), X86::ESP).addReg(X86::ESP)
14151428 .addImm(8);
1416
1417 if (Is64Bit && IsNested)
1418 BuildMI(allocMBB, DL, TII.get(X86::MOV64rr), X86::R10).addReg(X86::RAX);
1419
14201429 BuildMI(allocMBB, DL, TII.get(X86::RET));
14211430
1422 allocMBB->addSuccessor(&prologueMBB);
1431 if (IsNested)
1432 BuildMI(restoreR10MBB, DL, TII.get(X86::MOV64rr), X86::R10)
1433 .addReg(X86::RAX);
1434
1435 if (IsNested) {
1436 allocMBB->addSuccessor(restoreR10MBB);
1437 restoreR10MBB->addSuccessor(&prologueMBB);
1438 } else {
1439 allocMBB->addSuccessor(&prologueMBB);
1440 }
1441
14231442 checkMBB->addSuccessor(allocMBB);
14241443 checkMBB->addSuccessor(&prologueMBB);
14251444
8080 ; X64-NEXT: movabsq $0, %r10
8181 ; X64-NEXT: movabsq $0, %r11
8282 ; X64-NEXT: callq __morestack
83 ; X64-NEXT: movq %rax, %r10
8483 ; X64-NEXT: ret
84 ; X64: movq %rax, %r10
8585
8686 }