[llvm] [SPIR-V] Diagnose out-of-bounds argument index in function type metadata (PR #200601)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 03:16:13 PDT 2026
================
@@ -66,13 +66,15 @@ static FunctionType *extractFunctionTypeFromMetadata(NamedMDNode *NMD,
if (auto *Const = getConstInt(MD, 0)) {
auto *CMeta = dyn_cast<ConstantAsMetadata>(MD->getOperand(1));
assert(CMeta && "ConstantAsMetadata operand is expected");
- assert(Const->getSExtValue() >= -1);
+ int64_t Idx = Const->getSExtValue();
// Currently -1 indicates return value, greater values mean
// argument numbers.
- if (Const->getSExtValue() == -1)
+ if (Idx < -1 || (Idx >= 0 && static_cast<uint64_t>(Idx) >= PTys.size()))
----------------
aobolensk wrote:
It seems I have overcomplicated it a little bit. Your way looks good to me. Applied, thanks
https://github.com/llvm/llvm-project/pull/200601
More information about the llvm-commits
mailing list