+bool CallInst::paramHasAttr(uint16_t i, ParameterAttributes attr) const {
+ if (ParamAttrs && ParamAttrs->paramHasAttr(i, attr))
+ return true;
+ if (const Function *F = getCalledFunction())
+ return F->paramHasAttr(i, attr);
+ return false;
+}
+
+uint16_t CallInst::getParamAlignment(uint16_t i) const {
+ if (ParamAttrs && ParamAttrs->getParamAlignment(i))
+ return ParamAttrs->getParamAlignment(i);
+ if (const Function *F = getCalledFunction())
+ return F->getParamAlignment(i);
+ return 0;
+}
+
+/// @brief Determine if the call does not access memory.
+bool CallInst::doesNotAccessMemory() const {
+ return paramHasAttr(0, ParamAttr::ReadNone);
+}
+
+/// @brief Determine if the call does not access or only reads memory.
+bool CallInst::onlyReadsMemory() const {
+ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+}
+
+/// @brief Determine if the call cannot return.
+bool CallInst::doesNotReturn() const {
+ return paramHasAttr(0, ParamAttr::NoReturn);
+}
+
+/// @brief Determine if the call cannot unwind.
+bool CallInst::doesNotThrow() const {
+ return paramHasAttr(0, ParamAttr::NoUnwind);
+}
+
+/// @brief Determine if the call returns a structure.
+bool CallInst::isStructReturn() const {
+ // Be friendly and also check the callee.
+ return paramHasAttr(1, ParamAttr::StructRet);
+}
+
+/// @brief Determine if any call argument is an aggregate passed by value.
+bool CallInst::hasByValArgument() const {
+ if (ParamAttrs && ParamAttrs->hasAttrSomewhere(ParamAttr::ByVal))
+ return true;
+ // Be consistent with other methods and check the callee too.
+ if (const Function *F = getCalledFunction())
+ if (const ParamAttrsList *PAL = F->getParamAttrs())
+ return PAL->hasAttrSomewhere(ParamAttr::ByVal);
+ 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);
+}
+
+