[all-commits] [llvm/llvm-project] 29992c: [Clang][CodeGen] Emit “trap reasons” on UBSan trap...
Anthony Tran via All-commits
all-commits at lists.llvm.org
Sat Jul 26 08:50:46 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 29992cfd628ed5b968ccb73b17ed0521382ba317
https://github.com/llvm/llvm-project/commit/29992cfd628ed5b968ccb73b17ed0521382ba317
Author: Anthony Tran <atran881 at usc.edu>
Date: 2025-07-26 (Sat, 26 Jul 2025)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/CodeGenOptions.def
M clang/include/clang/Driver/Options.td
M clang/lib/CodeGen/CGDebugInfo.cpp
M clang/lib/CodeGen/CGExpr.cpp
M clang/lib/CodeGen/SanitizerHandler.h
M clang/lib/Driver/SanitizerArgs.cpp
M clang/test/CodeGen/bounds-checking-debuginfo.c
M clang/test/CodeGen/cfi-icall-generalize-debuginfo.c
M clang/test/CodeGen/cfi-icall-normalize2-debuginfo.c
M clang/test/CodeGen/ubsan-trap-debugloc.c
A clang/test/CodeGen/ubsan-trap-reason-add-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-alignment-assumption.c
A clang/test/CodeGen/ubsan-trap-reason-builtin-unreachable.c
A clang/test/CodeGen/ubsan-trap-reason-cfi-check-fail.c
A clang/test/CodeGen/ubsan-trap-reason-crash.cpp
A clang/test/CodeGen/ubsan-trap-reason-div-rem-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-dynamic-type-cache-miss.cpp
A clang/test/CodeGen/ubsan-trap-reason-flag.c
A clang/test/CodeGen/ubsan-trap-reason-float-cast-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-function-type-mismatch.c
A clang/test/CodeGen/ubsan-trap-reason-implicit-conversion.c
A clang/test/CodeGen/ubsan-trap-reason-invalid-builtin.c
A clang/test/CodeGen/ubsan-trap-reason-invalid-objc-cast.m
A clang/test/CodeGen/ubsan-trap-reason-load-invalid-value.c
A clang/test/CodeGen/ubsan-trap-reason-missing-return.cpp
A clang/test/CodeGen/ubsan-trap-reason-mul-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-negate-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-nonnull-arg.c
A clang/test/CodeGen/ubsan-trap-reason-nonnull-return.c
A clang/test/CodeGen/ubsan-trap-reason-nullability-arg.c
A clang/test/CodeGen/ubsan-trap-reason-nullability-return.c
A clang/test/CodeGen/ubsan-trap-reason-out-of-bounds.c
A clang/test/CodeGen/ubsan-trap-reason-pointer-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-shift-out-of-bounds.c
A clang/test/CodeGen/ubsan-trap-reason-sub-overflow.c
A clang/test/CodeGen/ubsan-trap-reason-type-mismatch.c
A clang/test/CodeGen/ubsan-trap-reason-vla-bound-not-positive.c
Log Message:
-----------
[Clang][CodeGen] Emit “trap reasons” on UBSan traps (#145967)
This patch adds a human readable trap category and message to UBSan
traps. The category and message are encoded in a fake frame in the debug
info where the function is a fake inline function where the name encodes
the trap category and message. This is the same mechanism used by
Clang’s `__builtin_verbose_trap()`.
This change allows consumers of binaries built with trapping UBSan to
more easily identify the reason for trapping. In particular LLDB already
has a frame recognizer that recognizes the fake function names emitted
in debug info by this patch. A patch testing this behavior in LLDB will
be added in a separately.
The human readable trap messages are based on the messages currently
emitted by the userspace runtime for UBSan in compiler-rt. Note the
wording is not identical because the userspace UBSan runtime has access
to dynamic information that is not available during Clang’s codegen.
Test cases for each UBSan trap kind are included.
This complements the [`-fsanitize-annotate-debug-info`
feature](https://github.com/llvm/llvm-project/pull/141997). While
`-fsanitize-annotate-debug-info` attempts to annotate all UBSan-added
instructions, this feature (`-fsanitize-debug-trap-reasons`) only
annotates the final trap instruction using SanitizerHandler information.
This work is part of a GSoc 2025 project.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list