This is an archive of the discontinued LLVM Phabricator instance.

[llvm-reduce] make llvm-reduce save the best reduction it has when it crashes
ClosedPublic

Authored by Tyker on Aug 14 2020, 2:08 PM.

Details

Summary

This helps with both debugging llvm-reduce and sometimes getting usefull result even if llvm-reduce crashes

Diff Detail

Event Timeline

Tyker created this revision.Aug 14 2020, 2:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2020, 2:08 PM
Tyker requested review of this revision.Aug 14 2020, 2:08 PM
lebedev.ri requested changes to this revision.EditedAug 14 2020, 2:17 PM
  1. I'm pretty sure it's not okay to allocate memory in crash handler.
  2. We can't know that the internal state is still consistent.

We already store each IR to disk to run the interestingness test on it.
Instead of LastIntersting = ReducedProgram.get();, let's just rewrite the OutputFilename each time.

This revision now requires changes to proceed.Aug 14 2020, 2:17 PM
Tyker updated this revision to Diff 285769.Aug 14 2020, 3:14 PM
  1. I'm pretty sure it's not okay to allocate memory in crash handler.
  2. We can't know that the internal state is still consistent.

i agree with both points but all i was trying to do i salvage what can be salvaged.

We already store each IR to disk to run the interestingness test on it.
Instead of LastIntersting = ReducedProgram.get();, let's just rewrite the OutputFilename each time.

yeah this is a better idea.

lebedev.ri accepted this revision.Aug 14 2020, 11:33 PM

This seems fine to me, thanks.
If you have llvm-reduce crashers, do let me know, i'm interested.

llvm/tools/llvm-reduce/llvm-reduce.cpp
84–87

I wonder if we want do to something special if input == output?

This revision is now accepted and ready to land.Aug 14 2020, 11:33 PM
Tyker added a comment.Aug 17 2020, 1:18 PM

This seems fine to me, thanks.
If you have llvm-reduce crashers, do let me know, i'm interested.

i had one but i has been fixed by 6187eeb683d8c639282d437e6af585e9b7f9c93e.

llvm/tools/llvm-reduce/llvm-reduce.cpp
84–87

we could save the original into its original name plus some post-fix like .old before overwriting.