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`.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357808
91177308-0d34-0410-b5e6-
96231b3b80d8
void initializeX86AvoidSFBPassPass(PassRegistry &);
void initializeX86CallFrameOptimizationPass(PassRegistry &);
void initializeX86CmovConverterPassPass(PassRegistry &);
+void initializeX86ExpandPseudoPass(PassRegistry&);
void initializeX86CondBrFoldingPassPass(PassRegistry &);
void initializeX86DomainReassignmentPass(PassRegistry &);
void initializeX86ExecutionDomainFixPass(PassRegistry &);
using namespace llvm;
#define DEBUG_TYPE "x86-pseudo"
+#define X86_EXPAND_PSEUDO_NAME "X86 pseudo instruction expansion pass"
namespace {
class X86ExpandPseudo : public MachineFunctionPass {
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;
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);
initializeFixupLEAPassPass(PR);
initializeX86CallFrameOptimizationPass(PR);
initializeX86CmovConverterPassPass(PR);
+ initializeX86ExpandPseudoPass(PR);
initializeX86ExecutionDomainFixPass(PR);
initializeX86DomainReassignmentPass(PR);
initializeX86AvoidSFBPassPass(PR);
--- /dev/null
+#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
+
+...
--- /dev/null
+#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
+
+...