[LLVMdev] __used__ attributes in llvm-gcc's crtstuff.c

Anton Korobeynikov
Tue, 14 Dec 2010 20:47:43 -0000

Hello,

> __used__ attributes in llvm-gcc/gcc/crtstuff.c.
> GCC compiles crtstuff.c with -fno-toplevel-reorder option, which ensures
> that
> unused static globals are not removed during optimization. However, since
> LLVM does not support that option,
The problem is not that LLVM does not support this option. Though,
this is indeed so due to certain reason.
All the code is transformed into IR and transformations are performed
on it. It will be really bad for the
transformations to depend on some magic command line options. Even
more, consider e.g. you tried
to link two IR files - one with the code with -fno-toplevev-reorder
and one - without. What should be done
in such case?

> I presume __used__ attribute is used instead.
This is correct, because this is what in fact the code should do here.

> My question is that why some global static variables, such as
> __frame_dummy_init_array_entry
> and __do_global_dtors_aux_fini_array_entry, are not given __used__
> attributes.
Just bug.

> it caused no problem for me so far.
> Would it be any problem in doing so?
Please prepare the patch and submit to llvm-commit. Thanks!

--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University