[llvm] [AMDGPU] Sign extend simm16 in setreg intrinsic (PR #77997)
Stanislav Mekhanoshin via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 11:20:14 PST 2024
rampitec wrote:
> This broke UBSan bots
>
> ```
> RUN: at line 2: /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -march=amdgcn -mcpu=verde -verify-machineinstrs -show-mc-encoding < /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll | /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -check-prefixes=GFX6 /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
> + /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/llc -march=amdgcn -mcpu=verde -verify-machineinstrs -show-mc-encoding
> + /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -check-prefixes=GFX6 /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
> /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/AMDGPU/SIModeRegister.cpp:288:27: runtime error: shift exponent 32 is too large for 32-bit type 'int'
> SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Target/AMDGPU/SIModeRegister.cpp:288:27 in
> FileCheck error: '<stdin>' is empty.
> FileCheck command line: /b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck -check-prefixes=GFX6 /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setreg.ll
> ```
Thanks. The culprit is not the patch itself, but the added test has uncovered pre-existing problem:
```
unsigned Mask = ((1 << Width) - 1) << Offset;
```
The test runs this part of code with Width == 32 which overflows unsigned int.
https://github.com/llvm/llvm-project/pull/77997
More information about the llvm-commits
mailing list