[profile] Add support for the exit-on-signal '%Nx' specifier

The exit-on-signal specifier tells the runtime to handle a signal by writing
out a profile and then exiting the program. It can be specified in the
LLVM_PROFILE_FILE environment variable or by calling
__llvm_profile_set_filename.

Here is how you might force a program to exit when it's sent SIGTERM (sig 15):

  LLVM_PROFILE_FILE="default.profraw%15x" <program>

When an instance of <program> is sent SIGTERM, it will write out a profile to
"default.profraw" (the specifier is stripped out of the filename) and exit with
return code 0. It's possible to use multiple exit-on-signal specifiers (up to
16).

rdar://problem/24098975
(cherry picked from commit 2cf73dc0fd684e3127e0ec9f3f8c432ae8ce7022)
2 files changed