Page MenuHomePhabricator

[llvm-reduce] Count chunks by running a preliminary reduction
ClosedPublic

Authored by aeubanks on Tue, Nov 9, 7:14 PM.

Details

Summary

Having a separate counting method runs the risk of a mismatch between
the actual reduction method and the counting method.

Instead, create an Oracle that always returns true for shouldKeep(), run
the reduction, and count how many times shouldKeep() was called. The
module should not be modified if shouldKeep() always returns true.

Diff Detail

Event Timeline

aeubanks created this revision.Tue, Nov 9, 7:14 PM
aeubanks requested review of this revision.Tue, Nov 9, 7:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Nov 9, 7:14 PM
Meinersbur added inline comments.Thu, Nov 11, 12:39 PM
llvm/tools/llvm-reduce/deltas/Delta.cpp
115

Did you consider adding a test/assertion for the number of calls to shouldKeep() by the reduce function remains the same every time? Having an explicit count function requires one to think how many there are, but I fear it will also be easier to write reduce functions whose number of targets depends on the result of the shouldKeep() function.

aeubanks added inline comments.Thu, Nov 11, 3:35 PM
llvm/tools/llvm-reduce/deltas/Delta.cpp
115

I don't think having an explicit count function helps. It's still very easy to have the reduce pass allow one reduction to also affect another reduction regardless of counting. So I don't think this patch makes things worse.

I can add such a test/assert in a followup patch, I'm afraid some existing pass already doesn't pass this test.

Meinersbur accepted this revision.Thu, Nov 11, 5:06 PM

LGTM

I can add such a test/assert in a followup patch, I'm afraid some existing pass already doesn't pass this test.

Fixing misbehaving existing passes would be great.

This revision is now accepted and ready to land.Thu, Nov 11, 5:06 PM