Skip to content

Commit 974ee14

Browse files
smowtonDaniel Kroening
authored and
Daniel Kroening
committed
Add exception edges to the CFG for dominator computation
1 parent bf0332d commit 974ee14

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/java_bytecode/java_local_variable_table.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ struct procedure_local_cfg_baset<
3232

3333
void operator()(const method_with_amapt& args)
3434
{
35+
const auto &method=args.first;
3536
const auto& amap=args.second;
3637
for(const auto& inst : amap)
3738
{
@@ -47,6 +48,29 @@ struct procedure_local_cfg_baset<
4748
}
4849
// Add edges declared in the exception table, which don't figure
4950
// in the address map successors/predecessors as yet.
51+
for(const auto& table_entry : method.exception_table)
52+
{
53+
auto findit=amap.find(table_entry.start_pc);
54+
assert(findit!=amap.end() &&
55+
"Exception table entry doesn't point to an instruction?");
56+
for(; findit->first<table_entry.end_pc; ++findit)
57+
{
58+
// For now just assume any non-branch
59+
// instruction could potentially throw.
60+
auto succit=findit;
61+
++succit;
62+
if(succit==amap.end())
63+
continue;
64+
const auto& thisinst=findit->second;
65+
if(thisinst.successors.size()==1 &&
66+
*thisinst.successors.begin()==succit->first)
67+
{
68+
this->add_edge(
69+
entry_map.at(findit->first),
70+
entry_map.at(table_entry.handler_pc));
71+
}
72+
}
73+
}
5074
}
5175

5276
unsigned get_first_node(const method_with_amapt& args) const

0 commit comments

Comments
 (0)