-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[LTO] Add unified LTO tests for the PS targets. #148229
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
[LTO] Add unified LTO tests for the PS targets. #148229
Conversation
@llvm/pr-subscribers-clang Author: Ying Yi (MaggieYingYi) ChangesFor the PS targets, unified LTO pipeline is used as default behaviour when enabling LTO. Other targets use Distinct LTO pipeline behaviour as default behaviours. Unified LTO tests are added in this PR:
Full diff: https://github.com/llvm/llvm-project/pull/148229.diff 2 Files Affected:
diff --git a/clang/test/CodeGen/asan-unified-lto.ll b/clang/test/CodeGen/asan-unified-lto.ll
index 7b790d49e3fdb..21734e1fd8f67 100644
--- a/clang/test/CodeGen/asan-unified-lto.ll
+++ b/clang/test/CodeGen/asan-unified-lto.ll
@@ -5,6 +5,7 @@
; RUN: %clang_cc1 -emit-llvm-bc -O1 -flto -fsanitize=address -o - -x ir < %s | llvm-dis -o - | FileCheck %s
; RUN: %clang_cc1 -emit-llvm-bc -O1 -flto -funified-lto -fsanitize=address -o - -x ir < %s | llvm-dis -o - | FileCheck %s
+; RUN: %clang_cc1 -emit-llvm-bc -O1 -flto -fno-unified-lto -fsanitize=address -o - -x ir < %s | llvm-dis -o - | FileCheck %s
; CHECK: @anon.3ee0898e5200a57350fed5485ae5d237
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
diff --git a/clang/test/CodeGen/unified-lto-pipeline-ps.c b/clang/test/CodeGen/unified-lto-pipeline-ps.c
new file mode 100644
index 0000000000000..5849bf051dfec
--- /dev/null
+++ b/clang/test/CodeGen/unified-lto-pipeline-ps.c
@@ -0,0 +1,33 @@
+// RUN: %clang -flto=thin --target=x86_64-scei-ps4 -O2 -c %s -o %t.ps4.tu -Xclang -fdebug-pass-manager 2>%t.ps4.tu.txt
+// RUN: %clang -flto=thin --target=x86_64-sie-ps5 -O2 -c %s -o %t.ps5.tu -Xclang -fdebug-pass-manager 2>%t.ps5.tu.txt
+// RUN: %clang -flto=full --target=x86_64-scei-ps4 -O2 -c %s -o %t.ps4.fu -Xclang -fdebug-pass-manager 2>%t.ps4.fu.txt
+// RUN: %clang -flto=full --target=x86_64-sie-ps5 -O2 -c %s -o %t.ps5.fu -Xclang -fdebug-pass-manager 2>%t.ps5.fu.txt
+// RUN: %clang -flto=thin -fno-unified-lto --target=x86_64-scei-ps4 -O2 -c %s -o %t.ps4.tn -Xclang -fdebug-pass-manager 2>%t.ps4.tn.txt
+// RUN: %clang -flto=full -fno-unified-lto --target=x86_64-scei-ps4 -O2 -c %s -o %t.ps4.fn -Xclang -fdebug-pass-manager 2>%t.ps4.fn.txt
+// RUN: %clang -flto=thin --target=x86_64-unknown-linux -O2 -c %s -o %t.l.tn -Xclang -fdebug-pass-manager 2>%t.l.tn.txt
+// RUN: %clang -flto=full --target=x86_64-unknown-linux -O2 -c %s -o %t.l.fn -Xclang -fdebug-pass-manager 2>%t.l.fn.txt
+/// Pre-link bitcode and pass pipelines should be identical for (unified) thin/full on PS4/PS5.
+/// Pipeline on PS5 is also identical (but bitcode won't be identical to PS4 due to the embedded triple).
+// RUN: cmp %t.ps4.tu %t.ps4.fu
+// RUN: cmp %t.ps5.tu %t.ps5.fu
+// RUN: diff %t.ps4.tu.txt %t.ps4.fu.txt
+// RUN: diff %t.ps4.tu.txt %t.ps5.tu.txt
+// RUN: diff %t.ps5.tu.txt %t.ps5.fu.txt
+// RUN: FileCheck --input-file %t.ps4.tu.txt %s
+// CHECK: ThinLTOBitcodeWriterPass
+/// Non-unified PS4/PS5 pass pipelines match Linux. Thin/full are different.
+// RUN: not diff %t.ps4.tn.txt %t.ps4.fn.txt
+// RUN: diff %t.ps4.tn.txt %t.l.tn.txt
+// RUN: diff %t.ps4.fn.txt %t.l.fn.txt
+/// PS4/PS5 unified use the full Linux pipeline (except ThinLTOBitcodeWriterPass vs BitcodeWriterPass).
+// RUN: not diff -u %t.ps4.tu.txt %t.l.fn.txt | FileCheck %s --check-prefix=DIFF --implicit-check-not="{{^[-+!<>] }}"
+// DIFF: -Running pass: ThinLTOBitcodeWriterPass
+// DIFF-NEXT: +Running pass: BitcodeWriterPass
+
+int foo() {
+ return 2 + 2;
+}
+
+int bar() {
+ return foo() + 1;
+}
|
gentle pinging ... |
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
/// Pass pipeline for full is different. | ||
// RUN: not diff %t.0.txt %t.3.txt | ||
/// Pass pipeline for full is different. Unified uses the full Linux pipeline except ThinLTOBitcodeWriterPass vs BitcodeWriterPass. | ||
// RUN: not diff -u %t.0.txt %t.3.txt | FileCheck %s --check-prefix=DIFF --implicit-check-not="{{^[-+!<>] }}" |
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.
I hope that diff -u
is portable. If it is not (e.g. unsupported on niche platforms), they might add some UNSUPPORTED: , but it's not a thing the author and reviewers should be concerned with :)
647766a
to
673cdd3
Compare
For the PS targets, unified LTO pipeline is used as default behaviour when enabling LTO. Other targets use Distinct LTO pipeline behaviour as default behavious. Unified/nonunified LTO checks are enhanced in this PR: 1. Check that the default, unified, and non-unified behavior for asan-unified-lto.ll all match (irrespective of what the default unified/nonunified behavior is). 2. Check that the difference in behavior for 'unified' and 'full' runs is (regarding the passes) is what is expected (rather than simply that they are different).
673cdd3
to
ab2917f
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/12396 Here is the relevant piece of the build log for the reference
|
For the PS targets, unified LTO pipeline is used as default behaviour when enabling LTO. Other targets use Distinct LTO pipeline behaviour as default behaviours. Unified LTO tests are added in this PR: