This is an archive of the discontinued LLVM Phabricator instance.

[Passes] Add PassBuilderContext
Needs ReviewPublic

Authored by nikic on Mar 17 2023, 3:57 AM.

Details

Reviewers
aeubanks
asbirlea
Summary

Using the NewPM requires a whole bunch of magic incantations -- you need to declare all the different pass managers, register all analysis passes and cross-register the proxies. This boilerplate always looks the same.

This patch adds a PassBuilderContext, which stores both the PassBuilder and the various analysis managers, and exposes a method to perform the analysis registration. This is more convenient for most uses of PassBuilder that aren't doing anything complicated.

Diff Detail

Event Timeline

nikic created this revision.Mar 17 2023, 3:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 3:57 AM
nikic requested review of this revision.Mar 17 2023, 3:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2023, 3:57 AM
nikic added inline comments.Mar 17 2023, 4:00 AM
llvm/include/llvm/Passes/PassBuilder.h
712

Not entirely sure whether PassInstrumentationCallbacks should be part of this or not. This is mostly used in conjunction with StandardInstrumentations, so maybe it doesn't belong here.

I've thought about doing this a couple of times, thanks for bring this up

I've had the thought that perhaps PassInstrumentation plus all the analysis managers should just be in PassBuilder itself (instead of a separate wrapper around PassBuilder), WDYT?

llvm/include/llvm/Passes/PassBuilder.h
712

I think it does belong here, and I'd even by default add StandardInstrumentations.

there's the issue that optnone handling is done in StandardInstrumentations, which honestly is pretty bad since users don't have to register StandardInstrumentations (that's my bad from when I just joined). maybe PassInstrumentation should by default register StandardInstrumentations