This is an archive of the discontinued LLVM Phabricator instance.

[Sanitizers] Add a flag -f[no-]sanitize-merge-traps
Needs ReviewPublic

Authored by rnk on Apr 8 2021, 3:56 PM.

Details

Summary

Without this flag, enabling optimizations causes clang to emit a single
ubsantrap for every check failure of a particular kind. Adding this flag
allows the user to control this behavior separately, so they can choose
to have increased code size in exchange for more debuggable code.

A Chrome developer requested this feature here:
https://crbug.com/1185451

I made this change in such a way that it doesn't litter the cc1 line
with redundant flags: if the user does not pass the positive or negative
version if this flag, it is not forwarded to the cc1 invocation.

Diff Detail

Event Timeline

rnk created this revision.Apr 8 2021, 3:56 PM
rnk requested review of this revision.Apr 8 2021, 3:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2021, 3:56 PM

The CodeGen tests you added are failing pre-merge checks. This is most likely because we recently (D97462) started verifying that all all CC1 command line options can be serialized from a CompilerInvocation instance. To reproduce this locally, you'd need to build with assertions or manually set -DCLANG_ROUND_TRIP_CC1_ARGS=ON when building with CMake.

The solution would be to add complementary code that generates "-f[no-]sanitize-merge-traps" from CodeGenOptions::SanitizeMergeTraps in CompilerInvocation::GenerateCodeGenArgs.

More info is here https://clang.llvm.org/docs/InternalsManual.html#compiler-invocation and in the following sections.