[LLVMdev] Optimization of string.h calls

David Blaikie dblaikie at gmail.com
Sat Sep 20 07:41:14 PDT 2014


I imagine that would be difficult. If you pass the resulting pointer out to
unknown code/functions, there's nothing to stop that code from walking
backwards from the pointer and having well defined behavior of observing
the prefix you tried to hide.

Essentially the compiler would have to be able to see and analyze all uses
of that pointer in one go before it could optimize away the prefix.
On Sep 19, 2014 8:41 PM, "Iritscen" <iritscen at yahoo.com> wrote:

> Hello all.  Is there a way to get llvm/clang at build-time to optimize a
> string.h call so that the final form of the string is saved in the binary?
> For instance, for a statement like...
>
> strrchr(__FILE__, '/') + 1
>
> …and where clang is called on this code’s source file with “clang
> /some/long/path/file.c”, can I end up with only “file.c” stored in the
> binary on disk?  I think you can see that I am attempting to avoid full
> paths from my machine ending up in the program.  My IDE, Xcode, always
> passes full paths to clang when building.  Thanks.
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140920/7d7a71fd/attachment.html>


More information about the llvm-dev mailing list