File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -332,7 +332,11 @@ class SILFunction
332
332
PerformanceConstraints perfConstraints = PerformanceConstraints::None;
333
333
334
334
// / This is the set of undef values we've created, for uniquing purposes.
335
- llvm::DenseMap<SILType, SILUndef *> undefValues;
335
+ // /
336
+ // / We use a SmallDenseMap since in most functions, we will have only one type
337
+ // / of undef if we have any at all. In that case, by staying small we avoid
338
+ // / needing a heap allocation.
339
+ llvm::SmallDenseMap<SILType, SILUndef *, 1 > undefValues;
336
340
337
341
// / This is the number of uses of this SILFunction inside the SIL.
338
342
// / It does not include references from debug scopes.
@@ -1563,6 +1567,12 @@ class SILFunction
1563
1567
// / This is a fast subset of the checks performed in the SILVerifier.
1564
1568
void verifyCriticalEdges () const ;
1565
1569
1570
+ // / Validate that all SILUndefs stored in the function's type -> SILUndef map
1571
+ // / have this function as their parent function.
1572
+ // /
1573
+ // / Please only call this from the SILVerifier.
1574
+ void verifySILUndefMap () const ;
1575
+
1566
1576
// / Pretty-print the SILFunction.
1567
1577
void dump (bool Verbose) const ;
1568
1578
void dump () const ;
Original file line number Diff line number Diff line change @@ -6902,6 +6902,11 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
6902
6902
" generic function definition must have a generic environment" );
6903
6903
}
6904
6904
6905
+ // Before verifying the body of the function, validate the SILUndef map to
6906
+ // make sure that all SILUndef in the function's map point at the function
6907
+ // as the SILUndef's parent.
6908
+ F->verifySILUndefMap ();
6909
+
6905
6910
// Otherwise, verify the body of the function.
6906
6911
verifyEntryBlock (F->getEntryBlock ());
6907
6912
verifyEpilogBlocks (F);
@@ -6974,6 +6979,15 @@ void SILFunction::verifyCriticalEdges() const {
6974
6979
/* checkLinearLifetime=*/ false ).verifyBranches (this );
6975
6980
}
6976
6981
6982
+ // / Validate that all SILUndef in \p f have f as a parent.
6983
+ void SILFunction::verifySILUndefMap () const {
6984
+ for (auto &pair : undefValues) {
6985
+ assert (
6986
+ pair.second ->getParent () == this &&
6987
+ " undef in f->undefValue map with different parent function than f?!" );
6988
+ }
6989
+ }
6990
+
6977
6991
// / Verify that a property descriptor follows invariants.
6978
6992
void SILProperty::verify (const SILModule &M) const {
6979
6993
if (!verificationEnabled (M))
You can’t perform that action at this time.
0 commit comments