> 1. Is doing part (b) necessary? That is, does LLVM's optimization > already eliminate unused code?
I don't believe that it is from a final binary point of view. Unreachable functions will be flagged as internal, and LLVM can do whatever it wants with internal symbols. I would imagine that it would discard these symbols and functions. That being said, we still go through all the time of generating code for the unused functions, and LLVM probably optimizes them at least a little bit. This is such a small percentage of code, however, that I wouldn't worry about doing this step. > 2. My code marks `RuntimeGlue` struct in libstd/task/spawn.rs as dead. > This is because the struct is private and never used directly. > Instead, it contains static methods that are used, so it's not > desirable to warn it. Currently, when my code sees, e.g., > `RuntimeGlue::kill_task`, it would mark the `kill_task` method > definition as live. What I would like to do in addition is mark the > `RuntimeGlue` struct definition as live, but I'm unable to find a way > to look up a struct given its method. How do I do that? I personally do not know of a method to do this in the compiler right now (although one may surely exist), but if it doesn't this would probably be a table calculated as part of the resolve pass. > 3. My code also marks the function `load_argc_and_argv` in > libstd/os.rs as dead when in fact it isn't. I would guess it's because > that function is only used when compiling the rustc source code on > Mac, whereas I'm compiling it on Linux. How do I modify my code to > take account of that? The function should probably be #[cfg(target_os = "linux")] > 4. I'm unable to finish compiling rustc because my addition spots a > number of dead codes in rustc source code. Assuming they are not false > positive, I then have three options: (i) remove the dead code, (ii) > comment it out, or (iii) put an `#[allow(dead_code)];` at the top of > the module. As I'm unfamiliar with the codebase, it's hard to decide > what to do in each case (I'm thankful to dbaupp for much help in this > area). When in doubt, which would be best to do? I would recommend removing whatever possible, but allow(dead_code) is indicative of a bug in the analysis pass or a change which needs to be present in the code. I would not recommend commenting out code (that's what a git history is for). _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
