diff options
author | Matthias Braun <matze@braunis.de> | 2017-08-22 23:56:30 +0000 |
---|---|---|
committer | Matthias Braun <matze@braunis.de> | 2017-08-22 23:56:30 +0000 |
commit | 55bc9b3f9ebf482936661e62894102e6bacd9f7e (patch) | |
tree | 35faee00884c2e59f63f6d46ea1b655557b94af8 /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 35189d52218511153c6ad3a027599bb814818779 (diff) | |
download | bcm5719-llvm-55bc9b3f9ebf482936661e62894102e6bacd9f7e.tar.gz bcm5719-llvm-55bc9b3f9ebf482936661e62894102e6bacd9f7e.zip |
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
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
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 |