Skip to content

Commit 3e84c5c

Browse files
committed
[NFC] SIL: Expose undef values.
1 parent 73b0ad3 commit 3e84c5c

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "swift/SIL/SILDeclRef.h"
2929
#include "swift/SIL/SILLinkage.h"
3030
#include "swift/SIL/SILPrintContext.h"
31+
#include "swift/SIL/SILUndef.h"
32+
#include "llvm/ADT/MapVector.h"
3133

3234
namespace swift {
3335

@@ -337,12 +339,8 @@ class SILFunction
337339

338340
PerformanceConstraints perfConstraints = PerformanceConstraints::None;
339341

340-
/// This is the set of undef values we've created, for uniquing purposes.
341-
///
342-
/// We use a SmallDenseMap since in most functions, we will have only one type
343-
/// of undef if we have any at all. In that case, by staying small we avoid
344-
/// needing a heap allocation.
345-
llvm::SmallDenseMap<SILType, SILUndef *, 1> undefValues;
342+
/// The undefs of each type in the function.
343+
llvm::SmallMapVector<SILType, SILUndef *, 1> undefValues;
346344

347345
/// This is the number of uses of this SILFunction inside the SIL.
348346
/// It does not include references from debug scopes.
@@ -1637,6 +1635,17 @@ class SILFunction
16371635
decl->getLifetimeAnnotation());
16381636
}
16391637

1638+
ArrayRef<std::pair<SILType, SILUndef *>> getUndefValues() {
1639+
return {undefValues.begin(), undefValues.end()};
1640+
}
1641+
1642+
void updateTypeForUndef(SILUndef *undef, SILType oldType) {
1643+
auto erased = undefValues.erase(oldType);
1644+
assert(erased == 1);
1645+
(void)erased;
1646+
undefValues[undef->getType()] = undef;
1647+
}
1648+
16401649
/// verify - Run the SIL verifier to make sure that the SILFunction follows
16411650
/// invariants.
16421651
void verify(CalleeCache *calleeCache = nullptr,

0 commit comments

Comments
 (0)