When inlining through an 'nounwind' call, mark inlined
calls 'nounwind'. It is important for correct C++
exception handling that nounwind markings do not get
lost, so this transformation is actually needed for
correctness.
llvm-svn: 45218
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 3531bad..b76b11d 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -71,6 +71,12 @@
else
return cast<InvokeInst>(I)->doesNotThrow();
}
+void CallSite::setDoesNotThrow(bool doesNotThrow) {
+ if (CallInst *CI = dyn_cast<CallInst>(I))
+ CI->setDoesNotThrow(doesNotThrow);
+ else
+ cast<InvokeInst>(I)->setDoesNotThrow(doesNotThrow);
+}
//===----------------------------------------------------------------------===//
// TerminatorInst Class
@@ -405,6 +411,15 @@
return false;
}
+void CallInst::setDoesNotThrow(bool doesNotThrow) {
+ const ParamAttrsList *PAL = getParamAttrs();
+ if (doesNotThrow)
+ PAL = ParamAttrsList::includeAttrs(PAL, 0, ParamAttr::NoUnwind);
+ else
+ PAL = ParamAttrsList::excludeAttrs(PAL, 0, ParamAttr::NoUnwind);
+ setParamAttrs(PAL);
+}
+
//===----------------------------------------------------------------------===//
// InvokeInst Implementation
@@ -483,6 +498,15 @@
return false;
}
+void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
+ const ParamAttrsList *PAL = getParamAttrs();
+ if (doesNotThrow)
+ PAL = ParamAttrsList::includeAttrs(PAL, 0, ParamAttr::NoUnwind);
+ else
+ PAL = ParamAttrsList::excludeAttrs(PAL, 0, ParamAttr::NoUnwind);
+ setParamAttrs(PAL);
+}
+
//===----------------------------------------------------------------------===//
// ReturnInst Implementation