Skip to content

Commit 462f630

Browse files
alexmalyshevmeta-codesync[bot]
authored andcommitted
Fix recursive usage of emitCond() (#55)
Summary: When the do_bb1() or do_bb2() functions called by emitCond() themselves call emitCond(), the outer conditional will grab the wrong blocks for its resulting Phi. It'll use the first block of their inner CFGs instead of the last one. Pull Request resolved: #55 Reviewed By: kddnewton Differential Revision: D104095042 Pulled By: alexmalyshev fbshipit-source-id: fcc31e33e06708a3be4a751daef41c231e5450fd
1 parent aa64f66 commit 462f630

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

cinderx/Jit/hir/simplify.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,21 @@ struct Env {
173173
block = bb1;
174174
cursor = bb1->end();
175175
Register* bb1_reg = do_bb1();
176+
// do_bb1() might have created more blocks, use the final one.
177+
BasicBlock* bb1_end = block;
176178
emit<Branch>(tail);
177179

178180
block = bb2;
179181
cursor = bb2->end();
180182
Register* bb2_reg = do_bb2();
183+
BasicBlock* bb2_end = block;
181184
emit<Branch>(tail);
182185

183186
block = tail;
184187
cursor = tail->begin();
185188
std::unordered_map<BasicBlock*, Register*> phi_srcs{
186-
{bb1, bb1_reg},
187-
{bb2, bb2_reg},
189+
{bb1_end, bb1_reg},
190+
{bb2_end, bb2_reg},
188191
};
189192
return emit<Phi>(phi_srcs);
190193
}

0 commit comments

Comments
 (0)