]> granicus.if.org Git - llvm/commitdiff
Return Undef from isBytewiseValue for empty arrays or structs
authorVitaly Buka <vitalybuka@google.com>
Fri, 12 Jul 2019 02:23:07 +0000 (02:23 +0000)
committerVitaly Buka <vitalybuka@google.com>
Fri, 12 Jul 2019 02:23:07 +0000 (02:23 +0000)
Reviewers: pcc, eugenis

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D64052

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

lib/Analysis/ValueTracking.cpp
unittests/Analysis/ValueTrackingTest.cpp

index 6857cf412edd0bc26fe1706094ed5002edc5e7ef..cf8fa9cee3fc8ea3af33f3fbce5633a654a4d19a 100644 (file)
@@ -3178,6 +3178,10 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) {
   if (isa<UndefValue>(V))
     return UndefInt8;
 
+  const uint64_t Size = DL.getTypeStoreSize(V->getType());
+  if (!Size)
+    return UndefInt8;
+
   Constant *C = dyn_cast<Constant>(V);
   if (!C) {
     // Conceptually, we could handle things like:
index 9f486e85759ac2097cedd8598223bca302927134..f4316cc8575c4b70520eb1869267e7d97dd7e941 100644 (file)
@@ -810,7 +810,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
         "i16* inttoptr (i96 -1 to i16*)",
     },
     {
-        "i8 0",
+        "i8 undef",
         "[0 x i8] zeroinitializer",
     },
     {
@@ -818,7 +818,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
         "[0 x i8] undef",
     },
     {
-        "i8 0",
+        "i8 undef",
         "[5 x [0 x i8]] zeroinitializer",
     },
     {
@@ -900,7 +900,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
         "[2 x i16] [i16 -21836, i16 -21846]]",
     },
     {
-        "i8 0",
+        "i8 undef",
         "{ } zeroinitializer",
     },
     {
@@ -908,7 +908,7 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
         "{ } undef",
     },
     {
-        "i8 0",
+        "i8 undef",
         "{ {}, {} } zeroinitializer",
     },
     {