Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/test/CodeGen/target-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,19 @@
// RUN: FileCheck %s -check-prefix=SYSTEMZ
// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -target-feature +soft-float -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=SYSTEMZ
// SYSTEMZ: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
// SYSTEMZ: target datalayout = "E-S64-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"

// RUN: %clang_cc1 -triple s390x-unknown -target-cpu z13 -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=SYSTEMZ-VECTOR
// SYSTEMZ-VECTOR: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
// SYSTEMZ-VECTOR: target datalayout = "E-S64-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"

// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z10 -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=ZOS
// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z13 -target-feature +soft-float -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=ZOS
// RUN: %clang_cc1 -triple s390x-none-zos -target-cpu z13 -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=ZOS
// ZOS: target datalayout = "E-m:l-p1:32:32-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
// ZOS: target datalayout = "E-S64-m:l-p1:32:32-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"

// RUN: %clang_cc1 -triple msp430-unknown -o - -emit-llvm %s | \
// RUN: FileCheck %s -check-prefix=MSP430
Expand Down
7 changes: 7 additions & 0 deletions llvm/lib/IR/AutoUpgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6532,6 +6532,13 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
return Res;
}

if (T.isSystemZ() && !DL.empty()) {
// Make sure the stack alignment is present.
if (!DL.contains("-S64"))
return "E-S64" + DL.drop_front(1).str();
return DL.str();
}

auto AddPtr32Ptr64AddrSpaces = [&DL, &Res]() {
// If the datalayout matches the expected format, add pointer size address
// spaces to the datalayout.
Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/TargetParser/TargetDataLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ static std::string computeSystemZDataLayout(const Triple &TT) {
// Big endian.
Ret += "E";

// The natural stack alignment is 64 bits.
Ret += "-S64";

// Data mangling.
Ret += getManglingComponent(TT);

Expand Down
17 changes: 17 additions & 0 deletions llvm/test/CodeGen/SystemZ/stack-align.ll
Copy link
Contributor

Choose a reason for hiding this comment

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

Use update_test_checks.py please.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; RUN: opt < %s -mtriple=s390x-unknown-linux-gnu -mcpu=z16 -S -passes=infer-alignment \
; RUN: 2>&1 | FileCheck %s
;
; Test that the alignment of the alloca is not increased beyond the stack
; alignment of 8 bytes.

declare void @foo(ptr)

define void @f1(<4 x i64> %Arg) {
; CHECK-LABEL: define void @f1
; CHECK-NEXT: %param = alloca <4 x i64>, align 8
; CHECK-NEXT: store <4 x i64> %Arg, ptr %param, align 8
%param = alloca <4 x i64>, align 8
store <4 x i64> %Arg, ptr %param, align 8
call void @foo(ptr %param)
ret void
}
6 changes: 6 additions & 0 deletions llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ TEST(DataLayoutUpgradeTest, ValidDataLayoutUpgrade) {
"1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9-p7:160:256:256:32-p8:128:128:"
"128:48-p9:192:256:256:32");

// Check that SystemZ adds -S64 if needed.
EXPECT_EQ(UpgradeDataLayoutString(
"E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64",
"systemz"),
"E-S64-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64");

// Check that RISCV64 upgrades -n64 to -n32:64.
EXPECT_EQ(UpgradeDataLayoutString("e-m:e-p:64:64-i64:64-i128:128-n64-S128",
"riscv64"),
Expand Down