News: 0001513181

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

LLVM Merges TySan As Sanitizer For Type-Based Aliasing Violations

([LLVM] 2 Hours Ago LLVM TySan)


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 [1]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."

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

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



[1] https://github.com/llvm/llvm-project/commit/a487b792e2dabcec02c63d19e32958572a257408

[2] https://github.com/llvm/llvm-project/pull/76259

[3] https://llvm.org/devmtg/2017-10/slides/Finkel-The%20Type%20Sanitizer.pdf



phoronix

The Magician of the Ivory Tower brought his latest invention for the
master programmer to examine. The magician wheeled a large black box into the
master's office while the master waited in silence.
"This is an integrated, distributed, general-purpose workstation,"
began the magician, "ergonomically designed with a proprietary operating
system, sixth generation languages, and multiple state of the art user
interfaces. It took my assistants several hundred man years to construct.
Is it not amazing?"
The master raised his eyebrows slightly. "It is indeed amazing," he
said.
"Corporate Headquarters has commanded," continued the magician, "that
everyone use this workstation as a platform for new programs. Do you agree
to this?"
"Certainly," replied the master, "I will have it transported to the
data center immediately!" And the magician returned to his tower, well
pleased.
Several days later, a novice wandered into the office of the master
programmer and said, "I cannot find the listing for my new program. Do
you know where it might be?"
"Yes," replied the master, "the listings are stacked on the platform
in the data center."
-- Geoffrey James, "The Tao of Programming"