mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Mark all calls as "could throw", when exceptions are enabled. Emit necessary LP info too. This fixes PR1439
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37311 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
501fee71e0
commit
070280e97f
@ -967,6 +967,7 @@ struct LandingPadInfo {
|
|||||||
LandingPadInfo(MachineBasicBlock *MBB)
|
LandingPadInfo(MachineBasicBlock *MBB)
|
||||||
: LandingPadBlock(MBB)
|
: LandingPadBlock(MBB)
|
||||||
, LandingPadLabel(0)
|
, LandingPadLabel(0)
|
||||||
|
, Personality(NULL)
|
||||||
, TypeIds()
|
, TypeIds()
|
||||||
, IsFilter(false)
|
, IsFilter(false)
|
||||||
{}
|
{}
|
||||||
|
@ -2852,7 +2852,7 @@ private:
|
|||||||
|
|
||||||
EmitLabel("eh_frame_begin", EHFrameInfo.Number);
|
EmitLabel("eh_frame_begin", EHFrameInfo.Number);
|
||||||
|
|
||||||
EmitSectionOffset("eh_frame_begin", "section_eh_frame",
|
EmitSectionOffset("eh_frame_begin", "eh_frame_common",
|
||||||
EHFrameInfo.Number, EHFrameInfo.PersonalityIndex,
|
EHFrameInfo.Number, EHFrameInfo.PersonalityIndex,
|
||||||
true, true);
|
true, true);
|
||||||
Asm->EOL("FDE CIE offset");
|
Asm->EOL("FDE CIE offset");
|
||||||
|
@ -1723,7 +1723,9 @@ void MachineModuleInfo::TidyLandingPads() {
|
|||||||
LandingPadInfo &LandingPad = LandingPads[i];
|
LandingPadInfo &LandingPad = LandingPads[i];
|
||||||
LandingPad.LandingPadLabel = MappedLabel(LandingPad.LandingPadLabel);
|
LandingPad.LandingPadLabel = MappedLabel(LandingPad.LandingPadLabel);
|
||||||
|
|
||||||
if (!LandingPad.LandingPadLabel) {
|
// Special case: we *should* emit LPs with null LP MBB. This indicates
|
||||||
|
// "rethrow" case.
|
||||||
|
if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) {
|
||||||
LandingPads.erase(LandingPads.begin() + i);
|
LandingPads.erase(LandingPads.begin() + i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1768,8 +1770,14 @@ Function *MachineModuleInfo::getPersonality() const {
|
|||||||
/// getPersonalityIndex - Return unique index for current personality
|
/// getPersonalityIndex - Return unique index for current personality
|
||||||
/// function. NULL personality function should always get zero index.
|
/// function. NULL personality function should always get zero index.
|
||||||
unsigned MachineModuleInfo::getPersonalityIndex() const {
|
unsigned MachineModuleInfo::getPersonalityIndex() const {
|
||||||
const Function* Personality = (!LandingPads.empty() ?
|
const Function* Personality = NULL;
|
||||||
LandingPads[0].Personality : NULL);
|
|
||||||
|
// Scan landing pads. If there is at least one non-NULL personality - use it.
|
||||||
|
for (unsigned i = 0; i != LandingPads.size(); ++i)
|
||||||
|
if (LandingPads[i].Personality) {
|
||||||
|
Personality = LandingPads[i].Personality;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < Personalities.size(); ++i) {
|
for (unsigned i = 0; i < Personalities.size(); ++i) {
|
||||||
if (Personalities[i] == Personality)
|
if (Personalities[i] == Personality)
|
||||||
|
@ -529,7 +529,8 @@ public:
|
|||||||
void ExportFromCurrentBlock(Value *V);
|
void ExportFromCurrentBlock(Value *V);
|
||||||
void LowerCallTo(Instruction &I,
|
void LowerCallTo(Instruction &I,
|
||||||
const Type *CalledValueTy, unsigned CallingConv,
|
const Type *CalledValueTy, unsigned CallingConv,
|
||||||
bool IsTailCall, SDOperand Callee, unsigned OpIdx);
|
bool IsTailCall, SDOperand Callee, unsigned OpIdx,
|
||||||
|
MachineBasicBlock *LandingPad = NULL);
|
||||||
|
|
||||||
// Terminator instructions.
|
// Terminator instructions.
|
||||||
void visitRet(ReturnInst &I);
|
void visitRet(ReturnInst &I);
|
||||||
@ -1342,29 +1343,11 @@ void SelectionDAGLowering::visitInvoke(InvokeInst &I, bool AsTerminator) {
|
|||||||
// Mark landing pad so that it doesn't get deleted in branch folding.
|
// Mark landing pad so that it doesn't get deleted in branch folding.
|
||||||
LandingPad->setIsLandingPad();
|
LandingPad->setIsLandingPad();
|
||||||
|
|
||||||
// Insert a label before the invoke call to mark the try range.
|
|
||||||
// This can be used to detect deletion of the invoke via the
|
|
||||||
// MachineModuleInfo.
|
|
||||||
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
|
|
||||||
unsigned BeginLabel = MMI->NextLabelID();
|
|
||||||
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
|
||||||
DAG.getConstant(BeginLabel, MVT::i32)));
|
|
||||||
|
|
||||||
LowerCallTo(I, I.getCalledValue()->getType(),
|
LowerCallTo(I, I.getCalledValue()->getType(),
|
||||||
I.getCallingConv(),
|
I.getCallingConv(),
|
||||||
false,
|
false,
|
||||||
getValue(I.getOperand(0)),
|
getValue(I.getOperand(0)),
|
||||||
3);
|
3, LandingPad);
|
||||||
|
|
||||||
// Insert a label before the invoke call to mark the try range.
|
|
||||||
// This can be used to detect deletion of the invoke via the
|
|
||||||
// MachineModuleInfo.
|
|
||||||
unsigned EndLabel = MMI->NextLabelID();
|
|
||||||
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
|
||||||
DAG.getConstant(EndLabel, MVT::i32)));
|
|
||||||
|
|
||||||
// Inform MachineModuleInfo of range.
|
|
||||||
MMI->addInvoke(LandingPad, BeginLabel, EndLabel);
|
|
||||||
|
|
||||||
// Update successor info
|
// Update successor info
|
||||||
CurMBB->addSuccessor(Return);
|
CurMBB->addSuccessor(Return);
|
||||||
@ -2782,10 +2765,13 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
|||||||
const Type *CalledValueTy,
|
const Type *CalledValueTy,
|
||||||
unsigned CallingConv,
|
unsigned CallingConv,
|
||||||
bool IsTailCall,
|
bool IsTailCall,
|
||||||
SDOperand Callee, unsigned OpIdx) {
|
SDOperand Callee, unsigned OpIdx,
|
||||||
|
MachineBasicBlock *LandingPad) {
|
||||||
const PointerType *PT = cast<PointerType>(CalledValueTy);
|
const PointerType *PT = cast<PointerType>(CalledValueTy);
|
||||||
const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
|
const FunctionType *FTy = cast<FunctionType>(PT->getElementType());
|
||||||
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
const ParamAttrsList *Attrs = FTy->getParamAttrs();
|
||||||
|
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
|
||||||
|
unsigned BeginLabel = 0, EndLabel = 0;
|
||||||
|
|
||||||
TargetLowering::ArgListTy Args;
|
TargetLowering::ArgListTy Args;
|
||||||
TargetLowering::ArgListEntry Entry;
|
TargetLowering::ArgListEntry Entry;
|
||||||
@ -2803,6 +2789,14 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
|||||||
Args.push_back(Entry);
|
Args.push_back(Entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ExceptionHandling) {
|
||||||
|
// Insert a label before the invoke call to mark the try range. This can be
|
||||||
|
// used to detect deletion of the invoke via the MachineModuleInfo.
|
||||||
|
BeginLabel = MMI->NextLabelID();
|
||||||
|
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
||||||
|
DAG.getConstant(BeginLabel, MVT::i32)));
|
||||||
|
}
|
||||||
|
|
||||||
std::pair<SDOperand,SDOperand> Result =
|
std::pair<SDOperand,SDOperand> Result =
|
||||||
TLI.LowerCallTo(getRoot(), I.getType(),
|
TLI.LowerCallTo(getRoot(), I.getType(),
|
||||||
Attrs && Attrs->paramHasAttr(0, ParamAttr::SExt),
|
Attrs && Attrs->paramHasAttr(0, ParamAttr::SExt),
|
||||||
@ -2811,6 +2805,17 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
|
|||||||
if (I.getType() != Type::VoidTy)
|
if (I.getType() != Type::VoidTy)
|
||||||
setValue(&I, Result.first);
|
setValue(&I, Result.first);
|
||||||
DAG.setRoot(Result.second);
|
DAG.setRoot(Result.second);
|
||||||
|
|
||||||
|
if (ExceptionHandling) {
|
||||||
|
// Insert a label at the end of the invoke call to mark the try range. This
|
||||||
|
// can be used to detect deletion of the invoke via the MachineModuleInfo.
|
||||||
|
EndLabel = MMI->NextLabelID();
|
||||||
|
DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
|
||||||
|
DAG.getConstant(EndLabel, MVT::i32)));
|
||||||
|
|
||||||
|
// Inform MachineModuleInfo of range.
|
||||||
|
MMI->addInvoke(LandingPad, BeginLabel, EndLabel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user