[all-commits] [llvm/llvm-project] 5f8795: [clang][CodeGen][UBSan] Fixing shift-exponent gene...

Adam Magier via All-commits all-commits at lists.llvm.org
Tue Feb 6 11:17:08 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5f87957fefb21d454f2fd7e6b4891350170d8690
      https://github.com/llvm/llvm-project/commit/5f87957fefb21d454f2fd7e6b4891350170d8690
  Author: Adam Magier <83226568+AdamMagierFOSS at users.noreply.github.com>
  Date:   2024-02-06 (Tue, 06 Feb 2024)

  Changed paths:
    M clang/lib/CodeGen/CGExprScalar.cpp
    A clang/test/CodeGen/ubsan-shift-bitint.c

  Log Message:
  -----------
  [clang][CodeGen][UBSan] Fixing shift-exponent generation for _BitInt (#80515)

Testing the shift-exponent check with small width _BitInt values exposed
a bug in ScalarExprEmitter::GetWidthMinusOneValue when using the result
to determine valid exponent sizes. False positives were reported for
some left shifts when width(LHS)-1 > range(RHS) and false negatives were
reported for right shifts when value(RHS) > range(LHS). This patch caps
the maximum value of GetWidthMinusOneValue to fit within range(RHS) to
fix the issue with left shifts and fixes a code generation in EmitShr to
fix the issue with right shifts and renames the function to
GetMaximumShiftAmount to better reflect the new behaviour.

Fixes #80135.

Co-authored-by: Adam Magier <adam.magier at ericsson.com>




More information about the All-commits mailing list