File tree Expand file tree Collapse file tree 5 files changed +18
-7
lines changed Expand file tree Collapse file tree 5 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ namespace swift {
17
17
18
18
class ValueBase ;
19
19
20
- // / A protocol (or inferface) for handling instruction deletion notifications.
20
+ // / A protocol (or inferface) for handling value deletion notifications.
21
21
// /
22
22
// / This class is used as a base class for any class that need to accept
23
23
// / instruction deletion notification messages. This is used by passes and
Original file line number Diff line number Diff line change @@ -83,8 +83,7 @@ class AliasAnalysis : public SILAnalysis {
83
83
bool typesMayAlias (SILType T1, SILType T2);
84
84
85
85
86
- virtual void handleDeleteNotification (ValueBase *I) override {
87
- }
86
+ virtual void handleDeleteNotification (ValueBase *I) override { }
88
87
89
88
public:
90
89
AliasAnalysis (SILModule *M) :
Original file line number Diff line number Diff line change @@ -43,6 +43,11 @@ SILBasicBlock::~SILBasicBlock() {
43
43
getModule ().notifyDeleteHandlers (&*I);
44
44
}
45
45
46
+ // Invalidate all of the basic block arguments.
47
+ for (auto *Arg : BBArgList) {
48
+ getModule ().notifyDeleteHandlers (Arg);
49
+ }
50
+
46
51
// iplist's destructor is going to destroy the InstList.
47
52
}
48
53
@@ -100,10 +105,18 @@ void SILBasicBlock::removeFromParent() {
100
105
SILArgument *SILBasicBlock::replaceBBArg (unsigned i, SILType Ty,
101
106
const ValueDecl *D) {
102
107
SILModule &M = getParent ()->getModule ();
108
+
109
+
103
110
assert (BBArgList[i]->use_empty () && " Expected no uses of the old BB arg!" );
104
111
112
+ // Notify the delete handlers that this argument is being deleted.
113
+ M.notifyDeleteHandlers (BBArgList[i]);
114
+
105
115
auto *NewArg = new (M) SILArgument (Ty, D);
106
116
NewArg->setParent (this );
117
+
118
+ // TODO: When we switch to malloc/free allocation we'll be leaking memory
119
+ // here.
107
120
BBArgList[i] = NewArg;
108
121
109
122
return NewArg;
Original file line number Diff line number Diff line change @@ -676,8 +676,8 @@ removeDeleteNotificationHandler(DeleteNotificationHandler* Handler) {
676
676
NotificationHandlers.remove (Handler);
677
677
}
678
678
679
- void SILModule::notifyDeleteHandlers (ValueBase *Item ) {
679
+ void SILModule::notifyDeleteHandlers (ValueBase *V ) {
680
680
for (auto *Handler : NotificationHandlers) {
681
- Handler->handleDeleteNotification (Item );
681
+ Handler->handleDeleteNotification (V );
682
682
}
683
683
}
Original file line number Diff line number Diff line change @@ -355,8 +355,7 @@ class SILCombine : public SILFunctionTransform {
355
355
}
356
356
}
357
357
358
- virtual void handleDeleteNotification (ValueBase *I) override {
359
- }
358
+ virtual void handleDeleteNotification (ValueBase *I) override { }
360
359
361
360
StringRef getName () override { return " SIL Combine" ; }
362
361
};
You can’t perform that action at this time.
0 commit comments