From 128459b85b59530e511ea17b3cc3a5b8ee3e8bd4 Mon Sep 17 00:00:00 2001
From: Devang Patel <dpatel@apple.com>
Date: Mon, 24 Sep 2007 20:02:42 +0000
Subject:  Do not promote null values because it may be unsafe to do so.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42270 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Transforms/Scalar/LICM.cpp | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'lib/Transforms/Scalar/LICM.cpp')

diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index 3058f74..f112ba8 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -800,6 +800,10 @@ void LICM::FindPromotableValuesInLoop(
           break;
         }
 
+      // Do not promote null values because it may be unsafe to do so.
+      if (isa<ConstantPointerNull>(V))
+        PointerOk = false;
+
       if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V)) {
         // If GEP base is NULL then the calculated address used by Store or
         // Load instruction is invalid. Do not promote this value because
-- 
cgit v1.1