[llvm-commits] [llvm-gcc-4.0] r44270 - /llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
Duncan Sands
baldrick at free.fr
Thu Nov 22 01:39:30 PST 2007
Author: baldrick
Date: Thu Nov 22 03:39:28 2007
New Revision: 44270
URL: http://llvm.org/viewvc/llvm-project?rev=44270&view=rev
Log:
Struct return functions cannot be const/pure because
they write the result via the sret pointer argument.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=44270&r1=44269&r2=44270&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Thu Nov 22 03:39:28 2007
@@ -984,29 +984,35 @@
TARGET_ADJUST_LLVM_CC(CallingConv, type);
#endif
- // Compute attributes for return type (and function attributes)
+ // Compute attributes for return type (and function attributes).
ParamAttrsVector Attrs;
uint16_t RAttributes = ParamAttr::None;
int flags = flags_from_decl_or_type(decl ? decl : type);
- // Check for 'const' function attribute
+ // Check for 'const' function attribute.
if (flags & ECF_CONST)
- RAttributes |= ParamAttr::Const;
+ // Since they write the return value through a pointer,
+ // 'sret' functions cannot be 'const'.
+ if (!ABIConverter.isStructReturn())
+ RAttributes |= ParamAttr::Const;
- // Check for 'noreturn' function attribute
+ // Check for 'noreturn' function attribute.
if (flags & ECF_NORETURN)
RAttributes |= ParamAttr::NoReturn;
- // Check for 'nounwind' function attribute
+ // Check for 'nounwind' function attribute.
if (flags & ECF_NOTHROW)
RAttributes |= ParamAttr::NoUnwind;
- // Check for 'pure' function attribute
+ // Check for 'pure' function attribute.
if (flags & ECF_PURE)
- RAttributes |= ParamAttr::Pure;
+ // Since they write the return value through a pointer,
+ // 'sret' functions cannot be 'pure'.
+ if (!ABIConverter.isStructReturn())
+ RAttributes |= ParamAttr::Pure;
- // Compute whether the result needs to be zext or sext'd
+ // Compute whether the result needs to be zext or sext'd.
if (isa<IntegerType>(RetTy.get())) {
tree ResultTy = TREE_TYPE(type);
if (TREE_INT_CST_LOW(TYPE_SIZE(ResultTy)) < INT_TYPE_SIZE) {
More information about the llvm-commits
mailing list