The C++ exception handling personality function wants
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SelectionDAGISel.cpp
index bc336d2069758d6a67b19223af25ebf115c0444d..05a7a954d7fa4cf78b39e1550b0fd9d3d0e80a1c 100644 (file)
@@ -2952,7 +2952,11 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
     Args.push_back(Entry);
   }
 
-  if (ExceptionHandling && MMI && LandingPad) {
+  bool MarkTryRange = LandingPad ||
+    // C++ requires special handling of 'nounwind' calls.
+    (Attrs && Attrs->paramHasAttr(0, ParamAttr::NoUnwind));
+
+  if (MarkTryRange && 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();
@@ -2969,7 +2973,7 @@ void SelectionDAGLowering::LowerCallTo(Instruction &I,
     setValue(&I, Result.first);
   DAG.setRoot(Result.second);
 
-  if (ExceptionHandling && MMI && LandingPad) {
+  if (MarkTryRange && 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();