bug fix on hidden case
This commit is contained in:
parent
4470c97411
commit
2ec8ff8ed5
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@ -10,7 +10,8 @@
|
||||
"name": "Debug",
|
||||
"program": "${workspaceFolder}/build/sysy",
|
||||
// "args": ["../sysytests/functional_2021/069_greatest_common_divisor.sy", "-S", "-o", "build/my.s", "-O1", "-emit-llvm"],
|
||||
"args" : ["-S", "../sysytests/functional_2022/21_if_test2.sy", "-o", "build/dbg.s", "-emit-llvm", "-O1",],
|
||||
// "args" : ["-S", "../sysytests/functional_2022/21_if_test2.sy", "-o", "build/dbg.s", "-emit-llvm", "-O1",],
|
||||
"args" : ["-S", "../sysytests/functional_h_2022/04_break_continue.sy", "-o", "build/dbg.s", "-emit-llvm", "-O1",],
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
]
|
||||
|
||||
@ -22,9 +22,9 @@ static InstBranch *is_cond_br(Instruction *inst) {
|
||||
|
||||
// not removing the block, this only means that pred no longer branch to bb
|
||||
static void rewrite_bb(sptr(BasicBlock) bb, sptr(BasicBlock) pred) {
|
||||
pred->succ_list.remove(bb);
|
||||
pred->succ_list.erase(STD_FIND(pred->succ_list, bb));
|
||||
auto pred_index = GETINDEX(bb->pred_list, pred);
|
||||
bb->pred_list.remove(pred);
|
||||
bb->pred_list.erase(STD_FIND(bb->pred_list, pred));
|
||||
for (auto itr = bb->inst_list.begin(); itr != bb->inst_list.end();) {
|
||||
auto inst = *itr++;
|
||||
if (!shared_cast<InstPhi>(inst)) break;
|
||||
|
||||
@ -259,9 +259,9 @@ void PassSCCP::Visit_Inst(Instruction *inst) {
|
||||
pred is no more bb's pred, so maintain cfg and rewrite bb's phi nodes
|
||||
*/
|
||||
static void rewrite_bb(sptr(BasicBlock) bb, sptr(BasicBlock) pred) {
|
||||
pred->succ_list.remove(bb);
|
||||
pred->succ_list.erase(STD_FIND(pred->succ_list, bb));
|
||||
auto pred_index = GETINDEX(bb->pred_list, pred);
|
||||
bb->pred_list.remove(pred);
|
||||
bb->pred_list.erase(STD_FIND(bb->pred_list, pred));
|
||||
for (auto itr = bb->inst_list.begin(); itr != bb->inst_list.end();) {
|
||||
auto inst = *itr++;
|
||||
if (!shared_cast<InstPhi>(inst)) break;
|
||||
|
||||
@ -141,7 +141,7 @@ bool Elim_Dead_Code(Function *func) {
|
||||
// Still unknown what this would be like, the only case by now is
|
||||
// true_branch = false_branch
|
||||
changed = true;
|
||||
LOG(WARNING) << "rewrite dead branch";
|
||||
LOG(WARNING) << "rewrite dead branch in " << bb->to_string();
|
||||
auto cfgnode = RCFG.bb_node.at(bb.get());
|
||||
// walk up through the dom-tree(idom), and check if there is any useful insts in it
|
||||
auto useful_pdom = cfgnode->idom;
|
||||
@ -191,7 +191,6 @@ bool Fuse_Block(Function *func) {
|
||||
visit.clear(); post_order.clear();
|
||||
get_post_order(func->bb_list.front().get());
|
||||
for (auto bb : post_order) {
|
||||
LOG(DEBUG) << "visit " << bb->to_string();
|
||||
if (is_branch(bb->inst_list.back().get())) {
|
||||
auto inst = bb->inst_list.back().get();
|
||||
if (inst->operand_list[1] == inst->operand_list[2]) {
|
||||
@ -305,7 +304,7 @@ void PassDCE::run(const Module &module) {
|
||||
Elim_Dead_Code(func.get());
|
||||
Elim_Unreach_Code(func.get());
|
||||
other_clear(func.get());
|
||||
// Fuse_Block(func.get());
|
||||
Fuse_Block(func.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user