[Assignment Tracking] Elide a map copy in some cases
authorOCHyams <orlando.hyams@sony.com>
Wed, 29 Mar 2023 12:29:51 +0000 (13:29 +0100)
committerOCHyams <orlando.hyams@sony.com>
Wed, 29 Mar 2023 13:25:23 +0000 (14:25 +0100)
commitc4861e32ed9096e5f737bc938073077ce279dbcc
treeb186d60e4edfe7728441b9b1ce1f3cf11122cc5a
parenteb64450afc96730f9a6ff87c817c34185a307a0f
[Assignment Tracking] Elide a map copy in some cases

Restructure AssignmentTrackingLowering::join to avoid a map copy in the case
where BB has more than one pred.

We only need to perform a copy of a pred LiveOut if there's exactly one
already-visited pred (Result = PredLiveOut). With more than one pred the result
is built by calling Result = join(std::move(Result), PredLiveOut) for each
subsequent pred, where join parameters are const &. i.e. with more than 1 pred
we can avoid copying by referencing the first two pred LiveOuts in the first
join and then using a move + reference for the rest.

This reduces compile time for CTMark LTO-O3-g builds.

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D144732
llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp