[llvm] [IR] Use `uint64_t` when assigning `getZExtValue` into `I` (PR #224648)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 07:20:35 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Igor Wodiany (IgWod)
<details>
<summary>Changes</summary>
This prevents a potential multiplication overflow when a constant is later built with `ConstantInt::get()`. This fixes an issues reported by a CodeQL scan.
---
Full diff: https://github.com/llvm/llvm-project/pull/224648.diff
1 Files Affected:
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 75fc03c22222bb..16ff20a3d99469 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -5915,7 +5915,7 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
}
auto *RetTy = cast<ScalableVectorType>(F->getReturnType());
unsigned MinElts = RetTy->getMinNumElements();
- unsigned I = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
+ uint64_t I = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
Value *NewIdx = ConstantInt::get(Type::getInt64Ty(C), I * MinElts);
NewCall = Builder.CreateCall(NewFn, {CI->getArgOperand(0), NewIdx});
break;
@@ -5929,7 +5929,7 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
return;
}
if (Name.starts_with("aarch64.sve.tuple.set")) {
- unsigned I = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
+ uint64_t I = cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
auto *Ty = cast<ScalableVectorType>(CI->getArgOperand(2)->getType());
Value *NewIdx =
ConstantInt::get(Type::getInt64Ty(C), I * Ty->getMinNumElements());
``````````
</details>
https://github.com/llvm/llvm-project/pull/224648
More information about the llvm-commits
mailing list