[ubsan] Using metadata instead of prologue data for function sanitizer
authorYuanfang Chen <yuanfang.chen@sony.com>
Mon, 27 Jun 2022 18:33:45 +0000 (11:33 -0700)
committerYuanfang Chen <yuanfang.chen@sony.com>
Mon, 27 Jun 2022 19:09:13 +0000 (12:09 -0700)
commit6678f8e505b19069a9dbdc3e3ee088d543752412
treea476e413efab85d27d2469fab484a87ab093b5bd
parentae90bc8467589cbc2079b93fae2b6ceec0821e27
[ubsan] Using metadata instead of prologue data for function sanitizer

Information in the function `Prologue Data` is intentionally opaque.
When a function with `Prologue Data` is duplicated. The self (global
value) references inside `Prologue Data` is still pointing to the
original function. This may cause errors like `fatal error: error in backend: Cannot represent a difference across sections`.

This patch detaches the information from function `Prologue Data`
and attaches it to a function metadata node.

This and D116130 fix https://github.com/llvm/llvm-project/issues/49689.

Reviewed By: pcc

Differential Revision: https://reviews.llvm.org/D115844
16 files changed:
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Driver/SanitizerArgs.cpp
clang/test/CodeGen/ubsan-function.cpp
clang/test/CodeGenCXX/catch-undef-behavior.cpp
clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
clang/test/Driver/fsanitize.c
llvm/docs/LangRef.rst
llvm/include/llvm/IR/FixedMetadataKinds.def
llvm/include/llvm/IR/MDBuilder.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/MDBuilder.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/CodeGen/X86/func-sanitizer.ll [new file with mode: 0644]