[cfe-dev] How to use clang without any dead-code elimination
Wen-Han Gu
nowar100 at gmail.com
Mon Jan 17 05:07:45 PST 2011
Thanks. It works. Just move `static' out.
Thank you very much.
2011/1/17 Török Edwin <edwintorok at gmail.com>
> On 2011-01-17 14:33, Wen-Han Gu wrote:
> > Hi all,
> >
> > I have some functions definition to be used in another place.
>
> If the function is not declared as "static", then clang must already
> assume it can be used externally, and can't eliminate the code (even if
> optimizing up to O3).
> Unless you perform LTO, -internalize, or other such whole program
> transformations, the code should be emitted.
>
> The linker might still eliminate the function if no function from a
> .o/.a is needed.
>
> > I want to generate LLVM IR without any dead-code elimination, or the
> > output will contains nothing.
>
> -O0 should work, but obviously won't have any other optimization.
>
> >
> > Did anyone know how to achive that without any change of source code?
>
> > If not this way, which source file should I modify?
>
> __attribute__((used)) if you use the function from assembly and compiler
> can't see its used.
>
> Best regards,
> --Edwin
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
--
Best regards,
Wen-Han
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110117/070813bb/attachment.html>
More information about the cfe-dev
mailing list