Changes in directory llvm-gcc/gcc:
llvm-expand.c updated: 1.119 -> 1.120 llvm-representation.c updated: 1.21 -> 1.22 llvm-representation.h updated: 1.20 -> 1.21 --- Log message: Implement support for attribute "used", implementing PR660: http://llvm.cs.uiuc.edu/PR660 and implementing test/Regression/CFrontend/2005-12-04-AttributeUsed.c. --- Diffs of the changes: (+66 -1) llvm-expand.c | 9 ++++++++ llvm-representation.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++- llvm-representation.h | 2 + 3 files changed, 66 insertions(+), 1 deletion(-) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.119 llvm-gcc/gcc/llvm-expand.c:1.120 --- llvm-gcc/gcc/llvm-expand.c:1.119 Sun Dec 4 21:24:21 2005 +++ llvm-gcc/gcc/llvm-expand.c Sun Dec 4 22:49:21 2005 @@ -7271,6 +7271,10 @@ return Fn; } + /* If this was marked 'used', add it to the 'used' list. */ + if (lookup_attribute ("used", DECL_ATTRIBUTES (subr))) + Fn->AttributeUsed = 1; + /* If there is already a body for this function, it's a wierd error. The only * case we allow is if the old function was linkonce. */ @@ -7776,6 +7780,11 @@ G->Init = V2C(llvm_constant_get_null(BaseTy)); } } + + /* If this was marked 'used', add it to the 'used' list. */ + if (lookup_attribute ("used", DECL_ATTRIBUTES (decl))) + G->AttributeUsed = 1; + TREE_ASM_WRITTEN(decl) = 1; if (EMIT_CODE_INCREMENTALLY) llvm_global_print(G, llvm_out_file); Index: llvm-gcc/gcc/llvm-representation.c diff -u llvm-gcc/gcc/llvm-representation.c:1.21 llvm-gcc/gcc/llvm-representation.c:1.22 --- llvm-gcc/gcc/llvm-representation.c:1.21 Tue Nov 29 12:25:04 2005 +++ llvm-gcc/gcc/llvm-representation.c Sun Dec 4 22:49:21 2005 @@ -24,6 +24,7 @@ #include "hashtab.h" #include <assert.h> #include <string.h> +#include <ctype.h> /* The one true program we are compiling */ llvm_program TheProgram; @@ -1055,6 +1056,8 @@ /* Print the specified program to the output file */ void llvm_program_print(FILE *F) { + unsigned NumAttributeUsed; + llvm_type_print_all_named(F); /* Output global ctors and dtors if there are any */ @@ -1081,7 +1084,58 @@ fprintf(F, "\n ]\n\n"); } } - + + /* Output the llvm.used array if there are any attribute(used) globals */ + NumAttributeUsed = 0; + + { /* Count globals that are attribute used */ + llvm_global *I; + for (I = llvm_ilist_begin(TheProgram.Globals); + I != llvm_ilist_end(TheProgram.Globals); + I = I->Next) + if (I->AttributeUsed) ++NumAttributeUsed; + } + { /* Count functions that are attribute used */ + llvm_function *I; + for (I = llvm_ilist_begin(TheProgram.Functions); + I != llvm_ilist_end(TheProgram.Functions); + I = I->Next) + if (I->AttributeUsed) ++NumAttributeUsed; + } + + if (NumAttributeUsed) { + llvm_global *G; + llvm_function *Fn; + fprintf(F, "; Attribute used list\n"); + fprintf(F,"%%llvm.used = appending global [%d x sbyte*]" + " [\n", NumAttributeUsed); + NumAttributeUsed = 0; + for (G = llvm_ilist_begin(TheProgram.Globals); + G != llvm_ilist_end(TheProgram.Globals); + G = G->Next) { + if (G->AttributeUsed) { + if (NumAttributeUsed++) + fprintf(F, ",\n"); + fprintf(F, "\tsbyte* cast ("); + llvm_value_print_operand(G2V(G), 1, F); + fprintf(F, " to sbyte*)"); + } + } + for (Fn = llvm_ilist_begin(TheProgram.Functions); + Fn != llvm_ilist_end(TheProgram.Functions); + Fn = Fn->Next) { + if (Fn->AttributeUsed) { + if (NumAttributeUsed++) + fprintf(F, ",\n"); + fprintf(F, "\tsbyte* cast ("); + llvm_value_print_operand(G2V(Fn), 1, F); + fprintf(F, " to sbyte*)"); + } + } + fprintf(F, "\n ]\n\n"); + } + + /* Output the rest of the global variables... */ llvm_ilist_foreach1(llvm_global, TheProgram.Globals, llvm_global_print, F); Index: llvm-gcc/gcc/llvm-representation.h diff -u llvm-gcc/gcc/llvm-representation.h:1.20 llvm-gcc/gcc/llvm-representation.h:1.21 --- llvm-gcc/gcc/llvm-representation.h:1.20 Tue Nov 29 12:25:04 2005 +++ llvm-gcc/gcc/llvm-representation.h Sun Dec 4 22:49:21 2005 @@ -287,6 +287,7 @@ ENUM_BITFIELD (llvm_linkage) Linkage : 4; int MarkedNameUsed : 1; + int AttributeUsed : 1; /* Function is attribute(used) */ char *PrettyFunctionName; } llvm_function; @@ -307,6 +308,7 @@ llvm_ilist_node(struct llvm_global, Globals); /* Part of Global list */ llvm_constant *Init; /* Initializer or null for external */ int isConstant : 1; /* Is the global immutable? */ + int AttributeUsed : 1; /* Global is attribute(used) */ ENUM_BITFIELD (llvm_linkage) Linkage : 4; int MarkedNameUsed : 1; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits