diff options
author | Andrew Trick <atrick@apple.com> | 2011-09-15 01:09:33 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2011-09-15 01:09:33 +0000 |
commit | b1afbac64b7c4c06959350acc175fb3552012f57 (patch) | |
tree | 20d54cdd0eba1c8071a9625fb4236f1eccdfa834 /lib/CodeGen | |
parent | 322ea080ada5608de41f82127f053f754e459910 (diff) | |
download | llvm-b1afbac64b7c4c06959350acc175fb3552012f57.tar.gz llvm-b1afbac64b7c4c06959350acc175fb3552012f57.tar.bz2 llvm-b1afbac64b7c4c06959350acc175fb3552012f57.tar.xz |
[regcoalescing] bug fix for RegistersDefinedFromSameValue.
An improper SlotIndex->VNInfo lookup was leading to unsafe copy removal.
Fixes PR10920 401.bzip2 miscompile with no IV rewrite.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/RegisterCoalescer.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp index 62d6306343..f3b8ae33c6 100644 --- a/lib/CodeGen/RegisterCoalescer.cpp +++ b/lib/CodeGen/RegisterCoalescer.cpp @@ -692,7 +692,7 @@ bool RegisterCoalescer::RemoveCopyByCommutingDef(const CoalescerPair &CP, // If some of the uses of IntA.reg is already coalesced away, return false. // It's not possible to determine whether it's safe to perform the coalescing. - for (MachineRegisterInfo::use_nodbg_iterator UI = + for (MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(IntA.reg), UE = MRI->use_nodbg_end(); UI != UE; ++UI) { MachineInstr *UseMI = &*UI; @@ -1370,6 +1370,7 @@ static unsigned ComputeUltimateVN(VNInfo *VNI, // which allows us to coalesce A and B. // VNI is the definition of B. LR is the life range of A that includes // the slot just before B. If we return true, we add "B = X" to DupCopies. +// This implies that A dominates B. static bool RegistersDefinedFromSameValue(LiveIntervals &li, const TargetRegisterInfo &tri, CoalescerPair &CP, @@ -1421,7 +1422,9 @@ static bool RegistersDefinedFromSameValue(LiveIntervals &li, // If the copies use two different value numbers of X, we cannot merge // A and B. LiveInterval &SrcInt = li.getInterval(Src); - if (SrcInt.getVNInfoAt(Other->def) != SrcInt.getVNInfoAt(VNI->def)) + // getVNInfoBefore returns NULL for undef copies. In this case, the + // optimization is still safe. + if (SrcInt.getVNInfoBefore(Other->def) != SrcInt.getVNInfoBefore(VNI->def)) return false; DupCopies.push_back(MI); |