From dd8cc241e07fcbb3774733acb328eafe29b18b8a Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Tue, 8 Jul 2008 08:38:44 +0000 Subject: Add some convenience methods for manipulating call attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53223 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Instructions.cpp | 46 +++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 4bcd560..36c3de7 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -72,12 +72,36 @@ bool CallSite::doesNotAccessMemory() const { else return cast(I)->doesNotAccessMemory(); } +void CallSite::setDoesNotAccessMemory(bool doesNotAccessMemory) { + if (CallInst *CI = dyn_cast(I)) + CI->setDoesNotAccessMemory(doesNotAccessMemory); + else + cast(I)->setDoesNotAccessMemory(doesNotAccessMemory); +} bool CallSite::onlyReadsMemory() const { if (CallInst *CI = dyn_cast(I)) return CI->onlyReadsMemory(); else return cast(I)->onlyReadsMemory(); } +void CallSite::setOnlyReadsMemory(bool onlyReadsMemory) { + if (CallInst *CI = dyn_cast(I)) + CI->setOnlyReadsMemory(onlyReadsMemory); + else + cast(I)->setOnlyReadsMemory(onlyReadsMemory); +} +bool CallSite::doesNotReturn() const { + if (CallInst *CI = dyn_cast(I)) + return CI->doesNotReturn(); + else + return cast(I)->doesNotReturn(); +} +void CallSite::setDoesNotReturn(bool doesNotReturn) { + if (CallInst *CI = dyn_cast(I)) + CI->setDoesNotReturn(doesNotReturn); + else + cast(I)->setDoesNotReturn(doesNotReturn); +} bool CallSite::doesNotThrow() const { if (CallInst *CI = dyn_cast(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); } -- cgit v1.1