[llvm] [InstCombine] Create new instructions instead of in-place operand replacement (PR #115988)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 28 07:49:09 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)
----------------
nikic wrote:

`AttributeList::FirstArgIndex + 0/1`. 0 are the return attributes.

https://github.com/llvm/llvm-project/pull/115988


More information about the llvm-commits mailing list