[PATCH] D115844: [ubsan] Using metadata instead of prologue data for function sanitizer

Yuanfang Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 20:32:57 PST 2021


ychen created this revision.
ychen added reviewers: pcc, vsk, rjmccall.
Herald added subscribers: dexonsmith, hiraditya.
ychen requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Information in the function `Prologue Data` is intentionally opaque. This
is fine from the function sanitizer's perspective if function manipulations
(duplication etc.) do not change the function signature. However,
coroutine lowering needs to split one function into several functions
that have different signatures. The ideal way to solve this is to make
the sanitizer information not opaque so that LLVM passes know how to deal with
it. This patch detaches the information from function `Prologue Data`
and attaches it to a function metadata node.

Alternatively,
(1) function attributes do not work because it could not carry
GlobalValue.
(2) I've considered adding one additional function optional
data(D13829 <https://reviews.llvm.org/D13829>) for the function sanitizer. However, it requires LL/parser
changes that I want to avoid.

If this is agreed upon, I'll send an follow-up patch fix PR50345.

Do you think this is worth doing? If so, which approach is better: this
patch or (2)?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115844

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/ubsan-function.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115844.394735.patch
Type: text/x-patch
Size: 17469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211216/0923a9db/attachment.bin>


More information about the llvm-commits mailing list