[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
Duncan Sands
baldrick at free.fr
Wed Jun 6 03:05:40 PDT 2007
Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.456 -> 1.457
---
Log message:
Additional fix for PR1422: http://llvm.org/PR1422 : make sure the landing pad label is placed in the
correct machine basic block - do not rely on the eh.exception intrinsic
being in the landing pad: the loop optimizers can move it out.
---
Diffs of the changes: (+26 -15)
SelectionDAGISel.cpp | 41 ++++++++++++++++++++++++++---------------
1 files changed, 26 insertions(+), 15 deletions(-)
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.456 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.457
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.456 Sat Jun 2 11:53:42 2007
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Jun 6 05:05:18 2007
@@ -1337,12 +1337,10 @@
void SelectionDAGLowering::visitInvoke(InvokeInst &I, bool AsTerminator) {
// Retrieve successors.
MachineBasicBlock *Return = FuncInfo.MBBMap[I.getSuccessor(0)];
- MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)];
-
+
if (!AsTerminator) {
- // Mark landing pad so that it doesn't get deleted in branch folding.
- LandingPad->setIsLandingPad();
-
+ MachineBasicBlock *LandingPad = FuncInfo.MBBMap[I.getSuccessor(1)];
+
LowerCallTo(I, I.getCalledValue()->getType(),
I.getCallingConv(),
false,
@@ -2577,16 +2575,10 @@
MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
if (MMI) {
- // Add a label to mark the beginning of the landing pad. Deletion of the
- // landing pad can thus be detected via the MachineModuleInfo.
- unsigned LabelID = MMI->addLandingPad(CurMBB);
- DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, DAG.getEntryNode(),
- DAG.getConstant(LabelID, MVT::i32)));
-
// Mark exception register as live in.
unsigned Reg = TLI.getExceptionAddressRegister();
if (Reg) CurMBB->addLiveIn(Reg);
-
+
// Insert the EXCEPTIONADDR instruction.
SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other);
SDOperand Ops[1];
@@ -2626,7 +2618,7 @@
MMI->addFilterTypeInfo(CurMBB, TyInfo);
else
MMI->addCatchTypeInfo(CurMBB, TyInfo);
-
+
// Mark exception selector register as live in.
unsigned Reg = TLI.getExceptionSelectorRegister();
if (Reg) CurMBB->addLiveIn(Reg);
@@ -2788,7 +2780,7 @@
Args.push_back(Entry);
}
- if (ExceptionHandling) {
+ if (ExceptionHandling && MMI) {
// 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();
@@ -2805,7 +2797,7 @@
setValue(&I, Result.first);
DAG.setRoot(Result.second);
- if (ExceptionHandling) {
+ if (ExceptionHandling && MMI) {
// 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();
@@ -4387,6 +4379,13 @@
FunctionLoweringInfo FuncInfo(TLI, Fn, MF);
for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
+ if (InvokeInst *Invoke = dyn_cast<InvokeInst>(I->getTerminator())) {
+ // Mark landing pad.
+ MachineBasicBlock *LandingPad = FuncInfo.MBBMap[Invoke->getSuccessor(1)];
+ LandingPad->setIsLandingPad();
+ }
+
+ for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
SelectBasicBlock(I, MF, FuncInfo);
// Add function live-ins to entry block live-in set.
@@ -4523,6 +4522,18 @@
BB = FuncInfo.MBBMap[LLVMBB];
SDL.setCurrentBasicBlock(BB);
+ if (ExceptionHandling && BB->isLandingPad()) {
+ MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
+
+ if (MMI) {
+ // Add a label to mark the beginning of the landing pad. Deletion of the
+ // landing pad can thus be detected via the MachineModuleInfo.
+ unsigned LabelID = MMI->addLandingPad(BB);
+ DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, DAG.getEntryNode(),
+ DAG.getConstant(LabelID, MVT::i32)));
+ }
+ }
+
// Lower all of the non-terminator instructions.
for (BasicBlock::iterator I = LLVMBB->begin(), E = --LLVMBB->end();
I != E; ++I)
More information about the llvm-commits
mailing list