aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ParameterAttributes.h
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-11-25 14:10:56 +0000
committerDuncan Sands <baldrick@free.fr>2007-11-25 14:10:56 +0000
commit827cde1c8319e51463007078a7ce3660ebc93036 (patch)
treea14ff574ff8b56c6eafd7d864d2cf756451a9d8d /include/llvm/ParameterAttributes.h
parent789d34f8c3d78cf439f0da2f1ba7856bdaed01a4 (diff)
downloadexternal_llvm-827cde1c8319e51463007078a7ce3660ebc93036.zip
external_llvm-827cde1c8319e51463007078a7ce3660ebc93036.tar.gz
external_llvm-827cde1c8319e51463007078a7ce3660ebc93036.tar.bz2
Fix PR1816. If a bitcast of a function only exists because of a
trivial difference in function attributes, allow calls to it to be converted to direct calls. Based on a patch by Török Edwin. While there, move the various lists of mutually incompatible parameters etc out of the verifier and into ParameterAttributes.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44315 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ParameterAttributes.h')
-rw-r--r--include/llvm/ParameterAttributes.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/include/llvm/ParameterAttributes.h b/include/llvm/ParameterAttributes.h
index 4c48d87..1dd98ea 100644
--- a/include/llvm/ParameterAttributes.h
+++ b/include/llvm/ParameterAttributes.h
@@ -43,6 +43,34 @@ enum Attributes {
ReadOnly = 1 << 10 ///< Function only reads from memory
};
+/// These attributes can safely be dropped from a function or a function call:
+/// doing so may reduce the number of optimizations performed, but it will not
+/// change a correct program into an incorrect one.
+/// @brief Attributes that do not change the calling convention.
+const uint16_t Informative = NoReturn | NoUnwind | NoAlias |
+ ReadNone | ReadOnly;
+
+/// The following attribute sets are used by the verifier:
+
+/// @brief Attributes that only apply to function parameters.
+const uint16_t ParameterOnly = ByVal | InReg | Nest | StructRet;
+
+/// @brief Attributes that only apply to function return values.
+const uint16_t ReturnOnly = NoReturn | NoUnwind | ReadNone | ReadOnly;
+
+/// @brief Attributes that only apply to integers.
+const uint16_t IntegerTypeOnly = SExt | ZExt;
+
+/// @brief Attributes that only apply to pointers.
+const uint16_t PointerTypeOnly = ByVal | Nest | NoAlias | StructRet;
+
+/// @brief Attributes that are mutually incompatible.
+const uint16_t MutuallyIncompatible[3] = {
+ ByVal | InReg | Nest | StructRet,
+ ZExt | SExt,
+ ReadNone | ReadOnly
+};
+
}
/// This is just a pair of values to associate a set of parameter attributes
@@ -110,6 +138,11 @@ class ParamAttrsList : public FoldingSetNode {
/// @brief Get a ParamAttrsList instance.
static ParamAttrsList *get(const ParamAttrsVector &attrVec);
+ /// Returns whether each of the specified lists of attributes can be safely
+ /// replaced with the other in a function or a function call.
+ /// @brief Whether one attribute list can safely replace the other.
+ static bool areCompatible(const ParamAttrsList *A, const ParamAttrsList *B);
+
/// @}
/// @name Accessors
/// @{