This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Report file opening errors
ClosedPublic

Authored by arsenm on Oct 24 2022, 9:19 AM.

Details

Summary

This was also trying to write the bitcode to the failed file
on failure, which asserts. Also, consistently use
ToolOutputFile, instead of one path manually removing
the temp file.

Diff Detail

Event Timeline

arsenm created this revision.Oct 24 2022, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2022, 9:19 AM
arsenm requested review of this revision.Oct 24 2022, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2022, 9:19 AM
Herald added a subscriber: wdng. · View Herald Transcript
aeubanks added inline comments.Oct 28 2022, 3:47 PM
llvm/tools/llvm-reduce/deltas/Delta.cpp
81–82

I think the intention of the original code was also to check if the writing caused any problems. So we should check before and after? And ditto below in the textual IR. Probably we should factor out the check into a helper function/lambda

arsenm updated this revision to Diff 471693.Oct 28 2022, 5:40 PM
arsenm edited the summary of this revision. (Show Details)

Consistently use ToolOutputFile and check error after close

aeubanks accepted this revision.Oct 31 2022, 2:13 PM

oh I guess if there's an error opening the file initially, it'll stay as that error even attempting to write to it?

This revision is now accepted and ready to land.Oct 31 2022, 2:13 PM

oh I guess if there's an error opening the file initially, it'll stay as that error even attempting to write to it?

No, it's an assert to write to the failed open file. This ends up checking after open and after close. The problem was the text and bitcode paths were duplicating the opening, and the text path didn't check