This patch addresses bug https://llvm.org/bugs/show_bug.cgi?id=26060 where lto_module_create() could return nullptr but lto_get_error_message() returned an empty string. Unfortunately, I could not find any place where lto_module_*() functions would be tested so I am not sure where to add a test for this problem.
Note that this patch would also fix the same problem that commit r257395 fixed yesterday in llvm-lto because the diagnostic handler in llvm-lto exits the program on error.
Is this related?