This is an archive of the discontinued LLVM Phabricator instance.

[NewPM] Fix wrong perfect forwardings
ClosedPublic

Authored by vhscampos on Jul 16 2021, 6:35 AM.

Details

Summary

Some template functions were missing '&&' in function arguments,
therefore these were always taken by value after template instantiation.

This patch adds the double ampersand to introduce proper perfect
forwarding.

Diff Detail

Event Timeline

vhscampos created this revision.Jul 16 2021, 6:35 AM
vhscampos requested review of this revision.Jul 16 2021, 6:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2021, 6:35 AM

there are a couple more adaptors in CGSCCPassManager.h and LoopPassManager.h, should those be udpated too?

vhscampos updated this revision to Diff 359743.Jul 19 2021, 4:23 AM

Fixes in other places of the new pass manager.

@aeubanks Yes, thank you. Just did that.

vhscampos retitled this revision from [NewPM] Fix wrong perfect forwarding in createModuleToFunctionPassAdaptor to [NewPM] Fix wrong perfect forwardings.Jul 19 2021, 8:20 AM
vhscampos edited the summary of this revision. (Show Details)
aeubanks added inline comments.Jul 19 2021, 8:32 AM
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
136

forward?

148

forward?

490

forward?

vhscampos marked 3 inline comments as done.Jul 19 2021, 8:47 AM
vhscampos added inline comments.
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
136

Pass is an rvalue reference.

Note that the type of 'Pass' is RepeatedPass<PassT>, not PassT, i.e. it does not have the type of the template. Which means that perfect forwarding doesn't work here. Therefore we'd need one implementation for lvalue ref and another for rvalue ref. Since this function is called only passing rvalues, it is safe to have only the rvalue reference version.

148

Same reason as above.

490

In this case here, LPM is fixed as an rvalue reference, so no need for forwarding. That means that it accepts only calls that pass an rvalue. This is true for all call sites.

This revision is now accepted and ready to land.Jul 19 2021, 8:48 AM
vhscampos marked 3 inline comments as done.Jul 19 2021, 8:55 AM

Thanks for your review

This revision was landed with ongoing or failed builds.Jul 19 2021, 9:21 AM
This revision was automatically updated to reflect the committed changes.