This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Make sure temp object file is always written
ClosedPublic

Authored by jobnoorman on Jul 10 2023, 2:45 AM.

Details

Summary

BOLT used ToolOutputFile::keep to make sure the intermediary object
file was written to disk for debugging purposes when --keep-tmp was
passed. However, since and intermediary buffer_ostream was used to
stream to, and this class only writes to its output stream in its
destructor, the object file was lost whenever its destructor wouldn't
run. This could happen, for example, if there is a crash while linking.

This patch makes sure the object file is written to disk immediately
after we're done creating it. This is very useful while debugging
JITLink crashes. This patch also gets rid of creating a temporary file
when --keep-tmp is not passed by streaming the object file directly to
a SmallString.

Diff Detail

Event Timeline

jobnoorman created this revision.Jul 10 2023, 2:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 2:45 AM
jobnoorman requested review of this revision.Jul 10 2023, 2:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 2:45 AM
maksfb accepted this revision.Jul 10 2023, 12:10 PM

LGTM

This revision is now accepted and ready to land.Jul 10 2023, 12:10 PM
This revision was automatically updated to reflect the committed changes.