Repository: rust
Issue: Print backtraces for LLVM segfaults and aborts
Labels: A-LLVM,T-compiler,E-help-wanted,C-bug

When a crash happens in an LLVM tool, it prints a nice backtrace:

```
> build/x86_64-unknown-linux-gnu/llvm/bin/llc -O0 crashy.ll
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/llc -O0 crashy.ll 
1.      Running pass 'Function Pass Manager' on module 'crashy.ll'.
2.      Running pass 'IRTranslator' on function '@_ZN3std3sys4unix2fs5lstat17h30bd1f0595542181E'
 #0 0x00007f75ffa4c47c PrintStackTraceSignalHandler(void*) (.llvm.14272527432730108163) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x133747c)
 #1 0x00007f75ffa49c3e llvm::sys::RunSignalHandlers() (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1334c3e)
 #2 0x00007f75ffa4c905 SignalHandler(int) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1337905)
 #3 0x00007f75fe6ec140 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #4 0x00007f75ffe8c752 llvm::MachineRegisterInfo::addRegOperandToUseList(llvm::MachineOperand*) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1777752)
 #5 0x00007f760042d14a llvm::MachineIRBuilder::buildDirectDbgValue(llvm::Register, llvm::MDNode const*, llvm::MDNode const*) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1d1814a)
 #6 0x00007f76003e1da2 llvm::IRTranslator::translateKnownIntrinsic(llvm::CallInst const&, unsigned int, llvm::MachineIRBuilder&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1cccda2)
 #7 0x00007f76003e3045 llvm::IRTranslator::translateCall(llvm::User const&, llvm::MachineIRBuilder&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1cce045)
 #8 0x00007f76003e6aaa llvm::IRTranslator::translate(llvm::Instruction const&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1cd1aaa)
 #9 0x00007f76003e8e2b llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x1cd3e2b)
#10 0x00007f75ffe0bfee llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x16f6fee)
#11 0x00007f75ffbb1721 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x149c721)
#12 0x00007f75ffbb9803 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x14a4803)
#13 0x00007f75ffbb218d llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/../lib/libLLVM-11-rust-1.49.0-nightly.so+0x149d18d)
#14 0x000000000020ae2e main (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x20ae2e)
#15 0x00007f75fe3f5cca __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26cca)
#16 0x0000000000208129 _start (/usr/local/google/home/tmandry/frust/build/x86_64-unknown-linux-gnu/llvm/bin/llc+0x208129)
```

But when an LLVM crash happens in rustc we don't, even when RUST_BACKTRACE=1.

This may be a simple matter of calling some LLVM function to set up hooks, but it might be more complicated than that.

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"in42"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->