This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Fix nondeterministic exit on error.
ClosedPublic

Authored by mtrofin on Dec 10 2021, 9:00 PM.

Details

Summary

In the multi-threaded case, if a thread hits an error, we mimick LLVMContext's behavior of reporting the error and exit-ing. However, this doesn't cleanly join the other threads, so depending on how fast the process exits, other threads may report 'terminate called without an active exception'.

To avoid this non-determinsim, and without introducing a more complicated design, we just report the error, but not exit early. We do track whether we hit errors and exit(1) after joining.

Diff Detail

Event Timeline

mtrofin created this revision.Dec 10 2021, 9:00 PM
mtrofin requested review of this revision.Dec 10 2021, 9:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2021, 9:00 PM
tejohnson added inline comments.Dec 13 2021, 9:13 AM
llvm/tools/llvm-lto2/llvm-lto2.cpp
311

Or if Threads==1

327

What is the downside of always deferring the error?

mtrofin updated this revision to Diff 393928.Dec 13 2021, 9:29 AM
mtrofin marked 2 inline comments as done.

simplified by handling single and multithreaded error cases the same way

mtrofin edited the summary of this revision. (Show Details)Dec 13 2021, 9:29 AM
mtrofin added inline comments.
llvm/tools/llvm-lto2/llvm-lto2.cpp
311

ack, but not needed anymore

327

Just that we can exit quicker in that case, and it'd mimic what clang does in non-multi-threaded cases. But I don't think either of those are worth the extra check, so removing the singlethreaded special case.

tejohnson accepted this revision.Dec 13 2021, 9:33 AM

lgtm with one minor suggestion below.

llvm/tools/llvm-lto2/llvm-lto2.cpp
324

Nit: The last 3 lines can now be shortened to 2:

if (DI.getSeverity() == DS_Error)
   HasErrors = true;
This revision is now accepted and ready to land.Dec 13 2021, 9:33 AM
mtrofin updated this revision to Diff 393951.Dec 13 2021, 9:58 AM
mtrofin edited the summary of this revision. (Show Details)

feedback

This revision was landed with ongoing or failed builds.Dec 13 2021, 10:09 AM
This revision was automatically updated to reflect the committed changes.