diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-03-25 02:02:19 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-03-25 02:02:19 +0000 |
commit | a2fb634defce316ec972aa6f3ca3a941b4656f5e (patch) | |
tree | 6d48a84f82e76ea831e1a5f21a98a16d60b8c838 | |
parent | d804f8ff70e335c56aa6bc698f4c43cc00b6830c (diff) | |
download | llvm-a2fb634defce316ec972aa6f3ca3a941b4656f5e.tar.gz llvm-a2fb634defce316ec972aa6f3ca3a941b4656f5e.tar.bz2 llvm-a2fb634defce316ec972aa6f3ca3a941b4656f5e.tar.xz |
lastRegisterUse() should ignore identity copies. Those will be erased.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48759 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 21 | ||||
-rw-r--r-- | test/CodeGen/PowerPC/2008-03-24-CoalescerBug.ll | 30 |
2 files changed, 44 insertions, 7 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 6f5b523638..870fcc4408 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -1541,6 +1541,10 @@ SimpleRegisterCoalescing::lastRegisterUse(unsigned Start, unsigned End, E = mri_->use_end(); I != E; ++I) { MachineOperand &Use = I.getOperand(); MachineInstr *UseMI = Use.getParent(); + unsigned SrcReg, DstReg; + if (tii_->isMoveInstr(*UseMI, SrcReg, DstReg) && SrcReg == DstReg) + // Ignore identity copies. + continue; unsigned Idx = li_->getInstructionIndex(UseMI); if (Idx >= Start && Idx < End && Idx >= UseIdx) { LastUse = &Use; @@ -1562,14 +1566,17 @@ SimpleRegisterCoalescing::lastRegisterUse(unsigned Start, unsigned End, if (e < s || MI == NULL) return NULL; - for (unsigned i = 0, NumOps = MI->getNumOperands(); i != NumOps; ++i) { - MachineOperand &Use = MI->getOperand(i); - if (Use.isRegister() && Use.isUse() && Use.getReg() && - tri_->regsOverlap(Use.getReg(), Reg)) { - UseIdx = e; - return &Use; + // Ignore identity copies. + unsigned SrcReg, DstReg; + if (!(tii_->isMoveInstr(*MI, SrcReg, DstReg) && SrcReg == DstReg)) + for (unsigned i = 0, NumOps = MI->getNumOperands(); i != NumOps; ++i) { + MachineOperand &Use = MI->getOperand(i); + if (Use.isRegister() && Use.isUse() && Use.getReg() && + tri_->regsOverlap(Use.getReg(), Reg)) { + UseIdx = e; + return &Use; + } } - } e -= InstrSlots::NUM; } diff --git a/test/CodeGen/PowerPC/2008-03-24-CoalescerBug.ll b/test/CodeGen/PowerPC/2008-03-24-CoalescerBug.ll new file mode 100644 index 0000000000..67c167aca1 --- /dev/null +++ b/test/CodeGen/PowerPC/2008-03-24-CoalescerBug.ll @@ -0,0 +1,30 @@ +; RUN: llvm-as < %s | llc -march=ppc32 + + %struct..0objc_object = type { %struct.objc_class* } + %struct.NSArray = type { %struct..0objc_object } + %struct.NSMutableArray = type { %struct.NSArray } + %struct.PFTPersistentSymbols = type { %struct..0objc_object, %struct.VMUSymbolicator*, %struct.NSMutableArray*, %struct.__CFDictionary*, %struct.__CFDictionary*, %struct.__CFDictionary*, %struct.__CFDictionary*, %struct.NSMutableArray*, i8, %struct.pthread_mutex_t, %struct.NSMutableArray*, %struct.pthread_rwlock_t } + %struct.VMUMachTaskContainer = type { %struct..0objc_object, i32, i32 } + %struct.VMUSymbolicator = type { %struct..0objc_object, %struct.NSMutableArray*, %struct.NSArray*, %struct.NSArray*, %struct.VMUMachTaskContainer*, i8 } + %struct.__CFDictionary = type opaque + %struct.__builtin_CFString = type { i32*, i32, i8*, i32 } + %struct.objc_class = type opaque + %struct.objc_selector = type opaque + %struct.pthread_mutex_t = type { i32, [40 x i8] } + %struct.pthread_rwlock_t = type { i32, [124 x i8] } +external constant %struct.__builtin_CFString ; <%struct.__builtin_CFString*>:0 [#uses=1] + +define void @"-[PFTPersistentSymbols saveSymbolWithName:address:path:lineNumber:flags:owner:]"(%struct.PFTPersistentSymbols* %self, %struct.objc_selector* %_cmd, %struct.NSArray* %name, i64 %address, %struct.NSArray* %path, i32 %lineNumber, i64 %flags, %struct..0objc_object* %owner) nounwind { +entry: + br i1 false, label %bb12, label %bb21 +bb12: ; preds = %entry + %tmp17 = tail call i8 inttoptr (i64 4294901504 to i8 (%struct..0objc_object*, %struct.objc_selector*, %struct.NSArray*)*)( %struct..0objc_object* null, %struct.objc_selector* null, %struct.NSArray* bitcast (%struct.__builtin_CFString* @0 to %struct.NSArray*) ) signext nounwind ; <i8> [#uses=0] + br i1 false, label %bb25, label %bb21 +bb21: ; preds = %bb12, %entry + %tmp24 = or i64 %flags, 4 ; <i64> [#uses=1] + br label %bb25 +bb25: ; preds = %bb21, %bb12 + %flags_addr.0 = phi i64 [ %tmp24, %bb21 ], [ %flags, %bb12 ] ; <i64> [#uses=1] + %tmp3233 = trunc i64 %flags_addr.0 to i32 ; <i32> [#uses=0] + ret void +} |