[llvm-commits] [llvm-gcc-4.2] r47221 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Duncan Sands baldrick at free.fr
Sat Feb 16 12:59:49 PST 2008


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));
 





More information about the llvm-commits mailing list