[all-commits] [llvm/llvm-project] 5a194c: [msan] Sharpen instrumentation of Intrinsic::{ctlz...

Thurston Dang via All-commits all-commits at lists.llvm.org
Wed Jun 25 09:30:21 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5a194c1fd97b10fdbdbd8ada85372d978c9ff3c4
      https://github.com/llvm/llvm-project/commit/5a194c1fd97b10fdbdbd8ada85372d978c9ff3c4
  Author: Thurston Dang <thurston at google.com>
  Date:   2025-06-25 (Wed, 25 Jun 2025)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
    M llvm/test/Instrumentation/MemorySanitizer/count-zeroes.ll

  Log Message:
  -----------
  [msan] Sharpen instrumentation of Intrinsic::{ctlz,cttz} (#145609)

The current instrumentation of Intrinsic::{ctlz,cttz} has false positives. For example, consider `ctlz(0001 11??)` whereby `0` and `1` denotes initialized bits (with concrete values of 0 and 1 respectively) and `?` denotes an uninitialized bit. The result (of 3) is well-defined and the shadow ought to be fully initialized, but the current instrumentation marks it as fully uninitialized.

This patch improves the fidelity of the instrumentation by comparing the number of leading (for ctlz; trailing for cttz) zeros in the concrete value and the shadow.

This patch also renames the function from 'handleCountZeroes' to 'handleLeadingTrailingCountZeros', to clarify that the intrinsics handled do not count all the zeros (unlike `llvm.ctpop`, which counts all the 1s).



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