[llvm-commits] [llvm-gcc-4.2] r44121 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Anton Korobeynikov
asl at math.spbu.ru
Wed Nov 14 09:00:03 PST 2007
Author: asl
Date: Wed Nov 14 11:00:03 2007
New Revision: 44121
URL: http://llvm.org/viewvc/llvm-project?rev=44121&view=rev
Log:
Propagate information about pure/const functions into IR
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=44121&r1=44120&r2=44121&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Nov 14 11:00:03 2007
@@ -1007,21 +1007,32 @@
#ifdef TARGET_ADJUST_LLVM_CC
TARGET_ADJUST_LLVM_CC(CallingConv, type);
#endif
-
- // Compute whether the result needs to be zext or sext'd, adding an attribute
- // if so.
+
+ // Compute attributes for return type (and function attributes)
ParamAttrsVector Attrs;
+ uint16_t RAttributes = ParamAttr::None;
+
+ // Check for 'const' function attribute
+ if (decl && TREE_READONLY(decl))
+ RAttributes |= ParamAttr::Const;
+
+ // Check for 'pure' function attribute
+ if (decl && DECL_IS_PURE(decl))
+ RAttributes |= ParamAttr::Pure;
+
+ // Compute whether the result needs to be zext or sext'd
if (isa<IntegerType>(RetTy.get())) {
- uint16_t RAttributes = ParamAttr::None;
tree ResultTy = TREE_TYPE(type);
if (TREE_INT_CST_LOW(TYPE_SIZE(ResultTy)) < INT_TYPE_SIZE) {
if (TYPE_UNSIGNED(ResultTy) || TREE_CODE(ResultTy) == BOOLEAN_TYPE)
- Attrs.push_back(ParamAttrsWithIndex::get(0, ParamAttr::ZExt));
- else
- Attrs.push_back(ParamAttrsWithIndex::get(0, ParamAttr::SExt));
+ RAttributes |= ParamAttr::ZExt;
+ else
+ RAttributes |= ParamAttr::SExt;
}
}
+ Attrs.push_back(ParamAttrsWithIndex::get(0, RAttributes));
+
// If this is a struct-return function, the dest loc is passed in as a
// pointer. Mark that pointer as structret.
if (ABIConverter.isStructReturn())
More information about the llvm-commits
mailing list