diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-07-04 20:09:24 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-07-04 20:09:24 +0000 | 
| commit | b41932d54e590b3ce95d9fddd81046f682ee724d (patch) | |
| tree | d3e44621da76bc545e16ec20f33a113e2c83d0b4 | |
| parent | 5f4899dbfe37eba1c460b27b761bd457cfadd508 (diff) | |
Notes
| -rw-r--r-- | contrib/llvm/patches/patch-10-llvm-r241142-r241143-mmx-undef.diff | 88 | 
1 files changed, 88 insertions, 0 deletions
diff --git a/contrib/llvm/patches/patch-10-llvm-r241142-r241143-mmx-undef.diff b/contrib/llvm/patches/patch-10-llvm-r241142-r241143-mmx-undef.diff new file mode 100644 index 000000000000..1750e7438954 --- /dev/null +++ b/contrib/llvm/patches/patch-10-llvm-r241142-r241143-mmx-undef.diff @@ -0,0 +1,88 @@ +Pull in r241142 from upstream llvm trunk (by David Majnemer): + +  [SCCP] Turn loads of null into undef instead of zero initialized values + +  Surprisingly, this is a correctness issue: the mmx type exists for +  calling convention purposes, LLVM doesn't have a zero representation for +  them. + +  This partially fixes PR23999. + +Pull in r241143 from upstream llvm trunk (by David Majnemer): + +  [LoopUnroll] Use undef for phis with no value live + +  We would create a phi node with a zero initialized operand instead of +  undef in the case where no value was originally available.  This was +  problematic for x86_mmx which has no null value. + +These fix a "Cannot create a null constant of that type!" error when +compiling the graphics/sdl2_gfx port with MMX enabled. + +Introduced here: http://svnweb.freebsd.org/changeset/base/285149 + +Index: lib/Transforms/Scalar/SCCP.cpp +=================================================================== +--- lib/Transforms/Scalar/SCCP.cpp ++++ lib/Transforms/Scalar/SCCP.cpp +@@ -1054,7 +1054,7 @@ +  +   // load null -> null +   if (isa<ConstantPointerNull>(Ptr) && I.getPointerAddressSpace() == 0) +-    return markConstant(IV, &I, Constant::getNullValue(I.getType())); ++    return markConstant(IV, &I, UndefValue::get(I.getType())); +  +   // Transform load (constant global) into the value loaded. +   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) { +Index: lib/Transforms/Utils/LoopUnrollRuntime.cpp +=================================================================== +--- lib/Transforms/Utils/LoopUnrollRuntime.cpp ++++ lib/Transforms/Utils/LoopUnrollRuntime.cpp +@@ -81,7 +81,7 @@ +       if (L->contains(PN)) { +         NewPN->addIncoming(PN->getIncomingValueForBlock(NewPH), OrigPH); +       } else { +-        NewPN->addIncoming(Constant::getNullValue(PN->getType()), OrigPH); ++        NewPN->addIncoming(UndefValue::get(PN->getType()), OrigPH); +       } +  +       Value *V = PN->getIncomingValueForBlock(Latch); +Index: test/Transforms/LoopUnroll/X86/mmx.ll +=================================================================== +--- test/Transforms/LoopUnroll/X86/mmx.ll ++++ test/Transforms/LoopUnroll/X86/mmx.ll +@@ -0,0 +1,21 @@ ++; RUN: opt < %s -S -loop-unroll | FileCheck %s ++target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" ++target triple = "x86_64-unknown-linux-gnu" ++ ++define x86_mmx @f() #0 { ++entry: ++  br label %for.body ++ ++for.body:                                         ; preds = %for.body, %entry ++  %phi = phi i32 [ 1, %entry ], [ %add, %for.body ] ++  %add = add i32 %phi, 1 ++  %cmp = icmp eq i32 %phi, 0 ++  br i1 %cmp, label %exit, label %for.body ++ ++exit:                                             ; preds = %for.body ++  %ret = phi x86_mmx [ undef, %for.body ] ++  ; CHECK: ret x86_mmx %ret ++  ret x86_mmx %ret ++} ++ ++attributes #0 = { "target-cpu"="x86-64" } +Index: test/Transforms/SCCP/crash.ll +=================================================================== +--- test/Transforms/SCCP/crash.ll ++++ test/Transforms/SCCP/crash.ll +@@ -27,3 +27,8 @@ +   %B = extractvalue [4 x i32] %A, 1 +   ret i32 %B + } ++ ++define x86_mmx @test3() { ++  %load = load x86_mmx* null ++  ret x86_mmx %load ++}  | 
