diff options
author | Steven Perron <31666470+s-perron@users.noreply.github.com> | 2018-08-01 13:47:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-01 13:47:09 -0400 |
commit | c8c724cba71dc59912aefd4dd1730a9a7827971e (patch) | |
tree | 82e4138a5d74cd0b893780605e2612a644c41d78 /source | |
parent | ab061afc838fb8547c7c8aaebde61a8eac228d04 (diff) |
Don't change decorations and names in merge return. (#1777)
When creating a new phi for a value in the function, merge return will
rewrite all uses of an id that are no longer dominated by its
definition. Uses that are not in a basic block, like OpName or
decorations, are not dominated, but they should not be replaced.
Fixes #1736.
Diffstat (limited to 'source')
-rw-r--r-- | source/opt/merge_return_pass.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/opt/merge_return_pass.cpp b/source/opt/merge_return_pass.cpp index 6d955527..d84c1aed 100644 --- a/source/opt/merge_return_pass.cpp +++ b/source/opt/merge_return_pass.cpp @@ -198,7 +198,11 @@ void MergeReturnPass::CreatePhiNodesForInst(BasicBlock* merge_block, std::vector<Instruction*> users_to_update; context()->get_def_use_mgr()->ForEachUser( &inst, [&users_to_update, &dom_tree, inst_bb, this](Instruction* user) { - if (!dom_tree->Dominates(inst_bb, context()->get_instr_block(user))) { + BasicBlock* user_bb = context()->get_instr_block(user); + // If |user_bb| is nullptr, then |user| is not in the function. It is + // something like an OpName or decoration, which should not be + // replaced with the result of the OpPhi. + if (user_bb && !dom_tree->Dominates(inst_bb, user_bb)) { users_to_update.push_back(user); } }); |