diff options
author | Quentin Colombet <qcolombet@apple.com> | 2015-03-30 21:50:44 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2015-03-30 21:50:44 +0000 |
commit | 6749ae36b4a33769e7a77cf812d7cd0a908ae3b9 (patch) | |
tree | ae26e24787adedb31d62adfeb58901a5243e7494 /llvm/lib | |
parent | c7ba53f9a9a7811553a0b2ec91a44436016b0eb2 (diff) | |
download | bcm5719-llvm-6749ae36b4a33769e7a77cf812d7cd0a908ae3b9.tar.gz bcm5719-llvm-6749ae36b4a33769e7a77cf812d7cd0a908ae3b9.zip |
[RegisterCoalescer] Fix a potential misuse of direct operand index in the
terminal rule.
Spot by code inspection.
llvm-svn: 233606
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/RegisterCoalescer.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index c04437e21df..5d958a61e6a 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -2731,9 +2731,9 @@ bool RegisterCoalescer::applyTerminalRule(const MachineInstr &Copy) const { assert(Copy.isCopyLike()); if (!UseTerminalRule) return false; + unsigned DstReg, DstSubReg, SrcReg, SrcSubReg; + isMoveInstr(*TRI, &Copy, SrcReg, DstReg, SrcSubReg, DstSubReg); // Check if the destination of this copy has any other affinity. - unsigned DstReg = Copy.getOperand(0).getReg(); - unsigned SrcReg = Copy.getOperand(1).getReg(); if (TargetRegisterInfo::isPhysicalRegister(DstReg) || // If SrcReg is a physical register, the copy won't be coalesced. // Ignoring it may have other side effect (like missing @@ -2755,9 +2755,11 @@ bool RegisterCoalescer::applyTerminalRule(const MachineInstr &Copy) const { // For now, just consider the copies that are in the same block. if (&MI == &Copy || !MI.isCopyLike() || MI.getParent() != OrigBB) continue; - unsigned OtherReg = MI.getOperand(0).getReg(); + unsigned OtherReg, OtherSubReg, OtherSrcReg, OtherSrcSubReg; + isMoveInstr(*TRI, &Copy, OtherSrcReg, OtherReg, OtherSrcSubReg, + OtherSubReg); if (OtherReg == SrcReg) - OtherReg = MI.getOperand(1).getReg(); + OtherReg = OtherSrcReg; // Check if OtherReg is a non-terminal. if (TargetRegisterInfo::isPhysicalRegister(OtherReg) || isTerminalReg(OtherReg, MI, MRI)) |