This is an archive of the discontinued LLVM Phabricator instance.

[LegacyPM] Port CGProfile pass
AbandonedPublic

Authored by evgeny777 on Oct 23 2019, 2:59 AM.

Details

Summary

This allows generating CG profile using legacy pass manager

Diff Detail

Event Timeline

evgeny777 created this revision.Oct 23 2019, 2:59 AM

FYI what I heard at the dev meeting yesterday is that we are very close to being able to switch to the new PM by default, after which the legacy PM will be removed (I'm sure not immediately, but the goal is to get down to one PM soon). Before you do a lot of work backporting some of the new passes like this, is switching to the new PM an option for you?

Thanks for looking at it, Teresa!

Here is a llvm-dev post, suggesting to use new PM by default:
http://lists.llvm.org/pipermail/llvm-dev/2017-October/118280.html

As you may have noticed it was two years ago and new PM is still "brand new" :)
Also, AFAIK, codegen passes still use old PM, so I guess it will be around for quite a while.
Until new PM is adopted as default by LLVM community, switching to it is not an option for us, unfortunately.
And I need just this pass (it does pretty good job optimizing PGO instrumented images) and don't have plans to port anything else.

Thanks for looking at it, Teresa!

Here is a llvm-dev post, suggesting to use new PM by default:
http://lists.llvm.org/pipermail/llvm-dev/2017-October/118280.html

As you may have noticed it was two years ago and new PM is still "brand new" :)
Also, AFAIK, codegen passes still use old PM, so I guess it will be around for quite a while.
Until new PM is adopted as default by LLVM community, switching to it is not an option for us, unfortunately.
And I need just this pass (it does pretty good job optimizing PGO instrumented images) and don't have plans to port anything else.

Ok, still suggest trying to move to new PM proactively to make sure it works for you, but it's fine with me to back port this. A few comments below.

include/llvm/LinkAllPasses.h
87 ↗(On Diff #226107)

Formatting off

lib/Transforms/IPO/PassManagerBuilder.cpp
781 ↗(On Diff #226107)

I notice that in the new PM this is added after the OptimizerLast EPs are added. Not sure if that is intentional - should the new and old PMs be consistent here?

lib/Transforms/Instrumentation/CGProfile.cpp
30 ↗(On Diff #226107)

Nit: Suggest moving this declaration to before Symtab which puts it in the same relative order as before and should avoid a spurious diff here.

test/Other/opt-O2-pipeline.ll
290 ↗(On Diff #226107)

Will this unnamed pass issue be fixed by D69315?

This was originally not added to the legacy pass manager because it leaks memory under it due to fundamental issues with the old pass manager. See https://reviews.llvm.org/D48105#1140299 .

This was originally not added to the legacy pass manager because it leaks memory under it due to fundamental issues with the old pass manager. See https://reviews.llvm.org/D48105#1140299 .

@Bigcheese @chandlerc Can you please elaborate? I've run llvm, clang and lld test suites with lsan and everything seems good. What's the problem exactly?

evgeny777 marked 5 inline comments as done.Oct 28 2019, 9:11 AM
evgeny777 added inline comments.
test/Other/opt-O2-pipeline.ll
290 ↗(On Diff #226107)

Yes

evgeny777 updated this revision to Diff 226678.Oct 28 2019, 9:18 AM
evgeny777 marked an inline comment as done.

Addressed comments.

I've run test cases of llvm/clang built with ASAN and LSAN without problems.
If problem details can't be recalled at the moment, I suggest landing this patch and reverting it if problem arises

Herald added a project: Restricted Project. · View Herald TranscriptOct 28 2019, 9:18 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

Hi, I just noticed now that here was a patch porting CGProfile Pass to legacy PM. I created a similar one and landed it https://reviews.llvm.org/D83013.

evgeny777 abandoned this revision.Sep 11 2020, 12:58 AM