Add EntryRegDiversions to record diversions for each block entry.

This commit is contained in:
Nicolas B. Pierron
2019-08-01 15:06:49 +02:00
committed by Nicolas B. Pierron
parent 9eb1847d80
commit bb87f1a54a
9 changed files with 126 additions and 16 deletions

View File

@@ -176,7 +176,7 @@ where
{
let mut divert = RegDiversions::new();
for ebb in func.layout.ebbs() {
divert.clear();
divert.at_ebb(&func.entry_diversions, ebb);
debug_assert_eq!(func.offsets[ebb], sink.offset());
for inst in func.layout.ebb_insts(ebb) {
emit_inst(func, inst, &mut divert, sink, isa);

View File

@@ -74,7 +74,7 @@ pub fn relax_branches(
{
let mut cur = FuncCursor::new(func);
while let Some(ebb) = cur.next_ebb() {
divert.clear();
divert.at_ebb(&cur.func.entry_diversions, ebb);
cur.func.offsets[ebb] = offset;
while let Some(inst) = cur.next_inst() {
divert.apply(&cur.func.dfg[inst]);
@@ -93,7 +93,8 @@ pub fn relax_branches(
// Visit all instructions in layout order.
let mut cur = FuncCursor::new(func);
while let Some(ebb) = cur.next_ebb() {
divert.clear();
divert.at_ebb(&cur.func.entry_diversions, ebb);
// Record the offset for `ebb` and make sure we iterate until offsets are stable.
if cur.func.offsets[ebb] != offset {
cur.func.offsets[ebb] = offset;

View File

@@ -20,7 +20,9 @@ pub fn shrink_instructions(func: &mut Function, isa: &dyn TargetIsa) {
let mut divert = RegDiversions::new();
for ebb in func.layout.ebbs() {
divert.clear();
// Load diversions from predecessors.
divert.at_ebb(&func.entry_diversions, ebb);
for inst in func.layout.ebb_insts(ebb) {
let enc = func.encodings[inst];
if enc.is_legal() {