Skip to content

Commit

Permalink
Return Undef from isBytewiseValue for empty arrays or structs
Browse files Browse the repository at this point in the history
Reviewers: pcc, eugenis

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 365864
  • Loading branch information
vitalybuka committed Jul 12, 2019
1 parent 8bd441a commit 52096ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/ValueTracking.cpp
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/Analysis/ValueTrackingTest.cpp
Expand Up @@ -810,15 +810,15 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
"i16* inttoptr (i96 -1 to i16*)",
},
{
"i8 0",
"i8 undef",
"[0 x i8] zeroinitializer",
},
{
"i8 undef",
"[0 x i8] undef",
},
{
"i8 0",
"i8 undef",
"[5 x [0 x i8]] zeroinitializer",
},
{
Expand Down Expand Up @@ -900,15 +900,15 @@ const std::pair<const char *, const char *> IsBytewiseValueTests[] = {
"[2 x i16] [i16 -21836, i16 -21846]]",
},
{
"i8 0",
"i8 undef",
"{ } zeroinitializer",
},
{
"i8 undef",
"{ } undef",
},
{
"i8 0",
"i8 undef",
"{ {}, {} } zeroinitializer",
},
{
Expand Down

0 comments on commit 52096ee

Please sign in to comment.