This is an archive of the discontinued LLVM Phabricator instance.

[DWARF][codegen] Fix for Aranges when split inlining is present
ClosedPublic

Authored by ayermolo on Feb 2 2022, 3:50 PM.

Details

Summary

When we enable -fsplit-dwarf-inlining we end up with two entries
in .debug_aranges for each CU. Because it processes Skeleton CU
inline information and DWO CU.

Furthermore address calculations were incorrect because we were processing sections in Skeleton CU.

Diff Detail

Event Timeline

ayermolo created this revision.Feb 2 2022, 3:50 PM
ayermolo requested review of this revision.Feb 2 2022, 3:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2022, 3:50 PM
ayermolo edited the summary of this revision. (Show Details)Feb 2 2022, 3:54 PM
ayermolo retitled this revision from [DWARF][server-llvm] Fix for Aranges when split inlining is present to [DWARF][codegen] Fix for Aranges when split inlining is present.Feb 2 2022, 4:13 PM
dblaikie added inline comments.Feb 2 2022, 4:15 PM
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2941–2942 ↗(On Diff #405478)

Should we avoid putting these entries in ArangeLabels to begin with, rather than filtering them out here?

llvm/test/DebugInfo/X86/fission-inline-aranges.ll
12–32

Does this need templates, using declarations, and if/scopes, etc? Or could it be simplified a bit? If it can't be, might be worth some explanatory text about why all these features are needed to tickle the bug?

ayermolo added inline comments.Feb 2 2022, 4:18 PM
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2941–2942 ↗(On Diff #405478)

I looked at where this is added, and I think it would involve passing a flag through multiple levels of API. I wasn't sure what would be more acceptable. Just cleaning it up here, or doing that. This is more self contained.

ayermolo added inline comments.Feb 2 2022, 4:19 PM
llvm/test/DebugInfo/X86/fission-inline-aranges.ll
12–32

I re-purposed fission-inline.ll. Maybe just add extra checks there?

dblaikie added inline comments.Feb 2 2022, 4:24 PM
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2941–2942 ↗(On Diff #405478)

Could you roughly summarize the layers of API it'd have to go through? There might be some nice way to structure it.

llvm/test/DebugInfo/X86/fission-inline-aranges.ll
12–32

Be best to make something simpler if possible, I think.

What's the DWARF (or source) that's of interest/necessary to reproduce the issue?

ayermolo added inline comments.Feb 2 2022, 4:49 PM
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
2941–2942 ↗(On Diff #405478)

Umm, nevermind. I looked at that code with fresh set of eyes and I think only API that needs to be modified is addLocalLabelAddress and in addLabelAddress we can do a check something like:

bool IsSplitDebugInlining = this->getCUNode()->getSplitDebugInlining();
bool IsSkeletonCU = DD->useSplitDwarf() && !Skeleton;
bool ShouldEmitArangeLabel = IsSplidDebugInlining && IsSkeletonCU || !DD->useSplitDwarf();
bool IsSplitDebugInlining = this->getCUNode()->getSplitDebugInlining();
bool IsSkeletonCU = DD->useSplitDwarf() && !Skeleton;
bool NoneSkeletonCU = DD->useSplitDwarf() && Skeleton;
bool ShouldEmitArangeLabel = (!IsSplitDebugInlining && IsSkeletonCU) || NoneSkeletonCU || !DD->useSplitDwarf();

Going to do a bit more testing, before updating this review.

ayermolo updated this revision to Diff 405503.Feb 2 2022, 5:22 PM

Changed the check to not emit in the first place.

ayermolo updated this revision to Diff 405511.Feb 2 2022, 6:16 PM

Updated the test, added another test when inlining is disabled.
Updated check. What we want to do is not add labels for skeleton CU at all I think.

@dblaikie what do you think about latest version, and reduced tests?

ormris removed a subscriber: ormris.Feb 3 2022, 8:06 PM
dblaikie added inline comments.Feb 4 2022, 7:13 PM
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
70–71

This boils down to:

bool ShouldEmitArangeLabel = Skeleton || !DD->useSplitDwarf();

I think?

DD->useSplitDwarf() && Skeleton) || !DD->useSplitDwarf();
->
(D->useSplitDwarf() || !DD->useSplitDwarf()) && (Skeleton || !D->useSplitDwarf())
->
true && (Skeleton || !D->useSplitDwarf())
->
Skeleton || !D->useSplitDwarf()

76–77

Could this be moved to above line 74 and then removed from the addLocalLabelAddress rather than duplicated? (would avoid needing to pass the extra parameter to addLocalLabelAddress)

505

Could you remove this unrelated change (you can commit it separately if you like)

ayermolo added inline comments.Feb 4 2022, 7:28 PM
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
70–71

ah right.

76–77

addLocalLabelAddress is a public API. Right now it's only used from here, but in the future if someone else uses it, they will need to know that addArangeLabel needs to be called before it is invoked. Maybe just eliminate it entirely and move functionality into addLabelAddress?

dblaikie added inline comments.Feb 4 2022, 7:39 PM
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
76–77

LLVM's concept of "public" API is fairly loose. We move functionality around pretty regularly.

I don't mind too much rolling the functionality in, it's not a very long function. Either way.

ayermolo updated this revision to Diff 406555.Feb 7 2022, 12:07 PM

Addressed comments.
I was thinking in next commit role addLocalLabelAddress into addLabelAddress

ayermolo marked 3 inline comments as done.Feb 7 2022, 12:07 PM
ayermolo marked an inline comment as done.
ayermolo marked 2 inline comments as done.
dblaikie accepted this revision.Feb 7 2022, 1:37 PM
dblaikie added inline comments.
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
74–76

Could potentially commit the addArangeLabel refactor as a separate preliminary commit to make it clear what's changing (& narrow the area to revert if the functional part has issues), but no worries either way.

This revision is now accepted and ready to land.Feb 7 2022, 1:37 PM
ayermolo added inline comments.Feb 7 2022, 2:24 PM
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
74–76

Posted D119192.

This revision was landed with ongoing or failed builds.Feb 9 2022, 11:52 AM
This revision was automatically updated to reflect the committed changes.