This is an archive of the discontinued LLVM Phabricator instance.

[globalopt] Don't emit DWARF fragments for members of a struct that cover the whole struct
ClosedPublic

Authored by DavidSpickett on Apr 23 2020, 8:51 AM.

Details

Summary

This can happen when the rest of the members of are zero length. Following the same pattern applied to the SROA pass in:
d7f6f1636d53c3e2faf55cdf20fbb44a1a149df1

Fixes: https://bugs.llvm.org/show_bug.cgi?id=45335

Diff Detail

Event Timeline

DavidSpickett created this revision.Apr 23 2020, 8:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2020, 8:51 AM

Thanks! I can confirm that I do not see a crash anymore with the config I used when initially reporting. I will try to run this patch through all of my kernel build tests this afternoon to make sure nothing else has regressed.

I am not an expert in this area by any means so I don't feel confident reviewing or approving the patch.

llvm/lib/Transforms/IPO/GlobalOpt.cpp
479

Should this be:
if (VarSize && FragmentSizeInBits < *VarSize)?

If we don't have a size, then !VarSize is true, and we proceed to emit a fragment? Seems in juxtaposition with the comment?

llvm/test/DebugInfo/Generic/global-sra-struct-zero-length.ll
76

Is there maybe some of this debug info that's irrelevant and could be cleaned up to help make the test case more concise?

aprantl added inline comments.Apr 27 2020, 2:50 PM
llvm/lib/Transforms/IPO/GlobalOpt.cpp
478–482
// If the FragmentSize is smaller than the variable, emit a fragment expression.
// If the variable size is unknown a fragment must be emitted to be safe.

Otherwise this raises more questions.

llvm/test/DebugInfo/Generic/global-sra-struct-zero-length.ll
3

please explain what is being tested in this test.

41

please try to remove all non-essential attributes from the test.

  • Fixed comments as suggested
  • Added comment to explain purpose of test case
  • Removed unimportant info from the test case
DavidSpickett marked 6 inline comments as done.Apr 28 2020, 4:52 AM
DavidSpickett added inline comments.
llvm/lib/Transforms/IPO/GlobalOpt.cpp
479

Updated the comment as aprantl suggested, now matches the code.

llvm/test/DebugInfo/Generic/global-sra-struct-zero-length.ll
3

Added, please check that this is clear enough.

nickdesaulniers accepted this revision.Apr 28 2020, 8:44 AM

ah got it, thanks for updating the comment, it makes more sense to me now.

Minor nits on the comments (sorry to bikeshed those), but LGTM.

llvm/test/DebugInfo/Generic/global-sra-struct-zero-length.ll
8

indentation and missing semicolon

12

indentation

This revision is now accepted and ready to land.Apr 28 2020, 8:44 AM
aprantl accepted this revision.Apr 28 2020, 9:32 AM
This revision was automatically updated to reflect the committed changes.
DavidSpickett marked an inline comment as done.
DavidSpickett marked 2 inline comments as done.Apr 30 2020, 3:38 AM

@nathanchance Post back here or on the Bugzilla issue if you continue to see failures.