Skip to content

Commit 118a78e

Browse files
tothambrus11kyouko-taiga
authored andcommitted
Add more tests for stackAlignment
1 parent 8dc6b08 commit 118a78e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Tests/LLVMTests/DataLayoutTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,28 @@ final class DataLayoutTests: XCTestCase {
8787
if let n = m.layout.stackAlignment { XCTAssertNotEqual(n, 0) }
8888
}
8989

90+
func testStackAlignmentOfTargetSpecifyingOne() throws {
91+
#if !SWIFTY_LLVM_CROSS_COMPILATION_ENABLED
92+
throw XCTSkip()
93+
#else
94+
// The data layout of x86_64 Linux specifies a natural stack alignment of 128 bits.
95+
let t = try TargetSpecification(target: .init("x86_64-unknown-linux-gnu"))
96+
let m = Module("foo", targetMachine: .init(target: t))
97+
XCTAssertEqual(m.layout.stackAlignment, 16)
98+
#endif
99+
}
100+
101+
func testStackAlignmentOfTargetSpecifyingNone() throws {
102+
#if !SWIFTY_LLVM_CROSS_COMPILATION_ENABLED
103+
throw XCTSkip()
104+
#else
105+
// The data layout of AVR doesn't specify any natural stack alignment.
106+
let t = try TargetSpecification(target: .init("avr-unknown-unknown"))
107+
let m = Module("foo", targetMachine: .init(target: t))
108+
XCTAssertNil(m.layout.stackAlignment)
109+
#endif
110+
}
111+
90112
func testPointerSize() throws {
91113
let m = try Module("foo", targetMachine: .host())
92114

0 commit comments

Comments
 (0)