diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:01:22 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:01:22 +0000 |
commit | 71d5a2540a98c81f5bcaeb48805e0e2881f530ef (patch) | |
tree | 5343938942df402b49ec7300a1c25a2d4ccd5821 /include/llvm/IR/Instructions.h | |
parent | 31bbf64f3a4974a2d6c8b3b27ad2f519caf74057 (diff) |
Diffstat (limited to 'include/llvm/IR/Instructions.h')
-rw-r--r-- | include/llvm/IR/Instructions.h | 348 |
1 files changed, 208 insertions, 140 deletions
diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index a5d78a08171a..34dafebe0fc5 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -67,18 +67,21 @@ protected: AllocaInst *cloneImpl() const; public: - explicit AllocaInst(Type *Ty, Value *ArraySize = nullptr, + explicit AllocaInst(Type *Ty, unsigned AddrSpace, + Value *ArraySize = nullptr, const Twine &Name = "", Instruction *InsertBefore = nullptr); - AllocaInst(Type *Ty, Value *ArraySize, + AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, const Twine &Name, BasicBlock *InsertAtEnd); - AllocaInst(Type *Ty, const Twine &Name, Instruction *InsertBefore = nullptr); - AllocaInst(Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd); + AllocaInst(Type *Ty, unsigned AddrSpace, + const Twine &Name, Instruction *InsertBefore = nullptr); + AllocaInst(Type *Ty, unsigned AddrSpace, + const Twine &Name, BasicBlock *InsertAtEnd); - AllocaInst(Type *Ty, Value *ArraySize, unsigned Align, + AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, unsigned Align, const Twine &Name = "", Instruction *InsertBefore = nullptr); - AllocaInst(Type *Ty, Value *ArraySize, unsigned Align, + AllocaInst(Type *Ty, unsigned AddrSpace, Value *ArraySize, unsigned Align, const Twine &Name, BasicBlock *InsertAtEnd); // Out of line virtual method, so the vtable, etc. has a home. @@ -958,6 +961,14 @@ public: inline op_iterator idx_end() { return op_end(); } inline const_op_iterator idx_end() const { return op_end(); } + inline iterator_range<op_iterator> indices() { + return make_range(idx_begin(), idx_end()); + } + + inline iterator_range<const_op_iterator> indices() const { + return make_range(idx_begin(), idx_end()); + } + Value *getPointerOperand() { return getOperand(0); } @@ -1354,7 +1365,7 @@ class CallInst : public Instruction, public OperandBundleUser<CallInst, User::op_iterator> { friend class OperandBundleUser<CallInst, User::op_iterator>; - AttributeSet AttributeList; ///< parameter attributes for call + AttributeList Attrs; ///< parameter attributes for call FunctionType *FTy; CallInst(const CallInst &CI); @@ -1633,11 +1644,11 @@ public: /// Return the parameter attributes for this call. /// - AttributeSet getAttributes() const { return AttributeList; } + AttributeList getAttributes() const { return Attrs; } /// Set the parameter attributes for this call. /// - void setAttributes(AttributeSet Attrs) { AttributeList = Attrs; } + void setAttributes(AttributeList A) { Attrs = A; } /// adds the attribute to the list of attributes. void addAttribute(unsigned i, Attribute::AttrKind Kind); @@ -1670,8 +1681,11 @@ public: return hasFnAttrImpl(Kind); } - /// Determine whether the call or the callee has the given attributes. - bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const; + /// Determine whether the return value has the given attribute. + bool hasRetAttr(Attribute::AttrKind Kind) const; + + /// Determine whether the argument or parameter has the given attribute. + bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const; /// Get the attribute of a given kind at a position. Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const { @@ -1700,26 +1714,26 @@ public: /// Extract the alignment for a call or parameter (0=unknown). unsigned getParamAlignment(unsigned i) const { - return AttributeList.getParamAlignment(i); + return Attrs.getParamAlignment(i); } /// Extract the number of dereferenceable bytes for a call or /// parameter (0=unknown). uint64_t getDereferenceableBytes(unsigned i) const { - return AttributeList.getDereferenceableBytes(i); + return Attrs.getDereferenceableBytes(i); } /// Extract the number of dereferenceable_or_null bytes for a call or /// parameter (0=unknown). uint64_t getDereferenceableOrNullBytes(unsigned i) const { - return AttributeList.getDereferenceableOrNullBytes(i); + return Attrs.getDereferenceableOrNullBytes(i); } /// @brief Determine if the parameter or return value is marked with NoAlias /// attribute. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotAlias(unsigned n) const { - return AttributeList.hasAttribute(n, Attribute::NoAlias); + return Attrs.hasAttribute(n, Attribute::NoAlias); } /// Return true if the call should not be treated as a call to a @@ -1732,7 +1746,7 @@ public: /// Return true if the call should not be inlined. bool isNoInline() const { return hasFnAttr(Attribute::NoInline); } void setIsNoInline() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoInline); + addAttribute(AttributeList::FunctionIndex, Attribute::NoInline); } /// Return true if the call can return twice @@ -1740,7 +1754,7 @@ public: return hasFnAttr(Attribute::ReturnsTwice); } void setCanReturnTwice() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ReturnsTwice); + addAttribute(AttributeList::FunctionIndex, Attribute::ReturnsTwice); } /// Determine if the call does not access memory. @@ -1748,7 +1762,7 @@ public: return hasFnAttr(Attribute::ReadNone); } void setDoesNotAccessMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ReadNone); + addAttribute(AttributeList::FunctionIndex, Attribute::ReadNone); } /// Determine if the call does not access or only reads memory. @@ -1756,7 +1770,7 @@ public: return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly); } void setOnlyReadsMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ReadOnly); + addAttribute(AttributeList::FunctionIndex, Attribute::ReadOnly); } /// Determine if the call does not access or only writes memory. @@ -1764,7 +1778,7 @@ public: return doesNotAccessMemory() || hasFnAttr(Attribute::WriteOnly); } void setDoesNotReadMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::WriteOnly); + addAttribute(AttributeList::FunctionIndex, Attribute::WriteOnly); } /// @brief Determine if the call can access memmory only using pointers based @@ -1773,34 +1787,34 @@ public: return hasFnAttr(Attribute::ArgMemOnly); } void setOnlyAccessesArgMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ArgMemOnly); + addAttribute(AttributeList::FunctionIndex, Attribute::ArgMemOnly); } /// Determine if the call cannot return. bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); } void setDoesNotReturn() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoReturn); + addAttribute(AttributeList::FunctionIndex, Attribute::NoReturn); } /// Determine if the call cannot unwind. bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); } void setDoesNotThrow() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoUnwind); + addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind); } /// Determine if the call cannot be duplicated. bool cannotDuplicate() const {return hasFnAttr(Attribute::NoDuplicate); } void setCannotDuplicate() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoDuplicate); + addAttribute(AttributeList::FunctionIndex, Attribute::NoDuplicate); } /// Determine if the call is convergent bool isConvergent() const { return hasFnAttr(Attribute::Convergent); } void setConvergent() { - addAttribute(AttributeSet::FunctionIndex, Attribute::Convergent); + addAttribute(AttributeList::FunctionIndex, Attribute::Convergent); } void setNotConvergent() { - removeAttribute(AttributeSet::FunctionIndex, Attribute::Convergent); + removeAttribute(AttributeList::FunctionIndex, Attribute::Convergent); } /// Determine if the call returns a structure through first @@ -1810,12 +1824,12 @@ public: return false; // Be friendly and also check the callee. - return paramHasAttr(1, Attribute::StructRet); + return paramHasAttr(0, Attribute::StructRet); } /// Determine if any call argument is an aggregate passed by value. bool hasByValArgument() const { - return AttributeList.hasAttrSomewhere(Attribute::ByVal); + return Attrs.hasAttrSomewhere(Attribute::ByVal); } /// Return the function called, or null if this is an @@ -1858,7 +1872,7 @@ public: private: template <typename AttrKind> bool hasFnAttrImpl(AttrKind Kind) const { - if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, Kind)) + if (Attrs.hasAttribute(AttributeList::FunctionIndex, Kind)) return true; // Operand bundles override attributes on the called function, but don't @@ -1867,7 +1881,8 @@ private: return false; if (const Function *F = getCalledFunction()) - return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, Kind); + return F->getAttributes().hasAttribute(AttributeList::FunctionIndex, + Kind); return false; } @@ -3084,42 +3099,41 @@ public: // -2 static const unsigned DefaultPseudoIndex = static_cast<unsigned>(~0L-1); - template <class SwitchInstTy, class ConstantIntTy, class BasicBlockTy> - class CaseIteratorT { - protected: - SwitchInstTy *SI; - unsigned Index; + template <typename CaseHandleT> class CaseIteratorImpl; - public: - typedef CaseIteratorT<SwitchInstTy, ConstantIntTy, BasicBlockTy> Self; + /// A handle to a particular switch case. It exposes a convenient interface + /// to both the case value and the successor block. + /// + /// We define this as a template and instantiate it to form both a const and + /// non-const handle. + template <typename SwitchInstT, typename ConstantIntT, typename BasicBlockT> + class CaseHandleImpl { + // Directly befriend both const and non-const iterators. + friend class SwitchInst::CaseIteratorImpl< + CaseHandleImpl<SwitchInstT, ConstantIntT, BasicBlockT>>; - /// Initializes case iterator for given SwitchInst and for given - /// case number. - CaseIteratorT(SwitchInstTy *SI, unsigned CaseNum) { - this->SI = SI; - Index = CaseNum; - } + protected: + // Expose the switch type we're parameterized with to the iterator. + typedef SwitchInstT SwitchInstType; - /// Initializes case iterator for given SwitchInst and for given - /// TerminatorInst's successor index. - static Self fromSuccessorIndex(SwitchInstTy *SI, unsigned SuccessorIndex) { - assert(SuccessorIndex < SI->getNumSuccessors() && - "Successor index # out of range!"); - return SuccessorIndex != 0 ? - Self(SI, SuccessorIndex - 1) : - Self(SI, DefaultPseudoIndex); - } + SwitchInstT *SI; + ptrdiff_t Index; + + CaseHandleImpl() = default; + CaseHandleImpl(SwitchInstT *SI, ptrdiff_t Index) : SI(SI), Index(Index) {} + public: /// Resolves case value for current case. - ConstantIntTy *getCaseValue() { - assert(Index < SI->getNumCases() && "Index out the number of cases."); - return reinterpret_cast<ConstantIntTy*>(SI->getOperand(2 + Index*2)); + ConstantIntT *getCaseValue() const { + assert((unsigned)Index < SI->getNumCases() && + "Index out the number of cases."); + return reinterpret_cast<ConstantIntT *>(SI->getOperand(2 + Index * 2)); } /// Resolves successor for current case. - BasicBlockTy *getCaseSuccessor() { - assert((Index < SI->getNumCases() || - Index == DefaultPseudoIndex) && + BasicBlockT *getCaseSuccessor() const { + assert(((unsigned)Index < SI->getNumCases() || + (unsigned)Index == DefaultPseudoIndex) && "Index out the number of cases."); return SI->getSuccessor(getSuccessorIndex()); } @@ -3129,63 +3143,32 @@ public: /// Returns TerminatorInst's successor index for current case successor. unsigned getSuccessorIndex() const { - assert((Index == DefaultPseudoIndex || Index < SI->getNumCases()) && + assert(((unsigned)Index == DefaultPseudoIndex || + (unsigned)Index < SI->getNumCases()) && "Index out the number of cases."); - return Index != DefaultPseudoIndex ? Index + 1 : 0; + return (unsigned)Index != DefaultPseudoIndex ? Index + 1 : 0; } - Self operator++() { - // Check index correctness after increment. - // Note: Index == getNumCases() means end(). - assert(Index+1 <= SI->getNumCases() && "Index out the number of cases."); - ++Index; - return *this; - } - Self operator++(int) { - Self tmp = *this; - ++(*this); - return tmp; - } - Self operator--() { - // Check index correctness after decrement. - // Note: Index == getNumCases() means end(). - // Also allow "-1" iterator here. That will became valid after ++. - assert((Index == 0 || Index-1 <= SI->getNumCases()) && - "Index out the number of cases."); - --Index; - return *this; - } - Self operator--(int) { - Self tmp = *this; - --(*this); - return tmp; - } - bool operator==(const Self& RHS) const { - assert(RHS.SI == SI && "Incompatible operators."); - return RHS.Index == Index; - } - bool operator!=(const Self& RHS) const { - assert(RHS.SI == SI && "Incompatible operators."); - return RHS.Index != Index; - } - Self &operator*() { - return *this; + bool operator==(const CaseHandleImpl &RHS) const { + assert(SI == RHS.SI && "Incompatible operators."); + return Index == RHS.Index; } }; - typedef CaseIteratorT<const SwitchInst, const ConstantInt, const BasicBlock> - ConstCaseIt; + typedef CaseHandleImpl<const SwitchInst, const ConstantInt, const BasicBlock> + ConstCaseHandle; - class CaseIt : public CaseIteratorT<SwitchInst, ConstantInt, BasicBlock> { - typedef CaseIteratorT<SwitchInst, ConstantInt, BasicBlock> ParentTy; + class CaseHandle + : public CaseHandleImpl<SwitchInst, ConstantInt, BasicBlock> { + friend class SwitchInst::CaseIteratorImpl<CaseHandle>; public: - CaseIt(const ParentTy &Src) : ParentTy(Src) {} - CaseIt(SwitchInst *SI, unsigned CaseNum) : ParentTy(SI, CaseNum) {} + CaseHandle(SwitchInst *SI, ptrdiff_t Index) : CaseHandleImpl(SI, Index) {} /// Sets the new value for current case. void setValue(ConstantInt *V) { - assert(Index < SI->getNumCases() && "Index out the number of cases."); + assert((unsigned)Index < SI->getNumCases() && + "Index out the number of cases."); SI->setOperand(2 + Index*2, reinterpret_cast<Value*>(V)); } @@ -3195,6 +3178,76 @@ public: } }; + template <typename CaseHandleT> + class CaseIteratorImpl + : public iterator_facade_base<CaseIteratorImpl<CaseHandleT>, + std::random_access_iterator_tag, + CaseHandleT> { + typedef typename CaseHandleT::SwitchInstType SwitchInstT; + + CaseHandleT Case; + + public: + /// Default constructed iterator is in an invalid state until assigned to + /// a case for a particular switch. + CaseIteratorImpl() = default; + + /// Initializes case iterator for given SwitchInst and for given + /// case number. + CaseIteratorImpl(SwitchInstT *SI, unsigned CaseNum) : Case(SI, CaseNum) {} + + /// Initializes case iterator for given SwitchInst and for given + /// TerminatorInst's successor index. + static CaseIteratorImpl fromSuccessorIndex(SwitchInstT *SI, + unsigned SuccessorIndex) { + assert(SuccessorIndex < SI->getNumSuccessors() && + "Successor index # out of range!"); + return SuccessorIndex != 0 ? CaseIteratorImpl(SI, SuccessorIndex - 1) + : CaseIteratorImpl(SI, DefaultPseudoIndex); + } + + /// Support converting to the const variant. This will be a no-op for const + /// variant. + operator CaseIteratorImpl<ConstCaseHandle>() const { + return CaseIteratorImpl<ConstCaseHandle>(Case.SI, Case.Index); + } + + CaseIteratorImpl &operator+=(ptrdiff_t N) { + // Check index correctness after addition. + // Note: Index == getNumCases() means end(). + assert(Case.Index + N >= 0 && + (unsigned)(Case.Index + N) <= Case.SI->getNumCases() && + "Case.Index out the number of cases."); + Case.Index += N; + return *this; + } + CaseIteratorImpl &operator-=(ptrdiff_t N) { + // Check index correctness after subtraction. + // Note: Case.Index == getNumCases() means end(). + assert(Case.Index - N >= 0 && + (unsigned)(Case.Index - N) <= Case.SI->getNumCases() && + "Case.Index out the number of cases."); + Case.Index -= N; + return *this; + } + ptrdiff_t operator-(const CaseIteratorImpl &RHS) const { + assert(Case.SI == RHS.Case.SI && "Incompatible operators."); + return Case.Index - RHS.Case.Index; + } + bool operator==(const CaseIteratorImpl &RHS) const { + return Case == RHS.Case; + } + bool operator<(const CaseIteratorImpl &RHS) const { + assert(Case.SI == RHS.Case.SI && "Incompatible operators."); + return Case.Index < RHS.Case.Index; + } + CaseHandleT &operator*() { return Case; } + const CaseHandleT &operator*() const { return Case; } + }; + + typedef CaseIteratorImpl<CaseHandle> CaseIt; + typedef CaseIteratorImpl<ConstCaseHandle> ConstCaseIt; + static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore = nullptr) { @@ -3278,30 +3331,40 @@ public: /// default case iterator to indicate that it is handled by the default /// handler. CaseIt findCaseValue(const ConstantInt *C) { - for (CaseIt i = case_begin(), e = case_end(); i != e; ++i) - if (i.getCaseValue() == C) - return i; + CaseIt I = llvm::find_if( + cases(), [C](CaseHandle &Case) { return Case.getCaseValue() == C; }); + if (I != case_end()) + return I; + return case_default(); } ConstCaseIt findCaseValue(const ConstantInt *C) const { - for (ConstCaseIt i = case_begin(), e = case_end(); i != e; ++i) - if (i.getCaseValue() == C) - return i; + ConstCaseIt I = llvm::find_if(cases(), [C](ConstCaseHandle &Case) { + return Case.getCaseValue() == C; + }); + if (I != case_end()) + return I; + return case_default(); } /// Finds the unique case value for a given successor. Returns null if the /// successor is not found, not unique, or is the default case. ConstantInt *findCaseDest(BasicBlock *BB) { - if (BB == getDefaultDest()) return nullptr; + if (BB == getDefaultDest()) + return nullptr; ConstantInt *CI = nullptr; - for (CaseIt i = case_begin(), e = case_end(); i != e; ++i) { - if (i.getCaseSuccessor() == BB) { - if (CI) return nullptr; // Multiple cases lead to BB. - else CI = i.getCaseValue(); - } + for (auto Case : cases()) { + if (Case.getCaseSuccessor() != BB) + continue; + + if (CI) + return nullptr; // Multiple cases lead to BB. + + CI = Case.getCaseValue(); } + return CI; } @@ -3316,8 +3379,9 @@ public: /// index idx and above. /// Note: /// This action invalidates iterators for all cases following the one removed, - /// including the case_end() iterator. - void removeCase(CaseIt i); + /// including the case_end() iterator. It returns an iterator for the next + /// case. + CaseIt removeCase(CaseIt I); unsigned getNumSuccessors() const { return getNumOperands()/2; } BasicBlock *getSuccessor(unsigned idx) const { @@ -3465,7 +3529,7 @@ class InvokeInst : public TerminatorInst, public OperandBundleUser<InvokeInst, User::op_iterator> { friend class OperandBundleUser<InvokeInst, User::op_iterator>; - AttributeSet AttributeList; + AttributeList Attrs; FunctionType *FTy; InvokeInst(const InvokeInst &BI); @@ -3669,11 +3733,11 @@ public: /// Return the parameter attributes for this invoke. /// - AttributeSet getAttributes() const { return AttributeList; } + AttributeList getAttributes() const { return Attrs; } /// Set the parameter attributes for this invoke. /// - void setAttributes(AttributeSet Attrs) { AttributeList = Attrs; } + void setAttributes(AttributeList A) { Attrs = A; } /// adds the attribute to the list of attributes. void addAttribute(unsigned i, Attribute::AttrKind Kind); @@ -3706,8 +3770,11 @@ public: return hasFnAttrImpl(Kind); } - /// Determine whether the call or the callee has the given attributes. - bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const; + /// Determine whether the return value has the given attribute. + bool hasRetAttr(Attribute::AttrKind Kind) const; + + /// Determine whether the argument or parameter has the given attribute. + bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const; /// Get the attribute of a given kind at a position. Attribute getAttribute(unsigned i, Attribute::AttrKind Kind) const { @@ -3737,26 +3804,26 @@ public: /// Extract the alignment for a call or parameter (0=unknown). unsigned getParamAlignment(unsigned i) const { - return AttributeList.getParamAlignment(i); + return Attrs.getParamAlignment(i); } /// Extract the number of dereferenceable bytes for a call or /// parameter (0=unknown). uint64_t getDereferenceableBytes(unsigned i) const { - return AttributeList.getDereferenceableBytes(i); + return Attrs.getDereferenceableBytes(i); } /// Extract the number of dereferenceable_or_null bytes for a call or /// parameter (0=unknown). uint64_t getDereferenceableOrNullBytes(unsigned i) const { - return AttributeList.getDereferenceableOrNullBytes(i); + return Attrs.getDereferenceableOrNullBytes(i); } /// @brief Determine if the parameter or return value is marked with NoAlias /// attribute. /// @param n The parameter to check. 1 is the first parameter, 0 is the return bool doesNotAlias(unsigned n) const { - return AttributeList.hasAttribute(n, Attribute::NoAlias); + return Attrs.hasAttribute(n, Attribute::NoAlias); } /// Return true if the call should not be treated as a call to a @@ -3771,7 +3838,7 @@ public: /// Return true if the call should not be inlined. bool isNoInline() const { return hasFnAttr(Attribute::NoInline); } void setIsNoInline() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoInline); + addAttribute(AttributeList::FunctionIndex, Attribute::NoInline); } /// Determine if the call does not access memory. @@ -3779,7 +3846,7 @@ public: return hasFnAttr(Attribute::ReadNone); } void setDoesNotAccessMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ReadNone); + addAttribute(AttributeList::FunctionIndex, Attribute::ReadNone); } /// Determine if the call does not access or only reads memory. @@ -3787,7 +3854,7 @@ public: return doesNotAccessMemory() || hasFnAttr(Attribute::ReadOnly); } void setOnlyReadsMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ReadOnly); + addAttribute(AttributeList::FunctionIndex, Attribute::ReadOnly); } /// Determine if the call does not access or only writes memory. @@ -3795,7 +3862,7 @@ public: return doesNotAccessMemory() || hasFnAttr(Attribute::WriteOnly); } void setDoesNotReadMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::WriteOnly); + addAttribute(AttributeList::FunctionIndex, Attribute::WriteOnly); } /// @brief Determine if the call access memmory only using it's pointer @@ -3804,34 +3871,34 @@ public: return hasFnAttr(Attribute::ArgMemOnly); } void setOnlyAccessesArgMemory() { - addAttribute(AttributeSet::FunctionIndex, Attribute::ArgMemOnly); + addAttribute(AttributeList::FunctionIndex, Attribute::ArgMemOnly); } /// Determine if the call cannot return. bool doesNotReturn() const { return hasFnAttr(Attribute::NoReturn); } void setDoesNotReturn() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoReturn); + addAttribute(AttributeList::FunctionIndex, Attribute::NoReturn); } /// Determine if the call cannot unwind. bool doesNotThrow() const { return hasFnAttr(Attribute::NoUnwind); } void setDoesNotThrow() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoUnwind); + addAttribute(AttributeList::FunctionIndex, Attribute::NoUnwind); } /// Determine if the invoke cannot be duplicated. bool cannotDuplicate() const {return hasFnAttr(Attribute::NoDuplicate); } void setCannotDuplicate() { - addAttribute(AttributeSet::FunctionIndex, Attribute::NoDuplicate); + addAttribute(AttributeList::FunctionIndex, Attribute::NoDuplicate); } /// Determine if the invoke is convergent bool isConvergent() const { return hasFnAttr(Attribute::Convergent); } void setConvergent() { - addAttribute(AttributeSet::FunctionIndex, Attribute::Convergent); + addAttribute(AttributeList::FunctionIndex, Attribute::Convergent); } void setNotConvergent() { - removeAttribute(AttributeSet::FunctionIndex, Attribute::Convergent); + removeAttribute(AttributeList::FunctionIndex, Attribute::Convergent); } /// Determine if the call returns a structure through first @@ -3841,12 +3908,12 @@ public: return false; // Be friendly and also check the callee. - return paramHasAttr(1, Attribute::StructRet); + return paramHasAttr(0, Attribute::StructRet); } /// Determine if any call argument is an aggregate passed by value. bool hasByValArgument() const { - return AttributeList.hasAttrSomewhere(Attribute::ByVal); + return Attrs.hasAttrSomewhere(Attribute::ByVal); } /// Return the function called, or null if this is an @@ -3918,7 +3985,7 @@ private: void setSuccessorV(unsigned idx, BasicBlock *B) override; template <typename AttrKind> bool hasFnAttrImpl(AttrKind Kind) const { - if (AttributeList.hasAttribute(AttributeSet::FunctionIndex, Kind)) + if (Attrs.hasAttribute(AttributeList::FunctionIndex, Kind)) return true; // Operand bundles override attributes on the called function, but don't @@ -3927,7 +3994,8 @@ private: return false; if (const Function *F = getCalledFunction()) - return F->getAttributes().hasAttribute(AttributeSet::FunctionIndex, Kind); + return F->getAttributes().hasAttribute(AttributeList::FunctionIndex, + Kind); return false; } |