llvm-project/llvm/test/tools/llvm-ml/struct_alignment.test
Eric Astor 7c44ee8e19 [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
2020-09-14 14:12:20 -04:00

45 lines
682 B
Plaintext

; RUN: llvm-ml -filetype=asm %s | FileCheck %s
.data
FOO STRUCT 8
f FWORD -1
FOO ENDS
t1 FOO <>
; CHECK-LABEL: t1:
; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .short 65535
; CHECK-NOT: .zero
BAZ STRUCT
b BYTE 3 DUP (-1)
f FWORD -1
BAZ ENDS
FOOBAR STRUCT 8
f1 BAZ <>
f2 BAZ <>
h BYTE -1
FOOBAR ENDS
t2 FOOBAR <>
; CHECK-LABEL: t2:
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .short 65535
; CHECK-NEXT: .zero 3
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .long 4294967295
; CHECK-NEXT: .short 65535
; CHECK-NEXT: .byte -1
; CHECK-NEXT: .zero 2
.code
END