From 284c49c36faea2f813f66d9ddf861a45a2a4c422 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 1 Jul 2015 05:37:57 +0000 Subject: [PATCH] [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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241142 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/SCCP.cpp | 2 +- test/Transforms/SCCP/crash.ll | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index bc068f78c57..305175ff8f7 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1055,7 +1055,7 @@ void SCCPSolver::visitLoadInst(LoadInst &I) { // load null -> null if (isa(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(Ptr)) { diff --git a/test/Transforms/SCCP/crash.ll b/test/Transforms/SCCP/crash.ll index 88528902d72..3ec1fd21745 100644 --- a/test/Transforms/SCCP/crash.ll +++ b/test/Transforms/SCCP/crash.ll @@ -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 +} -- 2.34.1