[StandardInstrumentations] Add option to dump IR to a file on crash
authorArthur Eubanks <aeubanks@google.com>
Mon, 22 May 2023 23:00:18 +0000 (16:00 -0700)
committerArthur Eubanks <aeubanks@google.com>
Thu, 25 May 2023 16:18:01 +0000 (09:18 -0700)
commiteb9ba243722454c186134fc83449ce69906603ae
tree6e481632cc6b61618f97dab1c6b6597dc54fa036
parent6f026ff029853431ee535e6a361edd059da3ab27
[StandardInstrumentations] Add option to dump IR to a file on crash

We already have -print-on-crash which dumps the IR to stderr on a crash, but it's more useful to dump to a file.

Introduce -print-on-crash-path to dump the IR to a file.

Making -print-on-crash a string option is confusing if you only pass -print-on-crash and it swallows up the next command line arg, which is why this is a new option.

Perhaps we could retire the dump to stderr version if people don't use it, but not sure how much people find that useful.

Reviewed By: jamieschmeiser

Differential Revision: https://reviews.llvm.org/D151170
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/test/Other/print-on-crash.ll