This is an archive of the discontinued LLVM Phabricator instance.

[NFC][llvm-dwarfdump] Don't calculate unnecessary stats
ClosedPublic

Authored by djtodoro on Feb 17 2021, 8:04 AM.

Details

Summary

Small optimization of the code -- No need to calculate any stats for NULL nodes, and also no need to call the collectStatsForDie() if it is the CU itself.

Diff Detail

Event Timeline

djtodoro created this revision.Feb 17 2021, 8:04 AM
djtodoro requested review of this revision.Feb 17 2021, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 17 2021, 8:04 AM

This definitely won't hurt, but it's a bit inconsistent. The NULL check is inside collectStatsRecursive(), but the CU check is outside of collectStatsForDie(). It would be nice to be consistent and have all functions handle all DIE types with potentially an early exit at the top rather sometimes having the burden to sanitize the input at the call site.

djtodoro updated this revision to Diff 324559.Feb 18 2021, 12:57 AM
  • Use early exit in both funcs

This definitely won't hurt, but it's a bit inconsistent. The NULL check is inside collectStatsRecursive(), but the CU check is outside of collectStatsForDie(). It would be nice to be consistent and have all functions handle all DIE types with potentially an early exit at the top rather sometimes having the burden to sanitize the input at the call site.

I agree. Thanks.

djtodoro retitled this revision from [llvm-dwarfdump][locstats] Unify handling of inlined vars with no loc to [NFC][llvm-dwarfdump] Don't calculate unnecessary stats.Feb 18 2021, 3:51 AM

@aprantl I guess this is ok now ? :)

aprantl accepted this revision.Feb 19 2021, 9:54 AM
This revision is now accepted and ready to land.Feb 19 2021, 9:54 AM
This revision was automatically updated to reflect the committed changes.