[BOLT] Refactor branch analysis code.

Summary:
Move the indirect branch analysis code from BinaryFunction to MCInstrAnalysis/X86MCTargetDesc.cpp.

In the process of doing this, I've added an MCRegInfo to MCInstrAnalysis which allowed me to remove a bunch of extra method parameters.  I've also had to refactor how BinaryFunction held on to instructions/offsets so that it would be easy to pass a sequence of instructions to the analysis code (rather than a map keyed by offset).

Note: I think there are a bunch of MCInstrAnalysis methods that have a BitVector output parameter that could be changed to a return value since the size of the vector is based on the number of registers, i.e. from MCRegisterInfo.  I haven't done this in order to keep the diff a more manageable size.

(cherry picked from FBD6213556)
This commit is contained in:
Bill Nell
2017-11-01 10:26:07 -07:00
committed by Maksim Panchenko
parent 9e42885d04
commit 46866f5fa0
11 changed files with 119 additions and 319 deletions

View File

@@ -93,7 +93,7 @@ void RegAnalysis::beConservative(BitVector &Result) const {
Result.set();
} else {
BitVector BV(BC.MRI->getNumRegs(), false);
BC.MIA->getCalleeSavedRegs(BV, *BC.MRI);
BC.MIA->getCalleeSavedRegs(BV);
BV.flip();
Result |= BV;
}
@@ -104,7 +104,7 @@ bool RegAnalysis::isConservative(BitVector &Vec) const {
return Vec.all();
} else {
BitVector BV(BC.MRI->getNumRegs(), false);
BC.MIA->getCalleeSavedRegs(BV, *BC.MRI);
BC.MIA->getCalleeSavedRegs(BV);
BV |= Vec;
return BV.all();
}
@@ -114,9 +114,9 @@ void RegAnalysis::getInstUsedRegsList(const MCInst &Inst, BitVector &RegSet,
bool GetClobbers) const {
if (!BC.MIA->isCall(Inst)) {
if (GetClobbers)
BC.MIA->getClobberedRegs(Inst, RegSet, *BC.MRI);
BC.MIA->getClobberedRegs(Inst, RegSet);
else
BC.MIA->getUsedRegs(Inst, RegSet, *BC.MRI);
BC.MIA->getUsedRegs(Inst, RegSet);
return;
}