Skip to content

[lldb] Don't invent an alignment if not encoded - #13566

Open
augusto2112 wants to merge 2 commits into
swiftlang:stable/21.xfrom
augusto2112:embed-multipayload-enum-alignment
Open

[lldb] Don't invent an alignment if not encoded#13566
augusto2112 wants to merge 2 commits into
swiftlang:stable/21.xfrom
augusto2112:embed-multipayload-enum-alignment

Conversation

@augusto2112

Copy link
Copy Markdown

The compiler only emits non-standard alignments into DWARF. RemoteMirror's TypeLowering knows how to calculate an enum's alignment from its payloads. If we don't know the type's alignment, let it do it.

Assisted-by: Claude

@augusto2112
augusto2112 requested a review from a team as a code owner July 29, 2026 20:11
@augusto2112
augusto2112 force-pushed the embed-multipayload-enum-alignment branch from 902841c to e33db20 Compare July 29, 2026 20:43
@augusto2112

Copy link
Copy Markdown
Author

swiftlang/swift#91080

@swift-ci test

Comment thread lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwiftDescriptorFinder.cpp Outdated
Comment thread lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwiftDescriptorFinder.cpp Outdated
Comment thread lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserSwiftDescriptorFinder.cpp Outdated
Comment thread lldb/test/API/lang/swift/embedded/multipayload_enum_alignment/Makefile Outdated
The compiler only emits non-standard alignments into DWARF.
RemoteMirror's TypeLowering knows how to calculate an enum's alignment
from its payloads. If we don't know the type's alignment, let it do it.

Assisted-by: Claude
@augusto2112
augusto2112 force-pushed the embed-multipayload-enum-alignment branch from e33db20 to c41d460 Compare July 30, 2026 01:02
@augusto2112

Copy link
Copy Markdown
Author

@swift-ci test

@augusto2112

Copy link
Copy Markdown
Author

swiftlang/swift#91080

@swift-ci test

// in DWARF? That's what reflection metadata does.
unsigned stride = ((byte_size + alignment - 1) & ~(alignment - 1));
// If the alignment is unknown, so is the stride.
unsigned stride = alignment ? llvm::alignTo(byte_size, alignment) : 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still confused by the logic here:

  1. on 603 we do byte_size?:8 but not on 606. I guess becuase 0 is still a valid value
  2. what's the semantics of alignTo(0, x) ?

I think this all gets clearer if you have an if (byte_size == 0) block that handles that case separately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants