This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Move InstCombineWorklist to Utils to allow reuse (NFC).
ClosedPublic

Authored by fhahn on Sep 21 2021, 8:50 AM.

Details

Summary

InstCombine's worklist can be re-used by other passes like
VectorCombine. Move it to llvm/Transform/Utils and rename it to
InstructionWorklist.

Diff Detail

Event Timeline

fhahn created this revision.Sep 21 2021, 8:50 AM
fhahn requested review of this revision.Sep 21 2021, 8:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 8:50 AM
fhahn updated this revision to Diff 373952.Sep 21 2021, 8:51 AM

Nice!
I'm not sure it is a good idea to just reuse part of another pass like that.
Perhaps InstCombineWorklist should be extracted+promoted to being more reusable?

Yeah, it should probably be moved. I put up D110181 to move it to Utils and rename it to InstructionWorklist.

fhahn retitled this revision from [InstCombine] Move InstCombineWorklist to Utils to allow reuse. to [InstCombine] Move InstCombineWorklist to Utils to allow reuse (NFC)..Sep 21 2021, 8:51 AM
fhahn added a comment.Sep 21 2021, 8:53 AM

Nice!
I'm not sure it is a good idea to just reuse part of another pass like that.
Perhaps InstCombineWorklist should be extracted+promoted to being more reusable?

Yeah, it should probably be moved. I put up D110181 to move it to Utils and rename it to InstructionWorklist.

The comment ended up on the wrong review, should be at D110171

lebedev.ri accepted this revision.Sep 21 2021, 8:57 AM

Now this i like!
LGTM, but please wait for @spatel.

This revision is now accepted and ready to land.Sep 21 2021, 8:57 AM

i think you want to apply some more s/instcombine/instructionworklist/ to the diff

llvm/include/llvm/Transforms/InstCombine/InstCombine.h
16–17

These need updating

llvm/include/llvm/Transforms/Utils/InstructionWorklist.h
21

Update

fhahn updated this revision to Diff 373967.Sep 21 2021, 9:26 AM

Fix include guard, remove DEBUG_TYPE from header, move it to before the individual includes.

fhahn added inline comments.Sep 21 2021, 9:31 AM
llvm/include/llvm/Transforms/Utils/InstructionWorklist.h
21

I removed it here and moved the user includes after the DEBUG_TYPE definitions at the include site. Not sure if there's a better way to customize the DEBUG_TYPE string here.

Thanks! We should have done this long ago. :)
See inline for a couple of minor points, but LGTM too.

llvm/include/llvm/Transforms/Utils/InstructionWorklist.h
21

Do we really need for the caller's DEBUG_TYPE to be set, or can we just define that here as "instruction-utils" or something like that? That's what it looks like in BasicBlockUtils.cpp (so might have to split this into a header and source file pair?).

35

Is it necessary to have that prefix? That part is just noise to me when I'm scrolling through instcombine debug spew. No tests should be depending on matching that...

fhahn updated this revision to Diff 373979.Sep 21 2021, 10:23 AM

Remove DbgPrefix.

fhahn marked 3 inline comments as done.Sep 21 2021, 10:27 AM
fhahn added inline comments.
llvm/include/llvm/Transforms/Utils/InstructionWorklist.h
21

I think we could just use a different DEBUG_TYPE here, but then we would miss update messages from the worklist with -debug-only=instcombine. Not sure if that's preferable?

35

I removed the prefix part for now.

lebedev.ri added inline comments.Sep 21 2021, 10:29 AM
llvm/include/llvm/Transforms/Utils/InstructionWorklist.h
21

I think the current patch as-is is fine.

This revision was landed with ongoing or failed builds.Sep 22 2021, 12:48 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked 2 inline comments as done.
fhahn added a comment.Sep 22 2021, 3:08 AM

Hmm, it looks like this broke the build with explicit modules ( -DLLVM_ENABLE_MODULES=On). I'm currently checking to see what the options are for unbreaking the build.

Hmm, it looks like this broke the build with explicit modules ( -DLLVM_ENABLE_MODULES=On). I'm currently checking to see what the options are for unbreaking the build.

@teemperor fixed the issue in a5e1c746b870d79142419a07a8aecc471eacfed1, thanks!