[all-commits] [llvm/llvm-project] 0d4902: [CIR] Lower string literals with high-bit bytes (#...

adams381 via All-commits all-commits at lists.llvm.org
Thu Jun 11 14:54:40 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d490215a541cf91b8e24e697570bb1cc938078d
      https://github.com/llvm/llvm-project/commit/0d490215a541cf91b8e24e697570bb1cc938078d
  Author: adams381 <adams at nvidia.com>
  Date:   2026-06-11 (Thu, 11 Jun 2026)

  Changed paths:
    M clang/lib/CIR/Lowering/LoweringHelpers.cpp
    A clang/test/CIR/CodeGen/string-literal-high-bytes.c

  Log Message:
  -----------
  [CIR] Lower string literals with high-bit bytes (#203384)

A string literal containing a byte >= 0x80 crashes CIR-to-LLVM lowering.
`convertStringAttrToDenseElementsAttr` builds each element's `APInt`
from a signed `char`, so a high-bit byte sign-extends to a 64-bit value
that no longer fits the 8-bit element width and trips the `APInt`
constructor assertion (`isUIntN(BitWidth, val) && "Value is not an N-bit
unsigned value"`).

Interpreting each string byte as `unsigned char` fixes it, mirroring
what #197269 did for scalar character literals. The string-literal array
path was the remaining site with the same defect, and the lowered LLVM
is byte-identical to classic CodeGen.

Repro: `char s[] = "\x80";` compiled with `-fclangir -emit-llvm`. This
also clears a cluster of SingleSource gcc-torture globals that embed
high-byte string data.

These globals compiled until #198427 removed the trailing-zeros
fast-path in the same lowering. String literals always carry a null
terminator (trailing zeros), so they previously took the insertvalue
path and never reached `convertStringAttrToDenseElementsAttr`; #198427
routes them through it and exposed this latent sign-extension bug.



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