> Sure it is. Why not?
Do you have a reference for that? I'd expect this to be hard, at linking time you no longer have the C++ source, so it's much harder to make such decisions.
You don't need the C++ source, just the IR. LLVM already removes mallocs if they are unused:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-July/033017....
Sure it is. Why not?
C++ compilers don't usually do this because it doesn't help much—explicit memory management encourages people to not allocate unless necessary in the first place.