#include "llvm/InstrTypes.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/ParameterAttributes.h"
namespace llvm {
/// @brief Set the parameter attributes.
void setParamAttrs(const ParamAttrsList *attrs);
+ /// @brief Determine whether the call or the callee has the given attribute.
+ bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+
+ /// @brief Determine if the call does not access memory.
+ bool doesNotAccessMemory() const {
+ return paramHasAttr(0, ParamAttr::ReadNone);
+ }
+
+ /// @brief Determine if the call does not access or only reads memory.
+ bool onlyReadsMemory() const {
+ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+ }
+
+ /// @brief Determine if the call cannot unwind.
+ bool isNoUnwind() const {
+ return paramHasAttr(0, ParamAttr::NoUnwind);
+ }
+
/// @brief Determine if the call returns a structure.
- bool isStructReturn() const;
+ bool isStructReturn() const {
+ // Be friendly and also check the callee.
+ return paramHasAttr(1, ParamAttr::StructRet);
+ }
/// getCalledFunction - Return the function being called by this instruction
/// if it is a direct call. If it is a call through a function pointer,
/// @brief Set the parameter attributes.
void setParamAttrs(const ParamAttrsList *attrs);
+ /// @brief Determine whether the call or the callee has the given attribute.
+ bool paramHasAttr(uint16_t i, ParameterAttributes attr) const;
+
+ /// @brief Determine if the call does not access memory.
+ bool doesNotAccessMemory() const {
+ return paramHasAttr(0, ParamAttr::ReadNone);
+ }
+
+ /// @brief Determine if the call does not access or only reads memory.
+ bool onlyReadsMemory() const {
+ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly);
+ }
+
+ /// @brief Determine if the call cannot unwind.
+ bool isNoUnwind() const {
+ return paramHasAttr(0, ParamAttr::NoUnwind);
+ }
+
/// @brief Determine if the call returns a structure.
- bool isStructReturn() const;
+ bool isStructReturn() const {
+ // Be friendly and also check the callee.
+ return paramHasAttr(1, ParamAttr::StructRet);
+ }
/// getCalledFunction - Return the function called, or null if this is an
/// indirect function invocation.