From b1844ea162a481213beb86199cbab15800807d7b Mon Sep 17 00:00:00 2001 From: Ivy Tang Date: Thu, 14 Mar 2024 10:32:38 -0700 Subject: [PATCH] Blockinstrument handle entry block throw Summary: The IR type checker and quality metrics pipelines broke due to BlockInstrument. If the block to be instrumented throws, do not make the new entry block with the instrument load params throw too. Reviewed By: agampe Differential Revision: D54691052 fbshipit-source-id: 63c6cdd716dfe728fb5d4e2a2b9897cfbf1e85c5 --- opt/instrument/BlockInstrument.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/opt/instrument/BlockInstrument.cpp b/opt/instrument/BlockInstrument.cpp index 098afca838d..5f445a941d2 100644 --- a/opt/instrument/BlockInstrument.cpp +++ b/opt/instrument/BlockInstrument.cpp @@ -620,6 +620,13 @@ auto insert_prologue_insts(cfg::ControlFlowGraph& cfg, auto it = cfg.find_insn(eb_insn); b.block = it.block(); b.it = it.unwrap(); + // the entry block with prologue opcodes should not retain throws from the + // block that it was split from + if (!cfg.entry_block()->cannot_throw()) { + cfg.delete_succ_edge_if(cfg.entry_block(), [](const cfg::Edge* e) { + return e->type() == cfg::EdgeType::EDGE_THROW; + }); + } } if (slow_invariants_debug) {