[llvm] [InstCombine] Create new instructions instead of in-place operand replacement (PR #115988)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 28 08:40:38 PDT 2026
================
@@ -923,6 +923,15 @@ static CallInst *canonicalizeConstantArg0ToArg1(CallInst &Call) {
if (isa<Constant>(Arg0) && !isa<Constant>(Arg1)) {
Call.setArgOperand(0, Arg1);
Call.setArgOperand(1, Arg0);
+ auto CallAttr = Call.getAttributes();
+ auto LHSAttr = CallAttr.getParamAttrs(0);
+ auto RHSAttr = CallAttr.getParamAttrs(1);
+ LLVMContext &Ctx = Call.getContext();
+ Call.setAttributes(
+ CallAttr.removeAttributesAtIndex(Ctx, 0)
+ .removeAttributesAtIndex(Ctx, 1)
----------------
dtcxzyw wrote:
Nice catch!
https://github.com/llvm/llvm-project/pull/115988
More information about the llvm-commits
mailing list