From: Vitaly Buka Date: Fri, 12 Jul 2019 02:23:07 +0000 (+0000) Subject: Return Undef from isBytewiseValue for empty arrays or structs X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d5f0ef04d5c863e60ada4d89d09d3204ecf6a4d;p=llvm Return Undef from isBytewiseValue for empty arrays or structs 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 --- diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 6857cf412ed..cf8fa9cee3f 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -3178,6 +3178,10 @@ Value *llvm::isBytewiseValue(Value *V, const DataLayout &DL) { if (isa(V)) return UndefInt8; + const uint64_t Size = DL.getTypeStoreSize(V->getType()); + if (!Size) + return UndefInt8; + Constant *C = dyn_cast(V); if (!C) { // Conceptually, we could handle things like: diff --git a/unittests/Analysis/ValueTrackingTest.cpp b/unittests/Analysis/ValueTrackingTest.cpp index 9f486e85759..f4316cc8575 100644 --- a/unittests/Analysis/ValueTrackingTest.cpp +++ b/unittests/Analysis/ValueTrackingTest.cpp @@ -810,7 +810,7 @@ const std::pair IsBytewiseValueTests[] = { "i16* inttoptr (i96 -1 to i16*)", }, { - "i8 0", + "i8 undef", "[0 x i8] zeroinitializer", }, { @@ -818,7 +818,7 @@ const std::pair IsBytewiseValueTests[] = { "[0 x i8] undef", }, { - "i8 0", + "i8 undef", "[5 x [0 x i8]] zeroinitializer", }, { @@ -900,7 +900,7 @@ const std::pair IsBytewiseValueTests[] = { "[2 x i16] [i16 -21836, i16 -21846]]", }, { - "i8 0", + "i8 undef", "{ } zeroinitializer", }, { @@ -908,7 +908,7 @@ const std::pair IsBytewiseValueTests[] = { "{ } undef", }, { - "i8 0", + "i8 undef", "{ {}, {} } zeroinitializer", }, {