[Clang] Give error message for invalid profile path when compiling IR
authorAiden Grossman <agrossman154@yahoo.com>
Fri, 16 Sep 2022 19:35:50 +0000 (19:35 +0000)
committerAiden Grossman <agrossman154@yahoo.com>
Fri, 16 Sep 2022 19:45:57 +0000 (19:45 +0000)
commitc0bc461999fdac918dd26867947c24eb6235c8d0
tree49c00ed268837a53a0143816fd116d94cb5bf637
parent8a868d8859f9da23ee051848863045208c17ab47
[Clang] Give error message for invalid profile path when compiling IR

Before this patch, when compiling an IR file (eg the .llvmbc section
from an object file compiled with -Xclang -fembed-bitcode=all) and
profile data was passed in using the -fprofile-instrument-use-path
flag, there would be no error printed (as the previous implementation
relied on the error getting caught again in the constructor of
CodeGenModule which isn't called when -x ir is set). This patch
moves the error checking directly to where the error is caught
originally rather than failing silently in setPGOUseInstrumentor and
waiting to catch it in CodeGenModule to print diagnostic information to
the user.

Regression test added.

Reviewed By: xur, mtrofin

Differential Revision: https://reviews.llvm.org/D132991
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Profile/profile-does-not-exist-ir.c [new file with mode: 0644]
clang/test/Profile/profile-does-not-exist.c