[llvm] [InlineSpiller] Do not fold undef copies (PR #147392)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 8 09:22:46 PDT 2025


================
@@ -946,6 +946,9 @@ foldMemoryOperand(ArrayRef<std::pair<MachineInstr *, unsigned>> Ops,
     if (MO.isUse() && !MO.readsReg() && !MO.isTied())
       continue;
 
+    if (MI->isCopy() && MI->getOperand(1).isUndef())
----------------
jrbyrnes wrote:

> There also might still be a better way to do this at the failure point

I guess instead of creating undef copies we can just create implicit_defs. Seems like sort of an ad-hoc requirement, but cleanupFailedVReg seems like a hack anyways.

> undef read case is already handled above here by the !readsReg check?

Do you mean the dest of an undef copy should be !readsReg ? This is checking conditions of the register we plan to spill / fold, so, in this case, the dest of the copy. 

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


More information about the llvm-commits mailing list