summaryrefslogtreecommitdiff
path: root/lib/CodeGen/TwoAddressInstructionPass.cpp
diff options
context:
space:
mode:
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>2017-12-04 10:03:14 +0000
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>2017-12-04 10:03:14 +0000
commit62f11d908ed4e9b576d6769cfdbce3e215c40cd1 (patch)
tree83a165afbf0fd1bfdc18f21d614deb825540b199 /lib/CodeGen/TwoAddressInstructionPass.cpp
parent5022455191e0d386d601770f5ea936f6376d21f9 (diff)
[TwoAddressInstructionPass] Bugfix in handling of sunk instructions.
An instruction returned by TII->convertToThreeAddress() may contain a %noreg (undef) operand, which is not expected by tryInstructionTransform(). So if this MI is sunk to a lower point in MBB, it must be skipped when later encountered. A new set SunkInstrs is used for this purpose. Note: there is no test supplied here, as this was triggered on SystemZ while working on a review of instruction flags. A test case for this bugfix will be included in the upcoming SystemZ commit. Review: Quentin Colombet https://reviews.llvm.org/D40711 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319646 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r--lib/CodeGen/TwoAddressInstructionPass.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp
index b996850d706..28a4375cb28 100644
--- a/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -110,6 +110,10 @@ class TwoAddressInstructionPass : public MachineFunctionPass {
// Set of already processed instructions in the current block.
SmallPtrSet<MachineInstr*, 8> Processed;
+ // Set of instructions converted to three-address by target and then sunk
+ // down current basic block.
+ SmallPtrSet<MachineInstr*, 8> SunkInstrs;
+
// A map from virtual registers to physical registers which are likely targets
// to be coalesced to due to copies from physical registers to virtual
// registers. e.g. v1024 = move r0.
@@ -756,6 +760,8 @@ TwoAddressInstructionPass::convertInstTo3Addr(MachineBasicBlock::iterator &mi,
mi = NewMI;
nmi = std::next(mi);
}
+ else
+ SunkInstrs.insert(NewMI);
// Update source and destination register maps.
SrcRegMap.erase(RegA);
@@ -1674,10 +1680,13 @@ bool TwoAddressInstructionPass::runOnMachineFunction(MachineFunction &Func) {
SrcRegMap.clear();
DstRegMap.clear();
Processed.clear();
+ SunkInstrs.clear();
for (MachineBasicBlock::iterator mi = MBB->begin(), me = MBB->end();
mi != me; ) {
MachineBasicBlock::iterator nmi = std::next(mi);
- if (mi->isDebugValue()) {
+ // Don't revisit an instruction previously converted by target. It may
+ // contain undef register operands (%noreg), which are not handled.
+ if (mi->isDebugValue() || SunkInstrs.count(&*mi)) {
mi = nmi;
continue;
}