This is an archive of the discontinued LLVM Phabricator instance.

[MachineLICM] delete dead flag if the duplicated def outside of loop is dead.
ClosedPublic

Authored by shchenz on Dec 3 2020, 2:03 AM.

Details

Summary

Some definitions may be dead before entering the MachineLICM pass. For example, LiveIntervals pass will mark some definition as dead if there is no user of a virtual register. Before the dead definition is eliminated, it is CSE-ed in machineLICM pass, but the dead flag in the duplicated instruction outside of loop is not cleaned, so we get verify error: Virtual register defs don't dominate all uses. (use after it is set to dead)

Create this patch to fix that issue.

Diff Detail

Event Timeline

shchenz created this revision.Dec 3 2020, 2:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2020, 2:03 AM
shchenz requested review of this revision.Dec 3 2020, 2:03 AM

gentle ping...

bjope added a subscriber: bjope.Dec 9 2020, 10:47 PM
shchenz edited the summary of this revision. (Show Details)Dec 11 2020, 12:15 AM
shchenz updated this revision to Diff 312711.Dec 18 2020, 1:04 AM
shchenz edited the summary of this revision. (Show Details)
shchenz added a reviewer: arsenm.

update the comments and gentle ping

arsenm added inline comments.Dec 18 2020, 7:22 AM
llvm/lib/CodeGen/MachineLICM.cpp
1470

Really should not be using const_cast here

llvm/test/CodeGen/PowerPC/machinelicm-cse-dead-flag.mir
5

Add a comment explaining the test

shchenz added inline comments.Dec 18 2020, 7:46 AM
llvm/lib/CodeGen/MachineLICM.cpp
1470

Thanks for your comments. Do you mean we should make LookForDuplicate() return MachineInstr * instead of return const MachineInstr *?

llvm/test/CodeGen/PowerPC/machinelicm-cse-dead-flag.mir
5

will do this later.

arsenm added inline comments.Dec 18 2020, 7:58 AM
llvm/lib/CodeGen/MachineLICM.cpp
1470

Either that, or there's a different place to make this change (I do think this is probably the right place though)

shchenz updated this revision to Diff 312808.Dec 18 2020, 8:16 AM

address @arsenm comments:
1: do not use const_cast
2: add comments for the test point in test case.

arsenm added inline comments.Dec 18 2020, 9:37 AM
llvm/test/CodeGen/PowerPC/machinelicm-cse-dead-flag.mir
46

Can you add another case where both of the defs are dead?

shchenz updated this revision to Diff 312901.Dec 18 2020, 4:22 PM

address @arsenm comments:
1: handle the case when hoisted and dup registers are both dead.

llvm/test/CodeGen/PowerPC/machinelicm-cse-dead-flag.mir
46

Good catch!

arsenm accepted this revision.Dec 19 2020, 7:14 AM
This revision is now accepted and ready to land.Dec 19 2020, 7:14 AM
This revision was landed with ongoing or failed builds.Dec 20 2020, 4:47 PM
This revision was automatically updated to reflect the committed changes.