On 08/06/18 16:54, Gao, Liming wrote:
> Laszlo: We manually search the unused functions in the module source
> files, and also verify the build to make sure the unused functions are
> real dead code.
Works for me, but then the commit message should state exactly this.
Such as:
"""
Remove functions that have external linkage but are never called.
(We have manually verified that no function removed in this patch is
ever called.)
"""
Because:
* "Dead code" also means such code that is conditionally reachable (for
example, there is a conditional call to the function); however deeper
analysis reveals that the condition can never evaluate to TRUE.
A patch that eliminates code for this case must stand on its own,
because it needs non-mechanic review. From the commit message it
wasn't clear whether such changes were in scope, and it was difficult
to tell from the code (due to the size of the patch).
* "External linkage" is relevant because it highlights that the current
situation is at least in part the result of tooling limitations.
A large number of functions in MdeModulePkg should be STATIC (= be
given internal linkage), but they are kept with external linkage
because some VS debugging tools cannot cope with STATIC functions (to
my understanding).
In turn, because utility functions are never made STATIC, gcc cannot
emit warnings when some of those functions are never actually called
(if they were STATIC, gcc would abort the build with to warnings).
Obviously this doesn't apply to all utility functions (some may have
originally been called from multiple source files).
> I agree to separate this patch as the module level. So, we can
> document which unused functions are removed in the driver.
Thanks -- given the explanation above, I'd be fine with just a commit
message update. Still, if Shenglei has the time, I think that
module-level patching would be far better.
Thanks!
Laszlo
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel