[ms] [llvm-ml] Fix struct padding logic
authorEric Astor <epastor@google.com>
Mon, 14 Sep 2020 18:11:29 +0000 (14:11 -0400)
committerEric Astor <epastor@google.com>
Mon, 14 Sep 2020 18:12:20 +0000 (14:12 -0400)
commit7c44ee8e1937c7402a106f3fa6a356caa73a14e8
tree9b14809945f144721d08b068f275e54c191cd086
parentda17e0d5c1dfabcba887e323b1aabc8cc4342cd6
[ms] [llvm-ml] Fix struct padding logic

MASM structs are end-padded to have size a multiple of the smaller of the requested alignment and the size of their largest field (taken recursively, if they have a field of STRUCT type).

This matches the behavior of ml.exe and ml64.exe. Our original implementation followed the MASM 6.0 documentation, which instead specified that MASM structs were padded to a multiple of their requested alignment.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D87248
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/test/tools/llvm-ml/struct_alignment.test [new file with mode: 0644]