[clang] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch static and avoid useless copies in their arguments (PR #69463)
Juan Manuel Martinez Caamaño via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 19 03:44:21 PDT 2023
https://github.com/jmmartinez updated https://github.com/llvm/llvm-project/pull/69463
>From aff47154ae4d45c2852382aed034ea44df4886d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= <juamarti at amd.com>
Date: Wed, 18 Oct 2023 15:45:07 +0200
Subject: [PATCH 1/3] [NFC][Clang] Remove unused variable "AOBFileNames"
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 25fd940584624ee..66790508274ab8b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2144,7 +2144,6 @@ bool tools::GetSDLFromOffloadArchive(
Lib = Lib.drop_front(2);
for (auto LPath : LibraryPaths) {
ArchiveOfBundles.clear();
- SmallVector<std::string, 2> AOBFileNames;
auto LibFile =
(Lib.startswith(":") ? Lib.drop_front()
: IsMSVC ? Lib + Ext : "lib" + Lib + Ext)
>From 45aad919ed102933fd4810d98ab1e219bf4a660f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= <juamarti at amd.com>
Date: Thu, 19 Oct 2023 12:17:29 +0200
Subject: [PATCH 2/3] [NFC][Clang] Make GetSDLFromOffloadArchive and SDLSearch
static
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 4 ++--
clang/lib/Driver/ToolChains/CommonArgs.h | 13 -------------
2 files changed, 2 insertions(+), 15 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 66790508274ab8b..4f1a87617516317 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2041,7 +2041,7 @@ void tools::addX86AlignBranchArgs(const Driver &D, const ArgList &Args,
/// convention has been to use the prefix “lib”. To avoid confusion with host
/// archive libraries, we use prefix "libbc-" for the bitcode SDL archives.
///
-bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
+static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
SmallVector<std::string, 8> LibraryPaths, std::string Lib,
StringRef Arch, StringRef Target, bool isBitCodeSDL) {
@@ -2118,7 +2118,7 @@ bool tools::SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
/// the library paths. If so, add a new command to clang-offload-bundler to
/// unbundle this archive and create a temporary device specific archive. Name
/// of this SDL is passed to the llvm-link tool.
-bool tools::GetSDLFromOffloadArchive(
+static bool GetSDLFromOffloadArchive(
Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args, SmallVector<std::string, 8> LibraryPaths,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
index 096152bfbdcf68a..f364c9793c9be62 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -66,19 +66,6 @@ void AddStaticDeviceLibs(Compilation *C, const Tool *T, const JobAction *JA,
llvm::opt::ArgStringList &CmdArgs, StringRef Arch,
StringRef Target, bool isBitCodeSDL);
-bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CmdArgs,
- SmallVector<std::string, 8> LibraryPaths, std::string Lib,
- StringRef Arch, StringRef Target, bool isBitCodeSDL);
-
-bool GetSDLFromOffloadArchive(Compilation &C, const Driver &D, const Tool &T,
- const JobAction &JA, const InputInfoList &Inputs,
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args,
- SmallVector<std::string, 8> LibraryPaths,
- StringRef Lib, StringRef Arch, StringRef Target,
- bool isBitCodeSDL);
-
const char *SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args,
const InputInfo &Input, const InputInfo &Output);
>From 7472c0506e4f58c95c7c3eec90dad00f29515f67 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Juan=20Manuel=20MARTINEZ=20CAAMA=C3=91O?= <juamarti at amd.com>
Date: Thu, 19 Oct 2023 12:20:38 +0200
Subject: [PATCH 3/3] [NFC][Clang] Make read-only arguments of
GetSDLFromOffloadArchive and SDLSearch read-only references instead of
copying them
---
clang/lib/Driver/ToolChains/CommonArgs.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4f1a87617516317..018f708be031aa8 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2043,8 +2043,9 @@ void tools::addX86AlignBranchArgs(const Driver &D, const ArgList &Args,
///
static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
- SmallVector<std::string, 8> LibraryPaths, std::string Lib,
- StringRef Arch, StringRef Target, bool isBitCodeSDL) {
+ const SmallVectorImpl<std::string> &LibraryPaths,
+ StringRef Lib, StringRef Arch, StringRef Target,
+ bool isBitCodeSDL) {
SmallVector<std::string, 12> SDLs;
std::string LibDeviceLoc = "/libdevice";
@@ -2121,8 +2122,9 @@ static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
static bool GetSDLFromOffloadArchive(
Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args, SmallVector<std::string, 8> LibraryPaths,
- StringRef Lib, StringRef Arch, StringRef Target, bool isBitCodeSDL) {
+ llvm::opt::ArgStringList &CC1Args,
+ const SmallVectorImpl<std::string> &LibraryPaths, StringRef Lib,
+ StringRef Arch, StringRef Target, bool isBitCodeSDL) {
// We don't support bitcode archive bundles for nvptx
if (isBitCodeSDL && Arch.contains("nvptx"))
More information about the cfe-commits
mailing list