-
Notifications
You must be signed in to change notification settings - Fork 15.9k
[SystemZ] Add SP alignment to the DataLayout string. #176041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-systemz Author: Jonas Paulsson (JonPsson1) ChangesAdd '-S64' to the SystemZ datalayout string, to avoid overalignment of stack objects. This changes 25 files on SPEC over 5 benchmarks, with fewer cases of runtime-alignment (NILL instructions). @uweigand @nikic Full diff: https://github.com/llvm/llvm-project/pull/176041.diff 3 Files Affected:
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index e95079490bd3c..ee8e45511720c 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -207,11 +207,11 @@
// 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
@@ -219,7 +219,7 @@
// 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
diff --git a/llvm/lib/TargetParser/TargetDataLayout.cpp b/llvm/lib/TargetParser/TargetDataLayout.cpp
index b8c3b4325558c..b985c1eec4244 100644
--- a/llvm/lib/TargetParser/TargetDataLayout.cpp
+++ b/llvm/lib/TargetParser/TargetDataLayout.cpp
@@ -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);
diff --git a/llvm/test/CodeGen/SystemZ/stack-align.ll b/llvm/test/CodeGen/SystemZ/stack-align.ll
new file mode 100644
index 0000000000000..d7f6b1e8a46f2
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/stack-align.ll
@@ -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
+}
|
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
nikic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to handle this in
llvm-project/llvm/lib/IR/AutoUpgrade.cpp
Line 6477 in c322a0c
| std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) { |
|
@nikic Thanks for review - I handled this in UpgradeDataLayoutString() as well. LGTY? |
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
nikic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
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.
uweigand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well.
LLVM 23 will mark the stack as aligned for more efficient code: llvm/llvm-project#176041
LLVM 23 will mark the stack as aligned for more efficient code: llvm/llvm-project#176041
s390x: Support aligned stack datalayout LLVM 23 will mark the stack as aligned for more efficient code: llvm/llvm-project#176041 r? durin42 @rustbot label llvm-main
Rollup merge of #151429 - s390x, r=durin42 s390x: Support aligned stack datalayout LLVM 23 will mark the stack as aligned for more efficient code: llvm/llvm-project#176041 r? durin42 @rustbot label llvm-main
Add '-S64' to the SystemZ datalayout string, to avoid overalignment of stack objects. Fixes llvm#173402
Add '-S64' to the SystemZ datalayout string, to avoid overalignment of stack objects.
Fixes #173402
This changes 25 files on SPEC over 5 benchmarks, with fewer cases of runtime-alignment (NILL instructions).
@uweigand @nikic