[SCCP] Turn loads of null into undef instead of zero initialized values
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 1 Jul 2015 05:37:57 +0000 (05:37 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 1 Jul 2015 05:37:57 +0000 (05:37 +0000)
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.

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

lib/Transforms/Scalar/SCCP.cpp
test/Transforms/SCCP/crash.ll

index bc068f78c5765300e688684ad4e3554cb8a1ab0e..305175ff8f73c85a84183d137c872a09a6655ae3 100644 (file)
@@ -1055,7 +1055,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) {
 
   // 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 88528902d721008501c31033d64cb221ea58e8f3..3ec1fd21745e340ea35a59b1b6c0b2b45db86280 100644 (file)
@@ -27,3 +27,8 @@ define i32 @test2([4 x i32] %A) {
   %B = extractvalue [4 x i32] %A, 1
   ret i32 %B
 }
+
+define x86_mmx @test3() {
+  %load = load x86_mmx, x86_mmx* null
+  ret x86_mmx %load
+}