Files
Drew Kersnar 3255d4d762 [Bitcode] Decode small byte constants as signed values (#203408)
Decode small byte constants the same way we encode them. The bitcode
writer stores ConstantByte values as signed integers, so the reader must
rebuild them using the signed ConstantByte::get path. This has high-bit
values like b8 255 round-trip as their canonical signed form, b8 -1,
instead of tripping the APInt width assertion. This matches current i8
behavior.

Before the fix, the new test crashes in llvm-dis with: "APInt.h:
Assertion `llvm::isUIntN(BitWidth, val) && "Value is not an N-bit
unsigned value"' failed."

Bug found while investigating this PR
(https://github.com/llvm/llvm-project/pull/177908), which transitions
the LSV to emitting the byte type. Fix assisted by AI.
2026-06-12 09:35:28 -05:00

8 lines
245 B
LLVM

; RUN: llvm-as < %s | llvm-dis | FileCheck %s
; CHECK: @byte.highbit = constant b8 -1
@byte.highbit = constant b8 255
; CHECK: @byte.vector.highbit = constant <2 x b8> <b8 -128, b8 -1>
@byte.vector.highbit = constant <2 x b8> <b8 128, b8 255>