It removes some needless deep indentation and some redundant statements.
It prepares the code for a more clean next patch - DWARF index callbacks D77327.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
250 ms | LLVM.Other::Unknown Unit Message ("") |
Event Timeline
Overall looks good to me except for one larger logic change. Maybe a your comment can clarify this. The code was in a very bad shape before, given the countless amounts of shortcuts you could take.
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | ||
---|---|---|
2014 | I assume this can be removed because you're iterating over num_matches == 0 when it's empty. But I cannot tell about the DWARFDebugInfo &debug_info = dwarf->DebugInfo(); and how costly this call is and if it makes sense to run when the offsets are empty. | |
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
525 | Why is the if no longer needed? | |
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
2061 | Nice shortcut. | |
2943 | This looks like a logic change and I wonder if it should go in a separate patch, maybe? |
I am generally very okay with this change, though some changes look suspicious, as @kwk noted.
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | ||
---|---|---|
2014 | I did not put an attention to it, thanks for catching it. Personally I think it is OK but when it has been brought up I am fixing this possible performance regression. SymbolFileDWARF::DebugInfo() contains some llvm::call_once(m_info_once_flag which does have some cost. | |
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
525 | It will now run DWARFMappedHash::ExtractDIEArray on empty array which is cheap, it does nothing. | |
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
2943 | This should be NFC, do I miss something? if (a == b) { c; } The patch changes it to: if (a != b) continue; c; |
I feel like this should have been split in two. It feels like there are straight forward obviously correct changes and a several others that require some thinking about but look correct.
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
---|---|---|
525 | If we stick with this change, please add a comment explaining this. It is not obvious and someone later on may come and change it back thinking this is a bug. |
That's a really good point. I agree. Can you split all changes of one kind into separate patches?
No need to split this into multiples revisions. It is just a rewrite of some odd nesting.
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
---|---|---|
2943 | Ah, now I see that it was previously a block on the right side of the diff :). |
I have checked in the really obvious parts as rG80237523193d.
The remainder is left here - although I do not see there more problematic parts now.
Does anyone know why harbormaster is useless?
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | ||
---|---|---|
2014 | not costly at all. This will be fine. | |
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
69–70 | This logic is easy to understand by reading the code. | |
69–82 | This logic is harder to follow. Maybe: if (!(die_tag == 0 || die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type)) continue; |
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
---|---|---|
69–82 | OK, changed it. |
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | ||
---|---|---|
2016 | Can this be made into a range-based for loop in a separate commit? | |
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
2057 | same here (later) | |
2915 | These two continues IMO are a bit confusing to read this way. Perhaps in this case an if (log) block with just one continue at the end is easier to read. Up to you. | |
2951 | I think I'd prefer a return over a break, (iff they are equivalent!). |
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
---|---|---|
70 | I also feel like the previous version was more readable. Is there another gain that I am missing? | |
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
2065 | This whole switch feels overly clever, how about: if (die.Tag() != DW_TAG_variable) continue; |
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | ||
---|---|---|
2016 | In D77327 it gets changed into a callback anyway so method_die_offsets no longer exists there. | |
lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp | ||
70 | I find both versions OK but this patch is going to revert my change in rG80237523193d so everyone should be happy. | |
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | ||
2057 | In D77327 it gets changed into a callback anyway so die_offsets no longer exists there. | |
2915 | OK, changed back to if (log) { ... }. I even was not sure with that. |
I assume this can be removed because you're iterating over num_matches == 0 when it's empty. But I cannot tell about the DWARFDebugInfo &debug_info = dwarf->DebugInfo(); and how costly this call is and if it makes sense to run when the offsets are empty.