diff options
author | Duncan Sands <baldrick@free.fr> | 2008-07-08 08:38:44 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2008-07-08 08:38:44 +0000 |
commit | 78c8872d87fdeeccbd7bcedf711939d21e96f31c (patch) | |
tree | 58c1485f1a510556ca33dcb2b9f888e0281d0f78 /llvm/lib/VMCore/Instructions.cpp | |
parent | 1904f44757da60332274ce4c3991617de417362d (diff) | |
download | bcm5719-llvm-78c8872d87fdeeccbd7bcedf711939d21e96f31c.tar.gz bcm5719-llvm-78c8872d87fdeeccbd7bcedf711939d21e96f31c.zip |
Add some convenience methods for manipulating
call attributes.
llvm-svn: 53223
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 4bcd560ee83..36c3de72ceb 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -72,12 +72,36 @@ bool CallSite::doesNotAccessMemory() const { else return cast<InvokeInst>(I)->doesNotAccessMemory(); } +void CallSite::setDoesNotAccessMemory(bool doesNotAccessMemory) { + if (CallInst *CI = dyn_cast<CallInst>(I)) + CI->setDoesNotAccessMemory(doesNotAccessMemory); + else + cast<InvokeInst>(I)->setDoesNotAccessMemory(doesNotAccessMemory); +} bool CallSite::onlyReadsMemory() const { if (CallInst *CI = dyn_cast<CallInst>(I)) return CI->onlyReadsMemory(); else return cast<InvokeInst>(I)->onlyReadsMemory(); } +void CallSite::setOnlyReadsMemory(bool onlyReadsMemory) { + if (CallInst *CI = dyn_cast<CallInst>(I)) + CI->setOnlyReadsMemory(onlyReadsMemory); + else + cast<InvokeInst>(I)->setOnlyReadsMemory(onlyReadsMemory); +} +bool CallSite::doesNotReturn() const { + if (CallInst *CI = dyn_cast<CallInst>(I)) + return CI->doesNotReturn(); + else + return cast<InvokeInst>(I)->doesNotReturn(); +} +void CallSite::setDoesNotReturn(bool doesNotReturn) { + if (CallInst *CI = dyn_cast<CallInst>(I)) + CI->setDoesNotReturn(doesNotReturn); + else + cast<InvokeInst>(I)->setDoesNotReturn(doesNotReturn); +} bool CallSite::doesNotThrow() const { if (CallInst *CI = dyn_cast<CallInst>(I)) return CI->doesNotThrow(); @@ -384,6 +408,12 @@ void CallInst::addParamAttr(unsigned i, ParameterAttributes attr) { setParamAttrs(PAL); } +void CallInst::removeParamAttr(unsigned i, ParameterAttributes attr) { + PAListPtr PAL = getParamAttrs(); + PAL = PAL.removeAttr(i, attr); + setParamAttrs(PAL); +} + bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const { if (ParamAttrs.paramHasAttr(i, attr)) return true; @@ -392,15 +422,6 @@ bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const { return false; } -void CallInst::setDoesNotThrow(bool doesNotThrow) { - PAListPtr PAL = getParamAttrs(); - if (doesNotThrow) - PAL = PAL.addAttr(0, ParamAttr::NoUnwind); - else - PAL = PAL.removeAttr(0, ParamAttr::NoUnwind); - setParamAttrs(PAL); -} - //===----------------------------------------------------------------------===// // InvokeInst Implementation @@ -466,12 +487,9 @@ void InvokeInst::addParamAttr(unsigned i, ParameterAttributes attr) { setParamAttrs(PAL); } -void InvokeInst::setDoesNotThrow(bool doesNotThrow) { +void InvokeInst::removeParamAttr(unsigned i, ParameterAttributes attr) { PAListPtr PAL = getParamAttrs(); - if (doesNotThrow) - PAL = PAL.addAttr(0, ParamAttr::NoUnwind); - else - PAL = PAL.removeAttr(0, ParamAttr::NoUnwind); + PAL = PAL.removeAttr(i, attr); setParamAttrs(PAL); } |