[GCOV] Set !kcfi_type metadata for indirectly called functions
authorSami Tolvanen <samitolvanen@google.com>
Fri, 6 Jan 2023 20:54:09 +0000 (20:54 +0000)
committerSami Tolvanen <samitolvanen@google.com>
Wed, 11 Jan 2023 22:53:22 +0000 (22:53 +0000)
commita78cfd5909024f9daa9a5175e9d411b0fac0e9a1
treec00dadc6c7fd43f8683d415906f6468aa4fa0e93
parent6a4a697e179986324342701adc9e1c47622c3ea9
[GCOV] Set !kcfi_type metadata for indirectly called functions

With CONFIG_GCOV_KERNEL, the Linux kernel indirectly calls the
__llvm_gcov_* functions generated by LLVM. With -fsanitize=kcfi,
these calls are made from instrumented code and fail indirect
call checks as they don't have !kcfi_type metadata. Similarly
to D138945, set type metadata for these functions to allow GCOV
and KCFI to be both enabled.

Link: https://github.com/ClangBuiltLinux/linux/issues/1778
Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D141444
llvm/include/llvm/Transforms/Utils/ModuleUtils.h
llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/lib/Transforms/Utils/ModuleUtils.cpp
llvm/test/Transforms/GCOVProfiling/kcfi.ll [new file with mode: 0644]