diff options
author | Duncan Sands <baldrick@free.fr> | 2007-12-19 21:13:37 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-12-19 21:13:37 +0000 |
commit | 2937e3586b67478127d9015f648efdcd3dbd6ff9 (patch) | |
tree | d4442f54d211307d792ee586467e8a127c908365 /lib/VMCore | |
parent | 314acc21f722c3297ffa8f3722e2b178e4bc0bc9 (diff) | |
download | external_llvm-2937e3586b67478127d9015f648efdcd3dbd6ff9.zip external_llvm-2937e3586b67478127d9015f648efdcd3dbd6ff9.tar.gz external_llvm-2937e3586b67478127d9015f648efdcd3dbd6ff9.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Function.cpp | 26 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 24 |
2 files changed, 50 insertions, 0 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index f985899..37e25ad 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -261,6 +261,32 @@ ParamAttrsList::getModified(const ParamAttrsList *PAL, return get(newVec); } +const ParamAttrsList * +ParamAttrsList::includeAttrs(const ParamAttrsList *PAL, + uint16_t idx, uint16_t attrs) { + uint16_t OldAttrs = PAL ? PAL->getParamAttrs(idx) : 0; + uint16_t NewAttrs = OldAttrs | attrs; + if (NewAttrs == OldAttrs) + return PAL; + + ParamAttrsVector modVec; + modVec.push_back(ParamAttrsWithIndex::get(idx, NewAttrs)); + return getModified(PAL, modVec); +} + +const ParamAttrsList * +ParamAttrsList::excludeAttrs(const ParamAttrsList *PAL, + uint16_t idx, uint16_t attrs) { + uint16_t OldAttrs = PAL ? PAL->getParamAttrs(idx) : 0; + uint16_t NewAttrs = OldAttrs & ~attrs; + if (NewAttrs == OldAttrs) + return PAL; + + ParamAttrsVector modVec; + modVec.push_back(ParamAttrsWithIndex::get(idx, NewAttrs)); + return getModified(PAL, modVec); +} + ParamAttrsList::~ParamAttrsList() { ParamAttrsLists->RemoveNode(this); } diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 3531bad..b76b11d 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -71,6 +71,12 @@ bool CallSite::doesNotThrow() const { 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 @@ bool CallInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const { 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 @@ bool InvokeInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const { 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 |