[llvm] WebAssembly: Don't duplicate implicit CALL operands in LowerCallResults (PR #225069)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 04:49:26 PDT 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/225069

When recombining the CALL_PARAMS/CALL_RESULTS pseudo-pair into a real CALL,
LowerCallResults copied CallParams.uses() onto the new instruction. uses()
includes the implicit operands (implicit-def $arguments and the implicit
$sp32/$sp64 uses), which the freshly created CALL already carries. This
resulted in a duplicated implicit-def of $arguments. This avoids a future
verifier error.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>

>From 138ebe079620669ed17cc30851c90f03bbb2273b Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 18 Sep 2026 14:38:05 +0200
Subject: [PATCH] WebAssembly: Don't duplicate implicit CALL operands in
 LowerCallResults

When recombining the CALL_PARAMS/CALL_RESULTS pseudo-pair into a real CALL,
LowerCallResults copied CallParams.uses() onto the new instruction. uses()
includes the implicit operands (implicit-def $arguments and the implicit
$sp32/$sp64 uses), which the freshly created CALL already carries. This
resulted in a duplicated implicit-def of $arguments. This avoids a future
verifier error.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
 llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index ba702afbe3262..1ecd232782679 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -867,7 +867,8 @@ LowerCallResults(MachineInstr &CallResults, DebugLoc DL, MachineBasicBlock *BB,
     }
   }
 
-  for (auto Use : CallParams.uses())
+  // Avoid duplicating the implicit operands.
+  for (auto Use : CallParams.explicit_uses())
     MIB.add(Use);
 
   BB->insert(CallResults.getIterator(), MIB);



More information about the llvm-commits mailing list