This is an archive of the discontinued LLVM Phabricator instance.

[GISel]: While constructing the GISelWorklist make sure we reserve at least the required size to the underlying dense map.
ClosedPublic

Authored by aditya_nandakumar on Feb 7 2019, 4:47 PM.

Details

Summary

This should save some unnecessary growing of the DenseMap.

Note: We should also provide a reserve interface to the GISelWorkList which can be runtime initialized to either the template parameter or the number of instructions in the MachineFunction. I can do this in a subsequent patch..

Diff Detail

Repository
rL LLVM

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2019, 4:47 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm added a comment.Feb 7 2019, 4:52 PM

LGTM

include/llvm/CodeGen/GlobalISel/GISelWorkList.h
32

If this matters, should this even be a SmallVector?

aditya_nandakumar marked an inline comment as done.Feb 7 2019, 4:54 PM
aditya_nandakumar added inline comments.
include/llvm/CodeGen/GlobalISel/GISelWorkList.h
32

Could you elaborate? Are you implying we replace this with something else (std::vector) or implying that the template parameter is probably not needed and we can always runtime reserve the size once..

arsenm added inline comments.Feb 7 2019, 5:00 PM
include/llvm/CodeGen/GlobalISel/GISelWorkList.h
32

Yes, if this is is big, there's no reason for the reserved small size so std::vector

aditya_nandakumar marked an inline comment as done.Feb 7 2019, 5:07 PM
aditya_nandakumar added inline comments.
include/llvm/CodeGen/GlobalISel/GISelWorkList.h
32

I thought I'd run some numbers just to be sure (the 512 number we use in most places is quite arbitrary) - however we do use the GISelWorkList in some passes (out of tree) for collecting some intermediate instructions, and it's set to 16 (and we avoid heap).
Either way, I can change that (and add the interface to reserve) in a subsequent patch.

Sorry - just realized that there was an LGTM, but was not accepted.

arsenm accepted this revision.Feb 7 2019, 7:52 PM
This revision is now accepted and ready to land.Feb 7 2019, 7:52 PM