[llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c

Chris Lattner lattner at cs.uiuc.edu
Sat Feb 19 09:10:33 PST 2005



Changes in directory llvm-gcc/gcc:

llvm-expand.c updated: 1.83 -> 1.84
---
Log message:

Make sure to give all arguments DECL_LLVM values even if they are unnamed.
Unnamed arguments cannot be referenced by the programmer, but they can
be referenced by compiler generated methods, like virtual function thunks.

Many MANY thanks to Adam Treat for coming up with 90% of this patch!

This fixes PR520: http://llvm.cs.uiuc.edu/PR520  and 
test/Regression/CC++Frontend/2005-02-19-UnnamedVirtualThunkArgument.cpp


---
Diffs of the changes:  (+14 -8)

 llvm-expand.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)


Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.83 llvm-gcc/gcc/llvm-expand.c:1.84
--- llvm-gcc/gcc/llvm-expand.c:1.83	Sat Feb 19 01:26:44 2005
+++ llvm-gcc/gcc/llvm-expand.c	Sat Feb 19 11:10:19 2005
@@ -5346,7 +5346,7 @@
   case PARM_DECL:
     if (!DECL_LLVM_SET_P (exp)) {
       error ("%Hprior parameter's size depends on '%D'",
-             &DECL_SOURCE_LOCATION (exp), exp);
+	      &DECL_SOURCE_LOCATION (exp), exp);
       return llvm_constant_VoidPtr_null;
     }
     /* ... fall through ...  */
@@ -7009,17 +7009,21 @@
       llvm_type *Ty = llvm_type_get_from_tree(TREE_TYPE(Args));
       int isLValue = 0;
 
+      if (DECL_NAME(Args)) Name = IDENTIFIER_POINTER(DECL_NAME(Args));
+
       if (isPassedByInvisibleReference(TREE_TYPE(Args))) {
         Ty = llvm_type_get_pointer(Ty);
         isLValue = 1;
-      }
-
-      if (DECL_NAME(Args)) Name = IDENTIFIER_POINTER(DECL_NAME(Args));
-      if (Name[0] && !isLValue) {   /* Only create values for named arguments */
+      } else {
         /* Add a suffix for the stack slot */
         char NameBuffer[100];
         char *ArgName = strlen(Name) > 90 ?xmalloc(strlen(Name)+10) :NameBuffer;
-        strcpy(ArgName, Name);
+        if (Name[0] != 0)   /* Not an empty name? */
+          strcpy(ArgName, Name);
+        else {
+          Name = "unnamed_arg";
+          strcpy(ArgName, "unnamed_arg");
+        }
         strcat(ArgName, "_addr");
         A = create_alloca_inst(ArgName, Ty, llvm_constant_uint_1);
         if (ArgName != NameBuffer)
@@ -7027,9 +7031,11 @@
 
         insert_alloca_into_entry_block(Fn, A);
         SET_DECL_LLVM(Args, D2V(A));  /* Remember lvalue address */
-      } else {
-        Name = "unnamed_arg";  /* we want llvm_value's to have names! */
       }
+      /* Add arguments to the function.  If there is a struct passed by value, *
+       * this could cause multiple LLVM arguments to be added for this one C
+       * argument.
+       */
       AddArguments(Fn, Ty, Name, D2V(A), &ArgNo);
 
       /* If the value is passed by "invisible reference", the l-value for the






More information about the llvm-commits mailing list