File tree 1 file changed +11
-3
lines changed
godel-script/godel-frontend/src/ir
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -143,18 +143,26 @@ void inst_combine_pass::scan(souffle_rule_impl* b) {
143
143
//
144
144
for (const auto & i : variable_reference_graph) {
145
145
const auto & name = i.first ;
146
- if (i.second .size ()!=1 ) {
146
+ // if alias variables' count > 1, even if there's a circle, still skip it.
147
+ if (i.second .size () != 1 ) {
147
148
continue ;
148
149
}
150
+ // alias variable's name
149
151
const auto & to = i.second .begin ()->first ;
150
152
if (!variable_reference_graph.count (to)) {
151
153
continue ;
152
154
}
153
- if (variable_reference_graph.at (to).size ()!=1 ) {
155
+ // this variable's alias count should be 1
156
+ if (variable_reference_graph.at (to).size () != 1 ) {
154
157
continue ;
155
158
}
159
+ // get `to`'s alias variable's name, this name should be equal to `name`
156
160
const auto & from = variable_reference_graph.at (to).begin ()->first ;
157
- if (from==name && to.find (" ssa_temp" )==0 && from.find (" ssa_temp" )==0 ) {
161
+ // means there's a circle like this:
162
+ // `to` <--> `from`(aka `name`)
163
+ // after clear(), `to`'s alias count should be 0:
164
+ // `to` <--- `from`(aka `name`)
165
+ if (from == name && to.find (" ssa_temp" ) == 0 && from.find (" ssa_temp" ) == 0 ) {
158
166
variable_reference_graph.at (to).clear ();
159
167
}
160
168
}
You can’t perform that action at this time.
0 commit comments