This is an archive of the discontinued LLVM Phabricator instance.

[GlobalOpt] Replace recursion with extended worklist
Needs ReviewPublic

Authored by jdoerfert on Apr 3 2021, 1:38 PM.

Details

Summary

As noted in D99845, there is a worklist already but we do recursion
because other values change. This tracks them in the worklist and
removes the recursion.

Diff Detail

Event Timeline

jdoerfert created this revision.Apr 3 2021, 1:38 PM
jdoerfert requested review of this revision.Apr 3 2021, 1:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 3 2021, 1:38 PM
Herald added a subscriber: wdng. · View Herald Transcript
lebedev.ri accepted this revision.Apr 3 2021, 1:44 PM

LGTM, thanks!

llvm/lib/Transforms/IPO/GlobalOpt.cpp
296
This revision is now accepted and ready to land.Apr 3 2021, 1:44 PM
lebedev.ri requested changes to this revision.Apr 3 2021, 1:46 PM
lebedev.ri added inline comments.
llvm/lib/Transforms/IPO/GlobalOpt.cpp
336–339

We need to track hopefully-dead-in-the-end instrs in some vector, and delete them if they are unused.

This revision now requires changes to proceed.Apr 3 2021, 1:46 PM
jdoerfert added inline comments.Apr 3 2021, 5:09 PM
llvm/lib/Transforms/IPO/GlobalOpt.cpp
336–339

Not totally sure what you want me to do.

TBH, I thought this would help me but it turns out some dead-constant user that are floating around prevent my global array from ever making it this far.

I'll clean up my Attributor code and get rid of my global arrays. Also need to do some value prop through another one that is not picked up IPSCCP, so might be worth to find a wholesome solution.

384

This return true is wrong now.

jdoerfert updated this revision to Diff 335120.Apr 3 2021, 6:27 PM

Address review, fix return mistake

lebedev.ri added inline comments.Apr 4 2021, 2:41 AM
llvm/lib/Transforms/IPO/GlobalOpt.cpp
336–339

Previously, CE would not have users by now because we recursed,
and got to the condition after we've dealt with it's users.
Now, we get here after we enqueue it's users,
so naturally, it won't have no users by now.
So we need to defer it's destruction until after we've done with the worklist.

lebedev.ri requested changes to this revision.Apr 7 2021, 12:45 PM
This revision now requires changes to proceed.Apr 7 2021, 12:45 PM
lebedev.ri resigned from this revision.Jan 12 2023, 4:50 PM

This review seems to be stuck/dead, consider abandoning if no longer relevant.

This revision now requires review to proceed.Jan 12 2023, 4:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 4:50 PM