Преглед изворни кода

[BranchFolding] Unique added live-ins after hoisting code.

We're not supposed to have duplicate live-ins.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281224 91177308-0d34-0410-b5e6-96231b3b80d8
Ahmed Bougacha пре 9 година
родитељ
комит
59a2759391
2 измењених фајлова са 8 додато и 1 уклоњено
  1. 7 0
      lib/CodeGen/BranchFolding.cpp
  2. 1 1
      test/CodeGen/X86/tail-call-conditional.mir

+ 7 - 0
lib/CodeGen/BranchFolding.cpp

@@ -1972,14 +1972,21 @@ bool BranchFolder::HoistCommonCodeInSuccs(MachineBasicBlock *MBB) {
   FBB->erase(FBB->begin(), FIB);
 
   // Update livein's.
+  bool AddedLiveIns = false;
   for (unsigned i = 0, e = LocalDefs.size(); i != e; ++i) {
     unsigned Def = LocalDefs[i];
     if (LocalDefsSet.count(Def)) {
       TBB->addLiveIn(Def);
       FBB->addLiveIn(Def);
+      AddedLiveIns = true;
     }
   }
 
+  if (AddedLiveIns) {
+    TBB->sortUniqueLiveIns();
+    FBB->sortUniqueLiveIns();
+  }
+
   ++NumHoist;
   return true;
 }

+ 1 - 1
test/CodeGen/X86/tail-call-conditional.mir

@@ -66,7 +66,7 @@ body:             |
     TCRETURNdi64 @f1, 0, csr_64, implicit %rsp, implicit %rdi, implicit %rsi
 
   ; CHECK: bb.2:
-  ; CHECK-NEXT: liveins: %rax, %rsi, %rdi, %rsi
+  ; CHECK-NEXT: liveins: %rax, %rdi, %rsi
   ; CHECK-NEXT: {{^  $}}
   ; CHECK-NEXT: TCRETURNdi64 @f2, 0, csr_64, implicit %rsp, implicit %rdi, implicit %rsi