On Jan 30, 2008, at 5:13 PM, Dale Johannesen wrote: > > On Jan 30, 2008, at 5:05 PM, Devang Patel wrote: > >> handle_used_attribute() sets DECL_PRESERVE_P bit, so what am I >> missing ? > > It was not set in the example in gcc.dg/tree-used.c. I'll step > through and figure out why, agree it looks like it ought to be.
In that example there is a declaration with __attribute__((used)), followed by a definition without it. merge_decls clobbers the PRESERVE bit when it merges the two nodes gcc constructs. The DECL_USED bit is not clobbered, which is enough to cause the function to be emitted with non-llvm-gcc but not with llvm-gcc, which is enough to get the test to pass. But, the no_dead_strip command is incorrectly dropped in the non-llvm-gcc version as well. So I've stumbled into a latent gcc bug, although not one that causes any testsuite failures AFAICT. (The attributes list is merged correctly in merge_decls, so my patch seems to be an improvement. However, there's another case in my example, where a definition without attribute((used)) is followed by a declaration with attribute((used)). For that, the USED bit gets set and is good enough for gcc to emit the body, as before, but both compilers drop the no_dead_strip: a bug. Unfortunately the USED bit is not good enough for llvm: llvm drops the second definition if you run llvm-as | opt | llc instead of using llvm-gcc. So there's still a bug here that may matter.) Good catch, thanks Devang. >> On Jan 30, 2008, at 5:00 PM, Dale Johannesen wrote: >> >>> Author: johannes >>> Date: Wed Jan 30 19:00:20 2008 >>> New Revision: 46589 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=46589&view=rev >>> Log: >>> The 'used' attribute is not stored where llvm-convert >>> thought it was. >>> >>> >>> Modified: >>> llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp >>> >>> Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp >>> URL: >>> http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=46589&r1=46588&r2=46589&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) >>> +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Jan 30 19:00:20 2008 >>> @@ -633,7 +633,7 @@ >>> Fn->setSection(TREE_STRING_POINTER(DECL_SECTION_NAME(FnDecl))); >>> >>> // Handle used Functions >>> - if (DECL_PRESERVE_P (FnDecl)) >>> + if (lookup_attribute ("used", DECL_ATTRIBUTES (FnDecl))) >>> AttributeUsedGlobals.insert(Fn); >>> >>> // Handle noinline Functions >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits@cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> - >> Devang >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits@cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits