This is an archive of the discontinued LLVM Phabricator instance.

[FuncSpec]Save compilation time by caching uses of replaced value
ClosedPublic

Authored by bin.cheng on Feb 15 2022, 1:08 AM.

Details

Summary

Hi,
This patch saves compilation time by caching uses of replace value.

We only need to do propagation on use instructions of the original value, rather than the replacing const value which might have lots of irrelavant uses. As an example, it improves LTO compilation time by 3~4% for one example case in speccpu2017 with Function Specialization enabled.

Thanks,
bin

Diff Detail

Event Timeline

bin.cheng created this revision.Feb 15 2022, 1:08 AM
bin.cheng requested review of this revision.Feb 15 2022, 1:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 15 2022, 1:08 AM
ChuanqiXu accepted this revision.Feb 15 2022, 1:32 AM

LGTM. It would better add [NFC] tag in the title.

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
347

// Cache uses of V so that we could avoid visiting unwanted users of Const.

This revision is now accepted and ready to land.Feb 15 2022, 1:32 AM
SjoerdMeijer accepted this revision.Feb 15 2022, 1:42 AM

Yeah, nice patch, thanks.

I was wondering if this was really caching and if it should be called something else, but I guess it is, it's cached very shortly/briefly, so it's alright. :)

llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
348

Nit, quoting from the programmers manual:

it is recommended to use SmallVector<T> (that is, omitting the N)