From 55bc9b3f9ebf482936661e62894102e6bacd9f7e Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Tue, 22 Aug 2017 23:56:30 +0000 Subject: TargetInstrInfo: Change duplicate() to work on bundles. Adds infrastructure to clone whole instruction bundles rather than just single instructions. This fixes a bug where tail duplication would unbundle instructions while cloning. This should unbreak the "Clang Stage 1: cmake, RA, with expensive checks enabled" build on greendragon. The bot broke with r311139 hitting this pre-existing bug. A proper testcase will come next. llvm-svn: 311511 --- llvm/lib/CodeGen/MachineFunction.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'llvm/lib/CodeGen/MachineFunction.cpp') diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 742b095d955..c4c0dff7bdf 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -270,6 +270,26 @@ MachineFunction::CloneMachineInstr(const MachineInstr *Orig) { MachineInstr(*this, *Orig); } +MachineInstr &MachineFunction::CloneMachineInstrBundle(MachineBasicBlock &MBB, + MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) { + MachineInstr *FirstClone = nullptr; + MachineBasicBlock::const_instr_iterator I = Orig.getIterator(); + for (;;) { + MachineInstr *Cloned = CloneMachineInstr(&*I); + MBB.insert(InsertBefore, Cloned); + if (FirstClone == nullptr) { + FirstClone = Cloned; + } else { + Cloned->bundleWithPred(); + } + + if (!I->isBundledWithSucc()) + break; + ++I; + } + return *FirstClone; +} + /// Delete the given MachineInstr. /// /// This function also serves as the MachineInstr destructor - the real -- cgit v1.2.3