LLVM Merges TySan As Sanitizer For Type-Based Aliasing Violations

Written by Michael Larabel in LLVM on 17 December 2024 at 09:56 AM EST. 6 Comments
LLVM
The LLVM compiler stack offers a number of sanitizers like the AddressSanitizer, MemorySanitizer, UndefinedBehaviorSanitizer, and others for detecting different coding issues like data races, memory addressing issues, use of uninitialized memory, and more. The newest sanitizer addition to LLVM mainline is TySan as a Type Sanitizer.

Merged today to LLVM Git for next year's LLVM 20 release is TySan as a sanitizer for type-based aliasing violations.

The Git commit landing the Type Sanitizer explains of this new addition:
"C/C++ have type-based aliasing rules, and LLVM's optimizer can exploit these given TBAA metadata added by Clang. Roughly, a pointer of given type cannot be used to access an object of a different type (with, of course, certain exceptions). Unfortunately, there's a lot of code in the wild that violates these rules (e.g. for type punning), and such code often must be built with -fno-strict-aliasing. Performance is often sacrificed as a result. Part of the problem is the difficulty of finding TBAA violations. Hopefully, this sanitizer will help."

The merge request dates back almost one year exactly and contains more background and discussion on this new LLVM Type Sanitizer for those interested.

LLVM Type Sanitizer slide


The idea for the Type Sanitizer isn't new but was started back in 2017 by Hal Finkel at Argonne National Laboratory. This slide deck offers more background information as well for the motives of this newest sanitizer.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week