summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2012-07-16 10:52:25 +0000
committerNadav Rotem <nadav.rotem@intel.com>2012-07-16 10:52:25 +0000
commit4968e45b9fe665a3bf98b03f46c5b3a7c3e51230 (patch)
treeb4ff5ef19912ba2e63a47c72516916006278d4f4 /llvm
parent263efd8f05fcfcc7a79568395fdd96ee778304be (diff)
downloadbcm5719-llvm-4968e45b9fe665a3bf98b03f46c5b3a7c3e51230.tar.gz
bcm5719-llvm-4968e45b9fe665a3bf98b03f46c5b3a7c3e51230.zip
Fix a bug in the 3-address conversion of LEA when one of the operands is an
undef virtual register. The problem is that ProcessImplicitDefs removes the definition of the register and marks all uses as undef. If we lose the undef marker then we get a register which has no def, is not marked as undef. The live interval analysis does not collect information for these virtual registers and we crash in later passes. Together with Michael Kuperstein <michael.m.kuperstein@intel.com> llvm-svn: 160260
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/X86/X86InstrInfo.cpp7
-rw-r--r--llvm/test/CodeGen/X86/2012-07-16-LeaUndef.ll16
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp
index 9f5f66e37c8..8ba31945058 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -2016,6 +2016,13 @@ X86InstrInfo::convertToThreeAddress(MachineFunction::iterator &MFI,
.addReg(Dest, RegState::Define |
getDeadRegState(isDead)),
Src, isKill, Src2, isKill2);
+
+ // Preserve undefness of the operands.
+ bool isUndef = MI->getOperand(1).isUndef();
+ bool isUndef2 = MI->getOperand(2).isUndef();
+ NewMI->getOperand(1).setIsUndef(isUndef);
+ NewMI->getOperand(3).setIsUndef(isUndef2);
+
if (LV && isKill2)
LV->replaceKillInstruction(Src2, MI, NewMI);
break;
diff --git a/llvm/test/CodeGen/X86/2012-07-16-LeaUndef.ll b/llvm/test/CodeGen/X86/2012-07-16-LeaUndef.ll
new file mode 100644
index 00000000000..9e5cbd2f337
--- /dev/null
+++ b/llvm/test/CodeGen/X86/2012-07-16-LeaUndef.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -march=x86-64 -mcpu=corei7
+
+define void @autogen_SD2543() {
+A:
+ %E83 = add i32 0, 1
+ %E820 = add i32 0, undef
+ br label %C
+C:
+ %B908 = add i32 %E83, %E820
+ store i32 %B908, i32* undef
+ %Sl2391 = select i1 undef, i32 undef, i32 %E83
+ %Cmp3114 = icmp ne i32 %Sl2391, undef
+ br i1 %Cmp3114, label %C, label %G
+G:
+ ret void
+}
OpenPOWER on IntegriCloud