[llvm-dev] Patches for enabling clang's noundef analysis by default

Juneyoung Lee via llvm-dev llvm-dev at lists.llvm.org
Mon Aug 23 00:41:18 PDT 2021

Hello all,

I would like to get feedback for two patches that enable clang's noundef
analysis flag by default.
The two patches are: https://reviews.llvm.org/D105169 ,
https://reviews.llvm.org/D108453 .
They are splitted for readability, but they will be merged into one commit
and pushed if accepted.

The noundef analysis flag was added by D81678 <
https://reviews.llvm.org/D81678> in the past.
Its goal is to mark arguments and return values in C/C++ as `noundef` if

Besides its performance benefit to sanitizers, which was the main
motivation, attaching `noundef` is beneficial because it allows quite a few
optimizations that are unsound w.r.t. undef or poison (they are usually
guarded with `isGuaranteedNotToBeUndefOrPoison` check).
Since the fact that arg/ret values are noundef is derived from the source
language (C/C++)'s specification, the information is permanently lost
unless explicitly attached by clang (as other dereferenceable/align/...
attributes from C/C++ do).

Previously, the flag was not activated by default because it required a lot
of tests to be updated.
This can raise conflicts with downstream patches (discussed in this thread:
D82317 <https://reviews.llvm.org/D82317>)

To avoid conflicts, I'd like to update requested tests by simply adding
`-disable-noundef-analysis` at `// RUN: %clang_cc1 ...` rather than
updating their texts (which is what D108453 is already doing).
For the requested directories or tests, I'll simply add the flag to the
`RUN:` command.
This will reduce the opportunity of raising conflicts with downstreams.

Any questions or concerns about enabling the flag are appreciated.
The two patches are written by Hyeongyu Kim, and I'm a messenger for the
patches. :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210823/0a7e8531/attachment.html>

More information about the llvm-dev mailing list