mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Add the support in code-gen for the landingpad instruction lowering.
The landingpad instruction is lowered into the EXCEPTIONADDR and EHSELECTION SDNodes. The information from the landingpad instruction is harvested by the 'AddLandingPadInfo' function. The new EH uses the current EH scheme in the back-end. This will change once we switch over to the new scheme. (Reviewed by Jakob!) llvm-svn: 137880
This commit is contained in:
parent
3efc45bfad
commit
71ce55ffd7
@ -221,6 +221,11 @@ void AddCatchInfo(const CallInst &I,
|
||||
void CopyCatchInfo(const BasicBlock *SuccBB, const BasicBlock *LPad,
|
||||
MachineModuleInfo *MMI, FunctionLoweringInfo &FLI);
|
||||
|
||||
/// AddLandingPadInfo - Extract the exception handling information from the
|
||||
/// landingpad instruction and add them to the specified machine module info.
|
||||
void AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI,
|
||||
MachineBasicBlock *MBB);
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
@ -454,3 +454,34 @@ void llvm::CopyCatchInfo(const BasicBlock *SuccBB, const BasicBlock *LPad,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// AddLandingPadInfo - Extract the exception handling information from the
|
||||
/// landingpad instruction and add them to the specified machine module info.
|
||||
void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI,
|
||||
MachineBasicBlock *MBB) {
|
||||
MMI.addPersonality(MBB,
|
||||
cast<Function>(I.getPersonalityFn()->stripPointerCasts()));
|
||||
|
||||
if (I.isCleanup())
|
||||
MMI.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)) {
|
||||
MMI.addCatchTypeInfo(MBB,
|
||||
dyn_cast<GlobalVariable>(Val->stripPointerCasts()));
|
||||
} else {
|
||||
// Add filters in a list.
|
||||
Constant *CVal = cast<Constant>(Val);
|
||||
SmallVector<const GlobalVariable*, 4> FilterList;
|
||||
for (User::op_iterator
|
||||
II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II)
|
||||
FilterList.push_back(cast<GlobalVariable>((*II)->stripPointerCasts()));
|
||||
|
||||
MMI.addFilterTypeInfo(MBB, FilterList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1814,6 +1814,45 @@ void SelectionDAGBuilder::visitResume(const ResumeInst &RI) {
|
||||
llvm_unreachable("SelectionDAGBuilder shouldn't visit resume instructions!");
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitLandingPad(const LandingPadInst &LP) {
|
||||
assert(FuncInfo.MBB->isLandingPad() &&
|
||||
"Call to landingpad not in landing pad!");
|
||||
|
||||
MachineBasicBlock *MBB = FuncInfo.MBB;
|
||||
MachineModuleInfo &MMI = DAG.getMachineFunction().getMMI();
|
||||
AddLandingPadInfo(LP, MMI, MBB);
|
||||
|
||||
SmallVector<EVT, 2> ValueVTs;
|
||||
ComputeValueVTs(TLI, LP.getType(), ValueVTs);
|
||||
|
||||
// Insert the EXCEPTIONADDR instruction.
|
||||
assert(FuncInfo.MBB->isLandingPad() &&
|
||||
"Call to eh.exception not in landing pad!");
|
||||
SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other);
|
||||
SDValue Ops[2];
|
||||
Ops[0] = DAG.getRoot();
|
||||
SDValue Op1 = DAG.getNode(ISD::EXCEPTIONADDR, getCurDebugLoc(), VTs, Ops, 1);
|
||||
SDValue Chain = Op1.getValue(1);
|
||||
|
||||
// Insert the EHSELECTION instruction.
|
||||
VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other);
|
||||
Ops[0] = Op1;
|
||||
Ops[1] = Chain;
|
||||
SDValue Op2 = DAG.getNode(ISD::EHSELECTION, getCurDebugLoc(), VTs, Ops, 2);
|
||||
Chain = Op2.getValue(1);
|
||||
Op2 = DAG.getSExtOrTrunc(Op2, getCurDebugLoc(), MVT::i32);
|
||||
|
||||
Ops[0] = Op1;
|
||||
Ops[1] = Op2;
|
||||
SDValue Res = DAG.getNode(ISD::MERGE_VALUES, getCurDebugLoc(),
|
||||
DAG.getVTList(&ValueVTs[0], ValueVTs.size()),
|
||||
&Ops[0], 2);
|
||||
|
||||
std::pair<SDValue, SDValue> RetPair = std::make_pair(Res, Chain);
|
||||
setValue(&LP, RetPair.first);
|
||||
DAG.setRoot(RetPair.second);
|
||||
}
|
||||
|
||||
/// handleSmallSwitchCaseRange - Emit a series of specific tests (suitable for
|
||||
/// small case ranges).
|
||||
bool SelectionDAGBuilder::handleSmallSwitchRange(CaseRec& CR,
|
||||
@ -2985,9 +3024,6 @@ void SelectionDAGBuilder::visitExtractValue(const ExtractValueInst &I) {
|
||||
&Values[0], NumValValues));
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitLandingPad(const LandingPadInst &I) {
|
||||
}
|
||||
|
||||
void SelectionDAGBuilder::visitGetElementPtr(const User &I) {
|
||||
SDValue N = getValue(I.getOperand(0));
|
||||
Type *Ty = I.getOperand(0)->getType();
|
||||
|
Loading…
Reference in New Issue
Block a user