diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3179,6 +3179,10 @@ 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/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp --- a/llvm/unittests/Analysis/ValueTrackingTest.cpp +++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp @@ -810,7 +810,7 @@ "i16* inttoptr (i96 -1 to i16*)", }, { - "i8 0", + "i8 undef", "[0 x i8] zeroinitializer", }, { @@ -818,7 +818,7 @@ "[0 x i8] undef", }, { - "i8 0", + "i8 undef", "[5 x [0 x i8]] zeroinitializer", }, { @@ -900,7 +900,7 @@ "[2 x i16] [i16 -21836, i16 -21846]]", }, { - "i8 0", + "i8 undef", "{ } zeroinitializer", }, { @@ -908,7 +908,7 @@ "{ } undef", }, { - "i8 0", + "i8 undef", "{ {}, {} } zeroinitializer", }, {