Author: baldrick Date: Sat Feb 16 14:59:48 2008 New Revision: 47221 URL: http://llvm.org/viewvc/llvm-project?rev=47221&view=rev Log: For a nested function, the parent's variables are like global variables for a normal function. In particular a 'const' nested function can reasonably return the address of one. However in order to get hold of that address a nested function needs to read through the static chain pointer parameter, which is incompatible with being readnone. So turn 'const' into readonly for nested functions.
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=47221&r1=47220&r2=47221&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Sat Feb 16 14:59:48 2008 @@ -1137,7 +1137,14 @@ // 'sret' functions cannot be 'readnone' or 'readonly'. if (ABIConverter.isStructReturn()) RAttributes &= ~(ParamAttr::ReadNone|ParamAttr::ReadOnly); - + + // Demote 'readnone' nested functions to 'readonly' since + // they may need to read through the static chain. + if (static_chain && (RAttributes & ParamAttr::ReadNone)) { + RAttributes &= ~ParamAttr::ReadNone; + RAttributes |= ParamAttr::ReadOnly; + } + // Compute whether the result needs to be zext or sext'd. RAttributes |= HandleArgumentExtension(TREE_TYPE(type)); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits