From a5da85e3ce72a6f1362d33d098de56123034c2c1 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 17 Jan 2024 17:31:07 +0100 Subject: prog: optimize call minimization In many cases we can remove all calls that follow the call of interest. Try this before deleting them one-by-one. --- prog/minimization.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/prog/minimization.go b/prog/minimization.go index 68cca2ec4..0beaef17b 100644 --- a/prog/minimization.go +++ b/prog/minimization.go @@ -67,6 +67,17 @@ func Minimize(p0 *Prog, callIndex0 int, crash bool, pred0 func(*Prog, int) bool) } func removeCalls(p0 *Prog, callIndex0 int, crash bool, pred func(*Prog, int) bool) (*Prog, int) { + if callIndex0 >= 0 && callIndex0+2 < len(p0.Calls) { + // It's frequently the case that all subsequent calls were not necessary. + // Try to drop them all at once. + p := p0.Clone() + for i := len(p0.Calls) - 1; i > callIndex0; i-- { + p.RemoveCall(i) + } + if pred(p, callIndex0) { + p0 = p + } + } for i := len(p0.Calls) - 1; i >= 0; i-- { if i == callIndex0 { continue -- cgit mrf-deployment