[llvm-commits] [dragonegg] r137209 - /dragonegg/trunk/src/Convert.cpp

Duncan Sands baldrick at free.fr
Wed Aug 10 04:08:30 PDT 2011


Author: baldrick
Date: Wed Aug 10 06:08:29 2011
New Revision: 137209

URL: http://llvm.org/viewvc/llvm-project?rev=137209&view=rev
Log:
With gcc-4.6, when a C++ class is returned by value it may be that
the address to return it in is provided in the RESULT_DECL, in which
case reading from the RESULT_DECL can result in something other than
undef.  Based on a patch by Peter Collingbourne.

Modified:
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=137209&r1=137208&r2=137209&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Aug 10 06:08:29 2011
@@ -6499,8 +6499,11 @@
   // Otherwise the symbol is a VAR_DECL, PARM_DECL or RESULT_DECL.  Since a
   // default definition is only created if the very first reference to the
   // variable in the function is a read operation, and refers to the value
-  // read, it has an undefined value except for PARM_DECLs.
-  if (TREE_CODE(var) != PARM_DECL)
+  // read, it has an undefined value for VAR_DECLs (a RESULT_DECL can have
+  // an initial value if the function returns a class by value).
+  assert((TREE_CODE(var) == PARM_DECL || TREE_CODE(var) == RESULT_DECL ||
+          TREE_CODE(var) == VAR_DECL) && "Unsupported SSA name definition!");
+  if (TREE_CODE(var) == VAR_DECL)
     return DefineSSAName(reg, UndefValue::get(getRegType(TREE_TYPE(reg))));
 
   // Read the initial value of the parameter and associate it with the ssa name.





More information about the llvm-commits mailing list