Thanks,Ed
_______________________________________________ LLVM Developers mailing list LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell
Is there a reason why LLVM's link-time optimization won't work for you?
http://llvm.org/docs/GoldPlugin.html
http://llvm.org/docs/LinkTimeOptimization.html
int mult(int a, int b){
return a*b;
}
int main(void){
return 0;
}
While mult is never called it still is not removed. I just can't seem to get opt to understand it's seeing the whole program so it can remove this globally accessible function. What am I missing? Seems related to the missing -fwhole-program flag in clang. Perhaps this is not even possible? If I can't get any answers here I may repost that specific question since I didn't list [opt] in the original question subject.
Thanks,
Ed
main and those merged by attributeexternally_visible become static functions and in effect are optimized more aggressively by interprocedural optimizers.So we can accomplish that for now with a simple pass on the source. But that had me thinking, how do we accomplish the same for unused C++ classes or member functions within classes. I figured we could accomplish that by changing the linkage type within the llvm IR. But it turns out these already get linkonce_odr linkage. http://llvm.org/docs/LangRef.html states "Unreferenced linkonce globals are allowed to be discarded"
class num{
private:
int number;
public:
num(int n):number(n){}
int mult(int other){
return number*other;
}
};
int main(void){
return 0;
that had me thinking, how do we accomplish the same for unused C++
classes or member functions within classes. I figured we could
accomplish that by changing the linkage type within the llvm IR. But it
turns out these already get linkonce_odr linkage.
http://llvm.org/docs/LangRef.html states "Unreferenced linkonce globals
are allowed to be discarded"
The answer is still internalize. Don't include their names in the list of public APIs and they'll be switched to 'internal' linkage, then deleted by the LTO passes.
There is no representation of a class in llvm or .o files. Instead, there's a plain struct which represents the typed memory (ie., storage for the non-static data members only), plus a pile of functions which take a pointer to that memory as their first argument (the member functions taking their 'this' argument).
Note that 'static' functions also just change the linkage to internal. So does putting code in an anonymous namespace. The main thing you get out of linker integration into LLVM LTO is that the linker can look at the pile of non-llvm code and determine which symbols are required by the rest of the system and compute that public API list for internalize.