Hi Evan, > +/// propagateEHRegister - The specified EH register is required in a > successor > +/// of the EH landing pad. Propagate it (by adding it to livein) to all the > +/// blocks in the paths between the landing pad and the specified block.
thanks for this fix. For the moment we don't really need this much generality: due to other problems (PR1508) we don't even try to handle the case where the exception handling intrinsics are neither in the landing pad nor in an immediate successor of the landing pad (we assert if this occurs). Thus the attached minimal fix is good enough until PR1508 is resolved (shall I commit it?). Also, I can't help feeling that the right way to solve the problem of reading the exception register in some block potentially far away from the landing pad is: (1) add code to the landing pad that writes the physical register to a virtual register; (2) turn the eh.exception intrinsic into a read from the virtual register. The problem is that we are in ssa form during codegen, so doing this means inserting phi nodes etc for the virtual register. Ciao, Duncan.
Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp =================================================================== RCS file: /var/cvs/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp,v retrieving revision 1.474 diff -u -3 -p -r1.474 SelectionDAGISel.cpp --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp 29 Jun 2007 03:42:22 -0000 1.474 +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp 29 Jun 2007 08:19:49 -0000 @@ -2336,25 +2336,6 @@ static void addCatchInfo(CallInst &I, Ma MMI->addCatchTypeInfo(MBB, TyInfo); } -/// propagateEHRegister - The specified EH register is required in a successor -/// of the EH landing pad. Propagate it (by adding it to livein) to all the -/// blocks in the paths between the landing pad and the specified block. -static void propagateEHRegister(MachineBasicBlock *MBB, unsigned EHReg, - SmallPtrSet<MachineBasicBlock*, 8> Visited) { - if (MBB->isLandingPad() || !Visited.insert(MBB)) - return; - - MBB->addLiveIn(EHReg); - for (MachineBasicBlock::pred_iterator PI = MBB->pred_begin(), - E = MBB->pred_end(); PI != E; ++PI) - propagateEHRegister(*PI, EHReg, Visited); -} - -static void propagateEHRegister(MachineBasicBlock *MBB, unsigned EHReg) { - SmallPtrSet<MachineBasicBlock*, 8> Visited; - propagateEHRegister(MBB, EHReg, Visited); -} - /// visitIntrinsicCall - Lower the call to the specified intrinsic function. If /// we want to emit this as a call to a named external function, return the name /// otherwise lower it and return null. @@ -2465,9 +2446,11 @@ SelectionDAGLowering::visitIntrinsicCall case Intrinsic::eh_exception: { if (ExceptionHandling) { - if (!CurMBB->isLandingPad() && TLI.getExceptionAddressRegister()) - propagateEHRegister(CurMBB, TLI.getExceptionAddressRegister()); - + if (!CurMBB->isLandingPad()) { + // FIXME: Mark exception register as live in. Hack for PR1508. + unsigned Reg = TLI.getExceptionAddressRegister(); + if (Reg) CurMBB->addLiveIn(Reg); + } // Insert the EXCEPTIONADDR instruction. SDVTList VTs = DAG.getVTList(TLI.getPointerTy(), MVT::Other); SDOperand Ops[1]; @@ -2492,8 +2475,9 @@ SelectionDAGLowering::visitIntrinsicCall #ifndef NDEBUG FuncInfo.CatchInfoLost.insert(&I); #endif - if (TLI.getExceptionSelectorRegister()) - propagateEHRegister(CurMBB, TLI.getExceptionSelectorRegister()); + // FIXME: Mark exception selector register as live in. Hack for PR1508. + unsigned Reg = TLI.getExceptionSelectorRegister(); + if (Reg) CurMBB->addLiveIn(Reg); } // Insert the EHSELECTION instruction.
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits