diff options
author | Duncan Sands <baldrick@free.fr> | 2007-11-27 13:23:08 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-11-27 13:23:08 +0000 |
commit | dc024674ff96820d6020757b48d47f46d4c07db2 (patch) | |
tree | 843dfcaeb8f6c99de930a32020148b563005c2fd /include | |
parent | f19341dec7361451f100a882a023b14583454d7e (diff) | |
download | external_llvm-dc024674ff96820d6020757b48d47f46d4c07db2.zip external_llvm-dc024674ff96820d6020757b48d47f46d4c07db2.tar.gz external_llvm-dc024674ff96820d6020757b48d47f46d4c07db2.tar.bz2 |
Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls. This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully
a bitcode guru (who might that be? :) ) will fix it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/DerivedTypes.h | 19 | ||||
-rw-r--r-- | include/llvm/Function.h | 7 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 18 | ||||
-rw-r--r-- | include/llvm/ParameterAttributes.h | 9 | ||||
-rw-r--r-- | include/llvm/Support/CallSite.h | 6 |
5 files changed, 33 insertions, 26 deletions
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index 1ae8cbd..12219c5 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -31,7 +31,6 @@ class PointerValType; class VectorValType; class IntegerValType; class APInt; -class ParamAttrsList; class DerivedType : public Type { friend class Type; @@ -140,12 +139,11 @@ public: class FunctionType : public DerivedType { friend class TypeMap<FunctionValType, FunctionType>; bool isVarArgs; - const ParamAttrsList *ParamAttrs; FunctionType(const FunctionType &); // Do not implement const FunctionType &operator=(const FunctionType &); // Do not implement FunctionType(const Type *Result, const std::vector<const Type*> &Params, - bool IsVarArgs, const ParamAttrsList *Attrs = 0); + bool IsVarArgs); public: /// FunctionType::get - This static method is the primary way of constructing @@ -154,12 +152,7 @@ public: static FunctionType *get( const Type *Result, ///< The result type const std::vector<const Type*> &Params, ///< The types of the parameters - bool isVarArg, ///< Whether this is a variable argument length function - const ParamAttrsList *Attrs = 0 - ///< Indicates the parameter attributes to use, if any. The 0th entry - ///< in the list refers to the return type. Parameters are numbered - ///< starting at 1. This argument must be on the heap and FunctionType - ///< owns it after its passed here. + bool isVarArg ///< Whether this is a variable argument length function ); inline bool isVarArg() const { return isVarArgs; } @@ -177,14 +170,6 @@ public: /// unsigned getNumParams() const { return NumContainedTys - 1; } - bool isStructReturn() const; - - /// The parameter attributes for the \p ith parameter are returned. The 0th - /// parameter refers to the return type of the function. - /// @returns The ParameterAttributes for the \p ith parameter. - /// @brief Get the attributes for a parameter - const ParamAttrsList *getParamAttrs() const { return ParamAttrs; } - // Implement the AbstractTypeUser interface. virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); virtual void typeBecameConcrete(const DerivedType *AbsTy); diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 56ed5c2..897e53b 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -68,7 +68,7 @@ private: BasicBlockListType BasicBlocks; ///< The basic blocks mutable ArgumentListType ArgumentList; ///< The formal arguments ValueSymbolTable *SymTab; ///< Symbol table of args/instructions - ParamAttrsList *ParamAttrs; ///< Parameter attributes + const ParamAttrsList *ParamAttrs; ///< Parameter attributes // The Calling Convention is stored in Value::SubclassData. /*unsigned CallingConvention;*/ @@ -150,7 +150,10 @@ public: /// Sets the parameter attributes for this Function. To construct a /// ParamAttrsList, see ParameterAttributes.h /// @brief Set the parameter attributes. - void setParamAttrs(ParamAttrsList *attrs); + void setParamAttrs(const ParamAttrsList *attrs); + + /// @brief Determine if the function returns a structure. + bool isStructReturn() const; /// deleteBody - This method deletes the body of the function, and converts /// the linkage to external. diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index ba132cf..96ca43d 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -836,7 +836,7 @@ public: /// class CallInst : public Instruction { - ParamAttrsList *ParamAttrs; ///< parameter attributes for call + const ParamAttrsList *ParamAttrs; ///< parameter attributes for call CallInst(const CallInst &CI); void init(Value *Func, Value* const *Params, unsigned NumParams); void init(Value *Func, Value *Actual1, Value *Actual2); @@ -916,12 +916,15 @@ public: /// parameter attributes information, if any. /// @returns 0 if no attributes have been set. /// @brief Get the parameter attributes. - ParamAttrsList *getParamAttrs() const { return ParamAttrs; } + const ParamAttrsList *getParamAttrs() const { return ParamAttrs; } /// Sets the parameter attributes for this CallInst. To construct a /// ParamAttrsList, see ParameterAttributes.h /// @brief Set the parameter attributes. - void setParamAttrs(ParamAttrsList *attrs); + void setParamAttrs(const ParamAttrsList *attrs); + + /// @brief Determine if the call returns a structure. + bool isStructReturn() const; /// getCalledFunction - Return the function being called by this instruction /// if it is a direct call. If it is a call through a function pointer, @@ -1620,7 +1623,7 @@ private: /// calling convention of the call. /// class InvokeInst : public TerminatorInst { - ParamAttrsList *ParamAttrs; + const ParamAttrsList *ParamAttrs; InvokeInst(const InvokeInst &BI); void init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, Value* const *Args, unsigned NumArgs); @@ -1691,12 +1694,15 @@ public: /// parameter attributes information, if any. /// @returns 0 if no attributes have been set. /// @brief Get the parameter attributes. - ParamAttrsList *getParamAttrs() const { return ParamAttrs; } + const ParamAttrsList *getParamAttrs() const { return ParamAttrs; } /// Sets the parameter attributes for this InvokeInst. To construct a /// ParamAttrsList, see ParameterAttributes.h /// @brief Set the parameter attributes. - void setParamAttrs(ParamAttrsList *attrs); + void setParamAttrs(const ParamAttrsList *attrs); + + /// @brief Determine if the call returns a structure. + bool isStructReturn() const; /// getCalledFunction - Return the function called, or null if this is an /// indirect function invocation. diff --git a/include/llvm/ParameterAttributes.h b/include/llvm/ParameterAttributes.h index 1dd98ea..79b5d0c 100644 --- a/include/llvm/ParameterAttributes.h +++ b/include/llvm/ParameterAttributes.h @@ -77,7 +77,7 @@ const uint16_t MutuallyIncompatible[3] = { /// with a parameter index. /// @brief ParameterAttributes with a parameter index. struct ParamAttrsWithIndex { - uint16_t attrs; ///< The attributes that are set, |'d together + uint16_t attrs; ///< The attributes that are set, or'd together uint16_t index; ///< Index of the parameter for which the attributes apply static ParamAttrsWithIndex get(uint16_t idx, uint16_t attrs) { @@ -219,6 +219,13 @@ class ParamAttrsList : public FoldingSetNode { /// @brief Return the number of parameter attributes this type has. unsigned size() const { return attrs.size(); } + /// @brief Return the number of references to this ParamAttrsList. + unsigned numRefs() const { return refCount; } + + /// @} + /// @name Mutators + /// @{ + public: /// Classes retaining references to ParamAttrsList objects should call this /// method to increment the reference count. This ensures that the /// ParamAttrsList object will not disappear until the class drops it. diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index fec7efc..d03d209 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -27,6 +27,7 @@ namespace llvm { class CallInst; class InvokeInst; +class ParamAttrsList; class CallSite { Instruction *I; @@ -57,6 +58,11 @@ public: unsigned getCallingConv() const; void setCallingConv(unsigned CC); + /// getParamAttrs/setParamAttrs - get or set the parameter attributes of + /// the call. + const ParamAttrsList *getParamAttrs() const; + void setParamAttrs(const ParamAttrsList *PAL); + /// getType - Return the type of the instruction that generated this call site /// const Type *getType() const { return I->getType(); } |