diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-01-17 17:31:07 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-01-18 13:27:00 +0000 |
| commit | a5da85e3ce72a6f1362d33d098de56123034c2c1 (patch) | |
| tree | 3131c13329b268f350bb287e3f0c0aa24f859f99 | |
| parent | 0363fc5d478cb62b7cd8e5089f59136c7b9afeed (diff) | |
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.
| -rw-r--r-- | prog/minimization.go | 11 |
1 files changed, 11 insertions, 0 deletions
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 |
