Reset the virtual registers in liveins when clearing the virtual registers.
authorAlex Lorenz <arphaman@gmail.com>
Mon, 27 Jul 2015 17:51:59 +0000 (17:51 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Mon, 27 Jul 2015 17:51:59 +0000 (17:51 +0000)
This commit zeroes out the virtual register references in the machine
function's liveins in the class 'MachineRegisterInfo' when the virtual
register definitions are cleared.

Reviewers: Matthias Braun

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243290 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineRegisterInfo.cpp
test/CodeGen/X86/virtual-registers-cleared-in-machine-functions-liveins.ll [new file with mode: 0644]

index 5984af87a184204b2fb46d80efc61b0cf34ca901..d3704efb6318c8fe537281a3fb5e260521a8cb56 100644 (file)
@@ -116,6 +116,8 @@ void MachineRegisterInfo::clearVirtRegs() {
   }
 #endif
   VRegInfo.clear();
+  for (auto &I : LiveIns)
+    I.second = 0;
 }
 
 void MachineRegisterInfo::verifyUseList(unsigned Reg) const {
diff --git a/test/CodeGen/X86/virtual-registers-cleared-in-machine-functions-liveins.ll b/test/CodeGen/X86/virtual-registers-cleared-in-machine-functions-liveins.ll
new file mode 100644 (file)
index 0000000..544539e
--- /dev/null
@@ -0,0 +1,19 @@
+; RUN: llc -march=x86-64 -o /dev/null -stop-after machine-scheduler %s | FileCheck %s --check-prefix=PRE-RA
+; RUN: llc -march=x86-64 -o /dev/null -stop-after prologepilog %s | FileCheck %s --check-prefix=POST-RA
+
+; This test verifies that the virtual register references in machine function's
+; liveins are cleared after register allocation.
+
+define i32 @test(i32 %a, i32 %b) {
+body:
+  %c = mul i32 %a, %b
+  ret i32 %c
+}
+
+; PRE-RA: liveins:
+; PRE-RA-NEXT: - { reg: '%edi', virtual-reg: '%0' }
+; PRE-RA-NEXT: - { reg: '%esi', virtual-reg: '%1' }
+
+; POST-RA: liveins:
+; POST-RA-NEXT: - { reg: '%edi' }
+; POST-RA-NEXT: - { reg: '%esi' }