diff options
author | Philip Reames <preames@rivosinc.com> | 2025-09-23 11:57:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-23 11:57:36 -0700 |
commit | ca2e8fc928ad103f46ca9f827e147c43db3a5c47 (patch) | |
tree | 1524c906fa7d3e9f4bd8474f8f21222b383f92aa /llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | |
parent | 721d1a009e528e66d788e7b3c17800633dc7bd24 (diff) | |
download | llvm-ca2e8fc928ad103f46ca9f827e147c43db3a5c47.zip llvm-ca2e8fc928ad103f46ca9f827e147c43db3a5c47.tar.gz llvm-ca2e8fc928ad103f46ca9f827e147c43db3a5c47.tar.bz2 |
Update callers of isTriviallyReMaterializable to check trivialness (#160319)
This is a preparatory change for an upcoming reorganization of our
rematerialization APIs. Despite the interface being documented as
"trivial" (meaning no virtual register uses on the instruction being
considered for remat), our actual implementation inconsistently supports
non-trivial remat, and certain backends (AMDGPU and RISC-V mostly) lie
about instructions being trivial to abuse that. We want to allow
non-triial remat more broadly, but first we need to do some cleanup to
make it understandable what's going on.
These three call sites are ones which appear to actually want the
trivial definition, and appear fairly low risk to change.
p.s. I'm deliberately *not* updating any APIs in this change, I'm going
to do that as a followup once it's clear which category each callsite
fits in.
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp index 08ca20b5..7591541 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -260,7 +260,10 @@ static void query(const MachineInstr &MI, bool &Read, bool &Write, // Test whether Def is safe and profitable to rematerialize. static bool shouldRematerialize(const MachineInstr &Def, const WebAssemblyInstrInfo *TII) { - return Def.isAsCheapAsAMove() && TII->isTriviallyReMaterializable(Def); + return Def.isAsCheapAsAMove() && TII->isTriviallyReMaterializable(Def) && + llvm::all_of(Def.all_uses(), [](const MachineOperand &MO) { + return MO.getReg().isVirtual(); + }); } // Identify the definition for this register at this point. This is a |