It's really not that simple. I want you to sit down and think about these situations:
- What if it's only passed as a function pointer to other parts of the code?
- What if code that imports this code needs it? Is a compiler supposed to know between instances of it being run whether or not a function should be excluded, especially without current knowledge of the other code? The compiler does not build the code in one run, it's run for each and every file. How do you intend to solve this such that the compiler will intelligently know what functions should be excluded for every possible situation?
- If the code is from a module, how is the compiler supposed to handle this? Rebuild the module every time it needs to be used?
These are only a few, but should hopefully give you an idea of why it's not as simple as predicting the runtime of an application (as if that were simple these days).
- What if it's only passed as a function pointer to other parts of the code?
- What if code that imports this code needs it? Is a compiler supposed to know between instances of it being run whether or not a function should be excluded, especially without current knowledge of the other code? The compiler does not build the code in one run, it's run for each and every file. How do you intend to solve this such that the compiler will intelligently know what functions should be excluded for every possible situation?
- If the code is from a module, how is the compiler supposed to handle this? Rebuild the module every time it needs to be used?
These are only a few, but should hopefully give you an idea of why it's not as simple as predicting the runtime of an application (as if that were simple these days).