diff --git a/docs/LangRef.html b/docs/LangRef.html
index 0c2f8ca8c13..f85a441e531 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -764,9 +764,9 @@ a power of 2.
The return type and each parameter of a function type may have a set of
parameter attributes associated with them. Parameter attributes are
used to communicate additional information about the result or parameters of
- a function. Parameter attributes are considered to be part of the function
- type so two functions types that differ only by the parameter attributes
- are different function types.
+ a function. Parameter attributes are considered to be part of the function,
+ not of the function type, so functions with different parameter attributes
+ can have the same function type.
Parameter attributes are simple keywords that follow the type specified. If
multiple parameter attributes are needed, they are space separated. For
@@ -774,15 +774,13 @@ a power of 2.
-%someFunc = i16 (i8 signext %someParam) zeroext
-%someFunc = i16 (i8 zeroext %someParam) zeroext
+declare i32 @printf(i8* noalias , ...) nounwind
+declare i32 @atoi(i8*) nounwind readonly
- Note that the two function types above are unique because the parameter has
- a different attribute (signext in the first one, zeroext in
- the second). Also note that the attribute for the function result
- (zeroext) comes immediately after the argument list.
+ Note that any attributes for the function result (nounwind,
+ readonly) come immediately after the argument list.
Currently, only the following parameter attributes are defined:
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index 1ae8cbd45b9..12219c53542 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;
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 &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 &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 56ed5c26f0b..897e53b0a2d 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 ba132cfd58f..96ca43d6cad 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 1dd98eaa901..79b5d0c2a61 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 fec7efc4cbb..d03d209d5fb 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(); }
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 2291852c869..82dee547a9f 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -268,7 +268,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
static bool isNoAliasArgument(const Argument *Arg) {
const Function *Func = Arg->getParent();
- const ParamAttrsList *Attr = Func->getFunctionType()->getParamAttrs();
+ const ParamAttrsList *Attr = Func->getParamAttrs();
if (Attr) {
unsigned Idx = 1;
for (Function::const_arg_iterator I = Func->arg_begin(),
@@ -839,7 +839,7 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,
return UnknownModRefBehavior;
}
- const ParamAttrsList *Attrs = F->getFunctionType()->getParamAttrs();
+ const ParamAttrsList *Attrs = F->getParamAttrs();
if (Attrs && Attrs->paramHasAttr(0, ParamAttr::ReadNone))
return DoesNotAccessMemory;
if (Attrs && Attrs->paramHasAttr(0, ParamAttr::ReadOnly))
diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs
index 4a1534881fe..5907eec5784 100644
--- a/lib/AsmParser/llvmAsmParser.cpp.cvs
+++ b/lib/AsmParser/llvmAsmParser.cpp.cvs
@@ -214,8 +214,8 @@
NOALIAS = 395,
BYVAL = 396,
NEST = 397,
- CONST = 398,
- PURE = 399,
+ READNONE = 398,
+ READONLY = 399,
DEFAULT = 400,
HIDDEN = 401,
PROTECTED = 402
@@ -362,8 +362,8 @@
#define NOALIAS 395
#define BYVAL 396
#define NEST 397
-#define CONST 398
-#define PURE 399
+#define READNONE 398
+#define READONLY 399
#define DEFAULT 400
#define HIDDEN 401
#define PROTECTED 402
@@ -372,7 +372,7 @@
/* Copy the first part of user declarations. */
-#line 14 "/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 14 "/home/duncan/LLVM/llvm.top/llvm/lib/AsmParser/llvmAsmParser.y"
#include "ParserInternals.h"
#include "llvm/CallingConv.h"
@@ -391,9 +391,6 @@
#include
#include