Dennis Luehring
2012-Jul-05 10:53 UTC
[LLVMdev] clang optimizer does not remove unused/uneeded variables(and accesses) from global scope
addition to my last post: http://groups.google.com/group/llvm-dev/browse_thread/thread/afd85c3f303ec2a9 i know that using static on my globals will remove them - no other compilation unit can then extern the vars but my question is - in this closed szenario clang is "directly" producing the exe - isn't clang aware of that the vars are not in use? btw: the microsoft compiler still keeps them - even if static, but without demangled names :)
Dimitry Andric
2012-Jul-05 11:30 UTC
[LLVMdev] clang optimizer does not remove unused/uneeded variables(and accesses) from global scope
On 2012-07-05 12:53, Dennis Luehring wrote:> addition to my last post: > http://groups.google.com/group/llvm-dev/browse_thread/thread/afd85c3f303ec2a9 > > i know that using static on my globals will remove them - no other > compilation unit can then extern the vars > > but my question is - in this closed szenario clang is "directly" > producing the exe - isn't clang aware of that the vars are not in use?It can't know that, unless you use link-time optimization. Which optimization level did you use?
Duncan Sands
2012-Jul-05 11:57 UTC
[LLVMdev] clang optimizer does not remove unused/uneeded variables(and accesses) from global scope
Hi Dimitry, On 05/07/12 13:30, Dimitry Andric wrote:> On 2012-07-05 12:53, Dennis Luehring wrote: >> addition to my last post: >> http://groups.google.com/group/llvm-dev/browse_thread/thread/afd85c3f303ec2a9 >> >> i know that using static on my globals will remove them - no other >> compilation unit can then extern the vars >> >> but my question is - in this closed szenario clang is "directly" >> producing the exe - isn't clang aware of that the vars are not in use? > > It can't know that, unless you use link-time optimization. Which > optimization level did you use?it can know: if you looked at his command line you can see that it is producing a final executable from the file, not just compiling it to object code. As far as I know clang relies on an LLVM aware linker to do the link-time optimization, though I'm not sure why: in this kind of case it could just do it itself. On linux you can use the gold linker with the LLVM gold plugin, maybe that can be used on windows too, I wouldn't know. Ciao, Duncan.
Possibly Parallel Threads
- [LLVMdev] clang optimizer does not remove unused/uneeded variables(and accesses) from global scope
- [LLVMdev] clang optimizer does not remove unused/uneeded variables(and accesses) from global scope
- [LLVMdev] clang optimizer does not remove unused/uneeded variables(and accesses) from global scope
- Building LLVM with VisualStudio 2017
- lattice panels with grouped extra data as text?