Temporarily Revert "Move most EH from MachineModuleInfo to MachineFunction"
This apprears to have broken the global isel bot: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-globalisel_build/5174/console This reverts commit r288293. llvm-svn: 288322
This commit is contained in:
@@ -568,193 +568,6 @@ MCSymbol *MachineFunction::getPICBaseSymbol() const {
|
||||
Twine(getFunctionNumber()) + "$pb");
|
||||
}
|
||||
|
||||
/// \name Exception Handling
|
||||
/// \{
|
||||
|
||||
LandingPadInfo &
|
||||
MachineFunction::getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad) {
|
||||
unsigned N = LandingPads.size();
|
||||
for (unsigned i = 0; i < N; ++i) {
|
||||
LandingPadInfo &LP = LandingPads[i];
|
||||
if (LP.LandingPadBlock == LandingPad)
|
||||
return LP;
|
||||
}
|
||||
|
||||
LandingPads.push_back(LandingPadInfo(LandingPad));
|
||||
return LandingPads[N];
|
||||
}
|
||||
|
||||
void MachineFunction::addInvoke(MachineBasicBlock *LandingPad,
|
||||
MCSymbol *BeginLabel, MCSymbol *EndLabel) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
LP.BeginLabels.push_back(BeginLabel);
|
||||
LP.EndLabels.push_back(EndLabel);
|
||||
}
|
||||
|
||||
MCSymbol *MachineFunction::addLandingPad(MachineBasicBlock *LandingPad) {
|
||||
MCSymbol *LandingPadLabel = Ctx.createTempSymbol();
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
LP.LandingPadLabel = LandingPadLabel;
|
||||
return LandingPadLabel;
|
||||
}
|
||||
|
||||
void MachineFunction::addCatchTypeInfo(MachineBasicBlock *LandingPad,
|
||||
ArrayRef<const GlobalValue *> TyInfo) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
for (unsigned N = TyInfo.size(); N; --N)
|
||||
LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1]));
|
||||
}
|
||||
|
||||
void MachineFunction::addFilterTypeInfo(MachineBasicBlock *LandingPad,
|
||||
ArrayRef<const GlobalValue *> TyInfo) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
std::vector<unsigned> IdsInFilter(TyInfo.size());
|
||||
for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
|
||||
IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
|
||||
LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
|
||||
}
|
||||
|
||||
void MachineFunction::tidyLandingPads(DenseMap<MCSymbol*, uintptr_t> *LPMap) {
|
||||
for (unsigned i = 0; i != LandingPads.size(); ) {
|
||||
LandingPadInfo &LandingPad = LandingPads[i];
|
||||
if (LandingPad.LandingPadLabel &&
|
||||
!LandingPad.LandingPadLabel->isDefined() &&
|
||||
(!LPMap || (*LPMap)[LandingPad.LandingPadLabel] == 0))
|
||||
LandingPad.LandingPadLabel = nullptr;
|
||||
|
||||
// Special case: we *should* emit LPs with null LP MBB. This indicates
|
||||
// "nounwind" case.
|
||||
if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
|
||||
LandingPads.erase(LandingPads.begin() + i);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) {
|
||||
MCSymbol *BeginLabel = LandingPad.BeginLabels[j];
|
||||
MCSymbol *EndLabel = LandingPad.EndLabels[j];
|
||||
if ((BeginLabel->isDefined() ||
|
||||
(LPMap && (*LPMap)[BeginLabel] != 0)) &&
|
||||
(EndLabel->isDefined() ||
|
||||
(LPMap && (*LPMap)[EndLabel] != 0))) continue;
|
||||
|
||||
LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j);
|
||||
LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j);
|
||||
--j;
|
||||
--e;
|
||||
}
|
||||
|
||||
// Remove landing pads with no try-ranges.
|
||||
if (LandingPads[i].BeginLabels.empty()) {
|
||||
LandingPads.erase(LandingPads.begin() + i);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If there is no landing pad, ensure that the list of typeids is empty.
|
||||
// If the only typeid is a cleanup, this is the same as having no typeids.
|
||||
if (!LandingPad.LandingPadBlock ||
|
||||
(LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0]))
|
||||
LandingPad.TypeIds.clear();
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void MachineFunction::addCleanup(MachineBasicBlock *LandingPad) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
LP.TypeIds.push_back(0);
|
||||
}
|
||||
|
||||
void MachineFunction::addSEHCatchHandler(MachineBasicBlock *LandingPad,
|
||||
const Function *Filter,
|
||||
const BlockAddress *RecoverBA) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
SEHHandler Handler;
|
||||
Handler.FilterOrFinally = Filter;
|
||||
Handler.RecoverBA = RecoverBA;
|
||||
LP.SEHHandlers.push_back(Handler);
|
||||
}
|
||||
|
||||
void MachineFunction::addSEHCleanupHandler(MachineBasicBlock *LandingPad,
|
||||
const Function *Cleanup) {
|
||||
LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
|
||||
SEHHandler Handler;
|
||||
Handler.FilterOrFinally = Cleanup;
|
||||
Handler.RecoverBA = nullptr;
|
||||
LP.SEHHandlers.push_back(Handler);
|
||||
}
|
||||
|
||||
void MachineFunction::setCallSiteLandingPad(MCSymbol *Sym,
|
||||
ArrayRef<unsigned> Sites) {
|
||||
LPadToCallSiteMap[Sym].append(Sites.begin(), Sites.end());
|
||||
}
|
||||
|
||||
unsigned MachineFunction::getTypeIDFor(const GlobalValue *TI) {
|
||||
for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
|
||||
if (TypeInfos[i] == TI) return i + 1;
|
||||
|
||||
TypeInfos.push_back(TI);
|
||||
return TypeInfos.size();
|
||||
}
|
||||
|
||||
int MachineFunction::getFilterIDFor(std::vector<unsigned> &TyIds) {
|
||||
// If the new filter coincides with the tail of an existing filter, then
|
||||
// re-use the existing filter. Folding filters more than this requires
|
||||
// re-ordering filters and/or their elements - probably not worth it.
|
||||
for (std::vector<unsigned>::iterator I = FilterEnds.begin(),
|
||||
E = FilterEnds.end(); I != E; ++I) {
|
||||
unsigned i = *I, j = TyIds.size();
|
||||
|
||||
while (i && j)
|
||||
if (FilterIds[--i] != TyIds[--j])
|
||||
goto try_next;
|
||||
|
||||
if (!j)
|
||||
// The new filter coincides with range [i, end) of the existing filter.
|
||||
return -(1 + i);
|
||||
|
||||
try_next:;
|
||||
}
|
||||
|
||||
// Add the new filter.
|
||||
int FilterID = -(1 + FilterIds.size());
|
||||
FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
|
||||
FilterIds.insert(FilterIds.end(), TyIds.begin(), TyIds.end());
|
||||
FilterEnds.push_back(FilterIds.size());
|
||||
FilterIds.push_back(0); // terminator
|
||||
return FilterID;
|
||||
}
|
||||
|
||||
void llvm::addLandingPadInfo(const LandingPadInst &I, MachineBasicBlock &MBB) {
|
||||
MachineFunction &MF = *MBB.getParent();
|
||||
if (const auto *PF = dyn_cast<Function>(
|
||||
I.getParent()->getParent()->getPersonalityFn()->stripPointerCasts()))
|
||||
MF.getMMI().addPersonality(PF);
|
||||
|
||||
if (I.isCleanup())
|
||||
MF.addCleanup(&MBB);
|
||||
|
||||
// FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct,
|
||||
// but we need to do it this way because of how the DWARF EH emitter
|
||||
// processes the clauses.
|
||||
for (unsigned i = I.getNumClauses(); i != 0; --i) {
|
||||
Value *Val = I.getClause(i - 1);
|
||||
if (I.isCatch(i - 1)) {
|
||||
MF.addCatchTypeInfo(&MBB,
|
||||
dyn_cast<GlobalValue>(Val->stripPointerCasts()));
|
||||
} else {
|
||||
// Add filters in a list.
|
||||
Constant *CVal = cast<Constant>(Val);
|
||||
SmallVector<const GlobalValue *, 4> FilterList;
|
||||
for (User::op_iterator II = CVal->op_begin(), IE = CVal->op_end();
|
||||
II != IE; ++II)
|
||||
FilterList.push_back(cast<GlobalValue>((*II)->stripPointerCasts()));
|
||||
|
||||
MF.addFilterTypeInfo(&MBB, FilterList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// \}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// MachineFrameInfo implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
Reference in New Issue
Block a user