[llvm] [Analysis][DXILResource] Correct bound computation (PR #184198)
Tex Riddell via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 10:57:57 PST 2026
================
@@ -1067,15 +1067,17 @@ void DXILResourceBindingInfo::populate(Module &M, DXILResourceTypeMap &DRTM) {
cast<ConstantInt>(CI->getArgOperand(0))->getZExtValue();
uint32_t LowerBound =
cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
- int32_t Size =
+ uint32_t Size =
cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
Value *Name = CI->getArgOperand(4);
- // negative size means unbounded resource array;
+ // UINT32_MAX (-1) size means unbounded resource array;
// upper bound register overflow should be detected in Sema
- assert((Size < 0 || (unsigned)LowerBound + Size - 1 <= UINT32_MAX) &&
+ assert((Size == UINT32_MAX ||
+ (unsigned)LowerBound + Size - 1 <= UINT32_MAX) &&
----------------
tex3d wrote:
Considering this happens in an analysis pass, it seems entirely possible to have IR that violates the `LowerBound + Size -1 <= UINT32_MAX` expectation. If that happens (and asserts are not enabled), this code would result in `LowerBound > UpperBound`. I'm not sure the best way to handle this, but producing an invalid range might not be the best option. Explicitly checking for that case and pinning the UpperBound to UINT32_MAX would probably be better.
https://github.com/llvm/llvm-project/pull/184198
More information about the llvm-commits
mailing list