[all-commits] [llvm/llvm-project] 213709: [CLANG] Fix Static Code Analyzer Concerns with bad...

smanna12 via All-commits all-commits at lists.llvm.org
Thu Jun 22 13:30:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 213709e7be031751170f04b05203b3228f87850a
      https://github.com/llvm/llvm-project/commit/213709e7be031751170f04b05203b3228f87850a
  Author: Manna, Soumi <soumi.manna at intel.com>
  Date:   2023-06-22 (Thu, 22 Jun 2023)

  Changed paths:
    M clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

  Log Message:
  -----------
  [CLANG] Fix Static Code Analyzer Concerns with bad bit right shift operation in getNVPTXLaneID()

In getNVPTXLaneID(CodeGenFunction &), the value of LaneIDBits is 4294967295 since function call llvm::Log2_32(CGF->getTarget()->getGridValue().GV_Warp_Size) might return 4294967295.

  unsigned LaneIDBits =
       llvm::Log2_32(CGF.getTarget().getGridValue().GV_Warp_Size);
  unsigned LaneIDMask = ~0u >> (32u - LaneIDBits);

The shift amount (32U - LaneIDBits) might be 33, So it has undefined behavior for right shifting by more than 31 bits.

This patch adds an assert to guard the LaneIDBits overflow issue with LaneIDMask value.

Reviewed By: tahonermann

Differential Revision: https://reviews.llvm.org/D151606




More information about the All-commits mailing list