Change InlineAsm to allow multiple targets instead

This commit is contained in:
Gary Guo 2023-12-26 15:28:42 +00:00
parent 7152993aa8
commit b044aaa905
23 changed files with 125 additions and 96 deletions

View file

@ -349,12 +349,20 @@ fn bcb_filtered_successors<'a, 'tcx>(terminator: &'a Terminator<'tcx>) -> Covera
| FalseUnwind { real_target: target, .. }
| Goto { target } => CoverageSuccessors::Chainable(target),
// These terminators can normally be chained, except when they have no
// A call terminator can normally be chained, except when they have no
// successor because they are known to diverge.
Call { target: maybe_target, .. } | InlineAsm { destination: maybe_target, .. } => {
match maybe_target {
Some(target) => CoverageSuccessors::Chainable(target),
None => CoverageSuccessors::NotChainable(&[]),
Call { target: maybe_target, .. } => match maybe_target {
Some(target) => CoverageSuccessors::Chainable(target),
None => CoverageSuccessors::NotChainable(&[]),
},
// An inline asm terminator can normally be chained, except when it diverges or uses asm
// goto.
InlineAsm { ref targets, .. } => {
if targets.len() == 1 {
CoverageSuccessors::Chainable(targets[0])
} else {
CoverageSuccessors::NotChainable(targets)
}
}

View file

@ -88,7 +88,6 @@ impl<'tcx> MockBlocks<'tcx> {
| TerminatorKind::FalseEdge { real_target: ref mut target, .. }
| TerminatorKind::FalseUnwind { real_target: ref mut target, .. }
| TerminatorKind::Goto { ref mut target }
| TerminatorKind::InlineAsm { destination: Some(ref mut target), .. }
| TerminatorKind::Yield { resume: ref mut target, .. } => *target = to_block,
ref invalid => bug!("Invalid from_block: {:?}", invalid),
}
@ -185,10 +184,12 @@ fn debug_basic_blocks(mir_body: &Body<'_>) -> String {
| TerminatorKind::FalseEdge { real_target: target, .. }
| TerminatorKind::FalseUnwind { real_target: target, .. }
| TerminatorKind::Goto { target }
| TerminatorKind::InlineAsm { destination: Some(target), .. }
| TerminatorKind::Yield { resume: target, .. } => {
format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), target)
}
TerminatorKind::InlineAsm { targets, .. } => {
format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), targets)
}
TerminatorKind::SwitchInt { targets, .. } => {
format!("{}{:?}:{} -> {:?}", sp, bb, kind.name(), targets)
}

View file

@ -1032,8 +1032,8 @@ impl<'tcx> MutVisitor<'tcx> for Integrator<'_, 'tcx> {
{
bug!("False unwinds should have been removed before inlining")
}
TerminatorKind::InlineAsm { ref mut destination, ref mut unwind, .. } => {
if let Some(ref mut tgt) = *destination {
TerminatorKind::InlineAsm { ref mut targets, ref mut unwind, .. } => {
for tgt in targets.iter_mut() {
*tgt = self.map_block(*tgt);
}
*unwind = self.map_unwind(*unwind);