[llvm] [LLVM][Auto-Upgrade] Support default args on undeclared multi-call upgrades (PR #216246)
Durgadoss R via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 20 05:10:12 PDT 2026
================
@@ -5394,33 +5397,32 @@ static bool upgradeIntrinsicCallWithDefaultArgs(CallBase *CI, Function *NewFn,
unsigned OldArgCount = CI->arg_size();
unsigned NewArgCount = NewFn->arg_size();
- // If the caller already supplied all arguments (or more), nothing to do.
- // This mirrors C++ semantics: an explicitly-passed value is never overridden.
- if (OldArgCount >= NewArgCount)
+ if (OldArgCount > NewArgCount)
return false;
- // Start with the existing arguments from the old call.
- SmallVector<Value *, 8> NewArgs(CI->args());
+ if (OldArgCount == NewArgCount) {
+ if (CI->getFunctionType() != NewFn->getFunctionType())
+ return false;
+ CI->setCalledFunction(NewFn);
+ return true;
+ }
- // Defaults are a contiguous trailing block, so checking the first missing
- // argument is enough.
if (OldArgCount < FirstDefault)
return false;
- // Fill in each missing trailing argument from the table.
+ SmallVector<Value *, 8> NewArgs(CI->args());
+
FunctionType *NewFT = NewFn->getFunctionType();
for (unsigned Idx = OldArgCount; Idx < NewArgCount; ++Idx) {
assert(Idx >= FirstDefault && Idx - FirstDefault < Defaults.size() &&
"missing argument outside the default range");
Type *ParamTy = NewFT->getParamType(Idx);
- // Only integer types are supported (i1, i8, i16, i32, i64).
if (!ParamTy->isIntegerTy())
return false;
NewArgs.push_back(ConstantInt::get(ParamTy, Defaults[Idx - FirstDefault]));
}
- // Preserve operand bundles by creating the call with them.
----------------
durga4github wrote:
let us have this one too
https://github.com/llvm/llvm-project/pull/216246
More information about the llvm-commits
mailing list