Skip to content

Commit 642f64f

Browse files
author
Davide Italiano
committed
[AliasAnalysis] Check for nullptr before dereferencing.
Fixes an undefined behaviour sanitizer bug. <rdar://problem/50641097>
1 parent 6e53336 commit 642f64f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/SILOptimizer/Analysis/AliasAnalysis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,10 @@ AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
580580
LLVM_DEBUG(llvm::dbgs() << "ALIAS ANALYSIS:\n V1: " << *V1
581581
<< " V2: " << *V2);
582582

583+
// If this is SILUndef, return may alias.
584+
if (!V1->getFunction())
585+
return AliasResult::MayAlias;
586+
583587
// Pass in both the TBAA types so we can perform typed access TBAA and the
584588
// actual types of V1, V2 so we can perform class based TBAA.
585589
if (!typesMayAlias(TBAAType1, TBAAType2, *V1->getFunction()))

0 commit comments

Comments
 (0)