This is an archive of the discontinued LLVM Phabricator instance.

Fix minor deficiency in MachineSink.
ClosedPublic

Authored by markus on Oct 11 2021, 3:17 AM.

Details

Summary

Seems that physical register uses of registers that are MRI->isConstantPhysReg() incorrectly inhibited transformation (the comment in the code is talking about "zombie" define and NOT uses).

Diff Detail

Event Timeline

markus created this revision.Oct 11 2021, 3:17 AM
markus requested review of this revision.Oct 11 2021, 3:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2021, 3:17 AM
StephenTozer accepted this revision.Nov 11 2021, 4:07 AM

Seems straightforward enough to me, the code block in question clearly only cares about preg defs for the purposes of sinking. LGTM, with one inline nit.

llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
6

Remove double "is a".

This revision is now accepted and ready to land.Nov 11 2021, 4:07 AM
StephenTozer added inline comments.Nov 11 2021, 4:08 AM
llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
2

Also just to add, does this need "-x mir"? I see some of the other llc tests on MIR files use it, but I don't know if it's actually required.

Found one issue with the test (noted inline), but otherwise no issues.

llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
36

I've just run the test, and it seems that this last line causes a parse error for llc; otherwise the test seems to work as written.

markus added inline comments.Nov 11 2021, 5:03 AM
llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
2

The majority of MIR tests depend on having llc detecting the input language from the filename extension and not using -x mir AFAICT.

36

Hmm, what exactly are you running then?
When I run

./bin/llvm-lit ../llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir

it passes without issues.

StephenTozer added inline comments.Nov 11 2021, 5:30 AM
llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
36

The command:

python .\build\Release\bin\llvm-lit.py llvm\test\CodeGen\RISCV\MachineSink-implicit-x0.mir

fails with:

$ ":" "RUN: at line 1"
$ "d:\upstream-llvm\build\release\bin\llc.exe" "-mtriple=riscv32" "D:\upstream-llvm\llvm\test\CodeGen\RISCV\MachineSink-implicit-x0.mir" "-run-pass=machine-sink" "-o" "-"
# command stderr:
error: YAML:35:1: not a mapping
---
^~~

Deleting the dashes causes it to pass. This is with python 3.9.7 and an up-to-date build of LLVM from trunk (82b74363a9).

StephenTozer added inline comments.Nov 11 2021, 5:37 AM
llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
36

Also, this is a windows build - and I've just confirmed that when running the tests on linux, the final line does not affect the test, so this is presumably platform-dependent.

StephenTozer added inline comments.Nov 11 2021, 5:47 AM
llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
36

Alright, I've figured it out - when I applied the patch, the test file didn't contain the final newline, which was messing with YAML parsing. This should be fine as-is, apologies for the wasted time!

markus added inline comments.Nov 11 2021, 5:55 AM
llvm/test/CodeGen/RISCV/MachineSink-implicit-x0.mir
36

Ah, right. I was not able to reproduce on linux but I will change it anyways since I see now that it is not present in other .mir tests. Not sure where I picked it up from.

No worries. Thanks for reviewing :)

This revision was landed with ongoing or failed builds.Nov 11 2021, 11:16 PM
This revision was automatically updated to reflect the committed changes.