summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Constants.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-11-04 10:02:08 -0500
committerSanjay Patel <spatel@rotateright.com>2019-11-04 10:05:24 -0500
commitb556ce3992709e1f6302ca1d4c296f57e83cd6a7 (patch)
tree35b153b907c1e5f490b89fbda16c60cb21c8abb3 /llvm/lib/IR/Constants.cpp
parentd142ec6fef9a053c9fd9edb5a388203cdb121e65 (diff)
downloadbcm5719-llvm-b556ce3992709e1f6302ca1d4c296f57e83cd6a7.tar.gz
bcm5719-llvm-b556ce3992709e1f6302ca1d4c296f57e83cd6a7.zip
[IR] adjust assert when replacing undef elements in vector constant
As noted in follow-up to: rGa1e8ad4f2fa7 It's not safe to assume that an element of the constant is always non-null. It's definitely not an expected case for the current instcombine user, but that may not hold if this function is eventually called from arbitrary places.
Diffstat (limited to 'llvm/lib/IR/Constants.cpp')
-rw-r--r--llvm/lib/IR/Constants.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index eb40b291b00..a6a8eaac2f9 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -611,7 +611,7 @@ Constant *Constant::replaceUndefsWith(Constant *C, Constant *Replacement) {
SmallVector<Constant *, 32> NewC(NumElts);
for (unsigned i = 0; i != NumElts; ++i) {
Constant *EltC = C->getAggregateElement(i);
- assert(EltC->getType() == Replacement->getType() &&
+ assert((!EltC || EltC->getType() == Replacement->getType()) &&
"Expected matching types");
NewC[i] = EltC && match(EltC, m_Undef()) ? Replacement : EltC;
}
OpenPOWER on IntegriCloud