Skip to content

Commit cd8efec

Browse files
committed
SIL Optimizer: check for SILUndef before constructing a ValueSet for a value
Fixes a crash, because SILUndef's function is null. rdar://97199428
1 parent 0e37a0e commit cd8efec

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/swift/SIL/NodeBits.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class NodeBitfield : public SILBitfield<NodeBitfield, SILNode> {
4343
template <class, class> friend class SILBitfield;
4444

4545
NodeBitfield *insertInto(SILFunction *function) {
46+
assert(function && "NodeBitField constructed with a null function");
4647
NodeBitfield *oldParent = function->newestAliveNodeBitfield;
4748
function->newestAliveNodeBitfield = this;
4849
return oldParent;

lib/SILOptimizer/Analysis/ValueTracking.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ bool swift::isExclusiveArgument(SILValue V) {
3838
/// Returns a found local object. If a local object was not found, returns an
3939
/// empty SILValue.
4040
static bool isLocalObject(SILValue Obj) {
41+
// Check for SILUndef.
42+
if (!Obj->getFunction())
43+
return false;
44+
4145
// Set of values to be checked for their locality.
4246
SmallVector<SILValue, 8> WorkList;
4347
// Set of processed values.

0 commit comments

Comments
 (0)