[llvm-dev] Register pressure calculation in the machine scheduler and live-through registers

Andrew Trick via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 30 14:14:49 PDT 2017


> On Aug 30, 2017, at 1:43 PM, Matthias Braun <matze at braunis.de> wrote:
> 
> That means you cannot use the code from RegisterPressure.{cpp|h} to compute this. The other liveness analysis we have in llvm codegen is LiveIntervals (LiveItnervalAnalysis) which gives you a list of liveness segments of a given vreg (the same representation is used in most linear scan allocators even though LLVM is not using a linear scan approach any more). This representation is not optimized for register pressure queries though: If you want to know how many variables are alive at a certain point in the program you have to check all virtual registers to see whether that point is contained in the liverange of that variable.
> To make this efficient you probably need some form of precomputation over the whole function.

The code in RegisterPressure.cpp is meant to work with LiveIntervals. Those queries only see within a block but are meant to be “seeded” with live-through information. That could be done be directly calling `addLiveRegs`. Alternately you can record live-through pressure separately via `initLiveThru`. It’s just that the MachineScheduler does not bother initializing the live-through information.

As Matthias said, actually determining live-through information requires a separate global liveness analysis, because LiveIntervals doesn’t tell you “what’s live at this point”.

-Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170830/117791e3/attachment.html>


More information about the llvm-dev mailing list