[WebAssembly] Fix memory bug introduced in 5286180999

Summary:
The instruction at `DefI` can sometimes be destroyed by
`rematerializeCheapDef`, so it should not be used after calling that
function. The fix is to use `Insert` instead when examining additional
multivalue stackifications. `Insert` is the address of the new
defining instruction after all moves and rematerializations have taken
place.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74875
This commit is contained in:
Thomas Lively 2020-02-19 15:01:47 -08:00
parent 709fd989b6
commit 16aabc86e0
1 changed files with 2 additions and 2 deletions

View File

@ -923,9 +923,9 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) {
// Stackifying a multivalue def may unlock in-place stackification of
// subsequent defs. TODO: Handle the case where the consecutive uses are
// not all in the same instruction.
auto *SubsequentDef = DefI->defs().begin();
auto *SubsequentDef = Insert->defs().begin();
auto *SubsequentUse = &Use;
while (SubsequentDef != DefI->defs().end() &&
while (SubsequentDef != Insert->defs().end() &&
SubsequentUse != Use.getParent()->uses().end()) {
if (!SubsequentDef->isReg() || !SubsequentUse->isReg())
break;