mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-01 07:11:45 +00:00
[X86] Preserve operand flag when expanding TCRETURNri
The expansion of TCRETURNri(64) would not keep operand flags like undef/renamable/etc. which can result in machine verifier issues. Also add plumbing to be able to use `-run-pass=x86-pseudo`. llvm-svn: 357808
This commit is contained in:
parent
2e999c9214
commit
c242d6bf4f
@ -136,6 +136,7 @@ void initializeWinEHStatePassPass(PassRegistry &);
|
||||
void initializeX86AvoidSFBPassPass(PassRegistry &);
|
||||
void initializeX86CallFrameOptimizationPass(PassRegistry &);
|
||||
void initializeX86CmovConverterPassPass(PassRegistry &);
|
||||
void initializeX86ExpandPseudoPass(PassRegistry&);
|
||||
void initializeX86CondBrFoldingPassPass(PassRegistry &);
|
||||
void initializeX86DomainReassignmentPass(PassRegistry &);
|
||||
void initializeX86ExecutionDomainFixPass(PassRegistry &);
|
||||
|
@ -26,6 +26,7 @@
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "x86-pseudo"
|
||||
#define X86_EXPAND_PSEUDO_NAME "X86 pseudo instruction expansion pass"
|
||||
|
||||
namespace {
|
||||
class X86ExpandPseudo : public MachineFunctionPass {
|
||||
@ -65,8 +66,12 @@ private:
|
||||
bool ExpandMBB(MachineBasicBlock &MBB);
|
||||
};
|
||||
char X86ExpandPseudo::ID = 0;
|
||||
|
||||
} // End anonymous namespace.
|
||||
|
||||
INITIALIZE_PASS(X86ExpandPseudo, DEBUG_TYPE, X86_EXPAND_PSEUDO_NAME, false,
|
||||
false)
|
||||
|
||||
void X86ExpandPseudo::ExpandICallBranchFunnel(
|
||||
MachineBasicBlock *MBB, MachineBasicBlock::iterator MBBI) {
|
||||
MachineBasicBlock *JTMBB = MBB;
|
||||
@ -253,12 +258,14 @@ bool X86ExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
|
||||
for (unsigned i = 0; i != 5; ++i)
|
||||
MIB.add(MBBI->getOperand(i));
|
||||
} else if (Opcode == X86::TCRETURNri64) {
|
||||
JumpTarget.setIsKill();
|
||||
BuildMI(MBB, MBBI, DL,
|
||||
TII->get(IsWin64 ? X86::TAILJMPr64_REX : X86::TAILJMPr64))
|
||||
.addReg(JumpTarget.getReg(), RegState::Kill);
|
||||
.add(JumpTarget);
|
||||
} else {
|
||||
JumpTarget.setIsKill();
|
||||
BuildMI(MBB, MBBI, DL, TII->get(X86::TAILJMPr))
|
||||
.addReg(JumpTarget.getReg(), RegState::Kill);
|
||||
.add(JumpTarget);
|
||||
}
|
||||
|
||||
MachineInstr &NewMI = *std::prev(MBBI);
|
||||
|
@ -71,6 +71,7 @@ extern "C" void LLVMInitializeX86Target() {
|
||||
initializeFixupLEAPassPass(PR);
|
||||
initializeX86CallFrameOptimizationPass(PR);
|
||||
initializeX86CmovConverterPassPass(PR);
|
||||
initializeX86ExpandPseudoPass(PR);
|
||||
initializeX86ExecutionDomainFixPass(PR);
|
||||
initializeX86DomainReassignmentPass(PR);
|
||||
initializeX86AvoidSFBPassPass(PR);
|
||||
|
10
test/CodeGen/X86/tailcall-pseudo-64.mir
Normal file
10
test/CodeGen/X86/tailcall-pseudo-64.mir
Normal file
@ -0,0 +1,10 @@
|
||||
#RUN: llc -verify-machineinstrs -mtriple=x86_64-apple-darwin -o - -run-pass=x86-pseudo %s | FileCheck %s
|
||||
---
|
||||
name: tail_call_fail_64
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0:
|
||||
TCRETURNri64 undef renamable $rax, 0, csr_64, implicit $rsp, implicit $ssp
|
||||
; CHECK: TAILJMPr64 killed undef renamable $rax, csr_64, implicit $rsp, implicit $ssp
|
||||
|
||||
...
|
10
test/CodeGen/X86/tailcall-pseudo.mir
Normal file
10
test/CodeGen/X86/tailcall-pseudo.mir
Normal file
@ -0,0 +1,10 @@
|
||||
#RUN: llc -verify-machineinstrs -mtriple=i386-apple-darwin -o - -run-pass=x86-pseudo %s | FileCheck %s
|
||||
---
|
||||
name: tail_call_fail
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0:
|
||||
TCRETURNri undef renamable $eax, 0, csr_32, implicit $esp, implicit $ssp
|
||||
; CHECK: TAILJMPr killed undef renamable $eax, csr_32, implicit $esp, implicit $ssp
|
||||
|
||||
...
|
Loading…
x
Reference in New Issue
Block a user