Suggested fix for bugs: https://github.com/llvm/llvm-project/issues/58297, https://github.com/llvm/llvm-project/issues/55136
Add a check that we're not attempting to move a multivalue instruction past any of it's users.
Differential D137824
[WebAssembly] multivalue stackify fix samparker on Nov 11 2022, 3:25 AM. Authored by
Details
Suggested fix for bugs: https://github.com/llvm/llvm-project/issues/58297, https://github.com/llvm/llvm-project/issues/55136 Add a check that we're not attempting to move a multivalue instruction past any of it's users.
Diff Detail Event Timeline
Comment Actions I don't know if you've seen it, but we have a multivalue-stackify.py script that tries to exhaustively enumerate multivalue sequences up to a certain size then filter out the uninteresting ones. The output is checked in as the multivalue-stackify.ll test. It may be worth playing around with that script so that it generates programs that exhibit this problem.
Comment Actions
Cool! My python isn't great tbh... but looking through the generated test, I would have thought that f141 may have triggered this bug: %t0 = call {i32, i32} @op_0_to_2() %t1 = extractvalue {i32, i32} %t0, 1 call void @op_1_to_0(i32 %t1) %t2 = extractvalue {i32, i32} %t0, 0 call void @op_1_to_0(i32 %t2) ret void %0:i32, %1:i32 = CALL @op_0_to_2, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64 CALL @op_1_to_0, %1, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64 CALL @op_1_to_0, %0, implicit-def dead $arguments, implicit $sp32, implicit $sp64, implicit-def dead $arguments, implicit $sp32, implicit $sp64 RETURN implicit-def dead $arguments Is it the fact that the users are calls and this prevents a move from being attempted..? Comment Actions Yeah, I suspect you're right that the function calls are inhibiting the moves. It would be nice to find a way around that, but looking at the code it looks like it will refuse to reorder a pair of calls no matter what attributes the callee has. I suppose we could add a debug-only flag to change that behavior, but it's probably not worth it. Maybe the script could emit instructions other than function calls instead... Anyway, mostly LGTM with the exception that it would be good to make the test even easier to read.
|
This doesn't sound quite right. As a counterexample, consider
Here we have a subsequent def (of b) used by a different instruction (baz), but we can still stackify by moving baz before bar.
It would be good to reduce the test case to figure out more precisely what the problem is and come up with a more precise solution. Maybe the problem is that baz and bar (or rather their equivalents in the test) cannot be reordered?