[clang] [Driver][LTO] Copy fix empty stats filename to AIX (PR #71738)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 9 10:09:13 PST 2023
https://github.com/diggerlin updated https://github.com/llvm/llvm-project/pull/71738
>From 592e0de1d87ad5dbfc7a1fb80974546ce161c02f Mon Sep 17 00:00:00 2001
From: zhijian <zhijian at ca.ibm.com>
Date: Wed, 8 Nov 2023 11:27:30 -0500
Subject: [PATCH 1/4] [Driver][LTO] Copy fix empty stats filename to AIX
---
clang/lib/Driver/ToolChains/AIX.cpp | 10 +++++++++-
clang/test/Driver/save-stats.c | 9 +++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 3e5ebafa15ebe1c..aed8734b2bab0ff 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -233,7 +233,15 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (D.isUsingLTO()) {
assert(!Inputs.empty() && "Must have at least one input.");
- addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
+ // Find the first filename InputInfo object.
+ auto Input = llvm::find_if(
+ Inputs, [](const InputInfo &II) -> bool { return II.isFilename(); });
+ if (Input == Inputs.end())
+ // For a very rare case, all of the inputs to the linker are
+ // InputArg. If that happens, just use the first InputInfo.
+ Input = Inputs.begin();
+
+ addLTOOptions(ToolChain, Args, CmdArgs, Output, *Input,
D.getLTOMode() == LTOK_Thin);
}
diff --git a/clang/test/Driver/save-stats.c b/clang/test/Driver/save-stats.c
index 7b35b80b9f629f8..15f77af19f159ff 100644
--- a/clang/test/Driver/save-stats.c
+++ b/clang/test/Driver/save-stats.c
@@ -28,10 +28,19 @@
// RUN: %clang --target=x86_64-unknown-fuchsia -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
// RUN: %clang --target=avr -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
// RUN: %clang --target=avr -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
+
// CHECK-LTO: "-stats-file=save-stats.stats"
// CHECK-LTO: "-o" "obj/dir{{/|\\\\}}save-stats.exe"
// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats"
+
+// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
+// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
+
+// CHECK-AIX-LTO: "-stats-file=save-stats.stats"
+// CHECK-AIX-LTO: "-o" "obj/dir{{/|\\\\}}save-stats"
+// CHECK-AIX-LTO: "-bplugin_opt:stats-file=save-stats.stats"
+
// RUN: %clang --target=x86_64-unknown-linux -save-stats=obj -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO-OBJ
// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir{{/|\\\\}}save-stats.stats"
>From d49d39e561df84d0247c90d818a8a14adb865f98 Mon Sep 17 00:00:00 2001
From: zhijian <zhijian at ca.ibm.com>
Date: Wed, 8 Nov 2023 16:08:30 -0500
Subject: [PATCH 2/4] minor change: delete an empty line
---
clang/test/Driver/save-stats.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/test/Driver/save-stats.c b/clang/test/Driver/save-stats.c
index 15f77af19f159ff..a148578350fc608 100644
--- a/clang/test/Driver/save-stats.c
+++ b/clang/test/Driver/save-stats.c
@@ -28,7 +28,6 @@
// RUN: %clang --target=x86_64-unknown-fuchsia -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
// RUN: %clang --target=avr -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
// RUN: %clang --target=avr -save-stats -flto -o obj/dir/save-stats.exe -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO
-
// CHECK-LTO: "-stats-file=save-stats.stats"
// CHECK-LTO: "-o" "obj/dir{{/|\\\\}}save-stats.exe"
// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats"
>From 611f934d42a1848c514ae4a6de0c0e35d30394a2 Mon Sep 17 00:00:00 2001
From: zhijian <zhijian at ca.ibm.com>
Date: Wed, 8 Nov 2023 16:43:28 -0500
Subject: [PATCH 3/4] address comment
---
clang/test/Driver/save-stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Driver/save-stats.c b/clang/test/Driver/save-stats.c
index a148578350fc608..ed6a4e1e00f4a5f 100644
--- a/clang/test/Driver/save-stats.c
+++ b/clang/test/Driver/save-stats.c
@@ -34,7 +34,7 @@
// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
-// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats -Wl,-plugin-opt=-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
+// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats -Wl,-plugin-opt:-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
// CHECK-AIX-LTO: "-stats-file=save-stats.stats"
// CHECK-AIX-LTO: "-o" "obj/dir{{/|\\\\}}save-stats"
>From a2f28cb8bde18718ba239acf8f011d0efe0970de Mon Sep 17 00:00:00 2001
From: zhijian <zhijian at ca.ibm.com>
Date: Thu, 9 Nov 2023 13:09:00 -0500
Subject: [PATCH 4/4] change -plugin-opt:-dummy to -bplugin-opt:-dummy
---
clang/test/Driver/save-stats.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/Driver/save-stats.c b/clang/test/Driver/save-stats.c
index ed6a4e1e00f4a5f..54f222f3d57abdf 100644
--- a/clang/test/Driver/save-stats.c
+++ b/clang/test/Driver/save-stats.c
@@ -34,7 +34,7 @@
// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
-// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats -Wl,-plugin-opt:-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
+// RUN: %clang --target=powerpc-unknown-aix -save-stats -flto -o obj/dir/save-stats -Wl,-bplugin-opt:-dummy %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-AIX-LTO
// CHECK-AIX-LTO: "-stats-file=save-stats.stats"
// CHECK-AIX-LTO: "-o" "obj/dir{{/|\\\\}}save-stats"
More information about the cfe-commits
mailing list