This is an archive of the discontinued LLVM Phabricator instance.

Add new pass LazyMachineBlockFrequencyInfo
ClosedPublic

Authored by anemet on Feb 10 2017, 10:41 AM.

Details

Summary

And use it in MachineOptimizationRemarkEmitter. A test will follow on top of
Justin's changes to enable MachineORE in AsmPrinter.

The approach is similar to the IR-level pass. It's a bit simpler because BPI
is immutable at the Machine level so we don't need to make that lazy.

Because of this a new function mapping is introduced (calculateBPI) at the
IR-agnostic LazyBlockFrequencyInfo class. This function calculates and
extracts BPI from the pass. For Machine-level, this is the identity function

Event Timeline

anemet created this revision.Feb 10 2017, 10:41 AM
davidxl added inline comments.Feb 12 2017, 8:56 PM
include/llvm/Analysis/LazyBlockFrequencyInfo.h
38

It is quite confusing to read the code here regarding xxxInfo, xxxInfoPass and default parameters. It may be more readable to get rid of the last parameter, but instead do this:

class LazyBranchProbabilityInfoPass ... {
public:

   typedef BranchProbablityInfo BPIType;
...

};

class MachineBranchProbablityInfo ... {
public:

typedef MachineBranchProbabilityInfo BPIType;

..
};

and then

template <...>
class LazyBlockFrequencyInfo {

typedef typename BranchProbablityInfoPassT::BPIType BranchProbablityInfoT;
 ...

};

anemet updated this revision to Diff 88309.Feb 13 2017, 10:37 PM

Redo the mapping from the BPI pass to the BPInfo

anemet added inline comments.Feb 13 2017, 10:37 PM
include/llvm/Analysis/LazyBlockFrequencyInfo.h
38

I agree that it's not the most readable but I wanted to keep the type info of the mapping and the actual mapping function together.

I've completely redone this part of the patch. Now we just have a trait class that provides the mapping function for each BPI pass. Let me know if this works for you.

anemet updated this revision to Diff 88310.Feb 13 2017, 10:43 PM

No need to include <functional> anymore.

This revision is now accepted and ready to land.Feb 13 2017, 10:52 PM
This revision was automatically updated to reflect the committed changes.