aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2023-04-26 20:43:11 -0700
committerFangrui Song <i@maskray.me>2023-04-26 20:43:11 -0700
commit71cb689661ab107986a3773571ab9985d6c47114 (patch)
tree6bfc45c77f2a22d6fd2a2bdd83c66571c14be5a9 /llvm/lib
parent1855c0a82a2798276cafe765d825ac7875f5bf1d (diff)
downloadllvm-71cb689661ab107986a3773571ab9985d6c47114.zip
llvm-71cb689661ab107986a3773571ab9985d6c47114.tar.gz
llvm-71cb689661ab107986a3773571ab9985d6c47114.tar.bz2
[LTO] Change getThinLTOOutputFile to take StringRef
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTO.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 15b6e22..fee09fc 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1404,11 +1404,10 @@ ThinBackend lto::createInProcessThinBackend(ThreadPoolStrategy Parallelism,
// Given the original \p Path to an output file, replace any path
// prefix matching \p OldPrefix with \p NewPrefix. Also, create the
// resulting directory if it does not yet exist.
-std::string lto::getThinLTOOutputFile(const std::string &Path,
- const std::string &OldPrefix,
- const std::string &NewPrefix) {
+std::string lto::getThinLTOOutputFile(StringRef Path, StringRef OldPrefix,
+ StringRef NewPrefix) {
if (OldPrefix.empty() && NewPrefix.empty())
- return Path;
+ return std::string(Path);
SmallString<128> NewPath(Path);
llvm::sys::path::replace_path_prefix(NewPath, OldPrefix, NewPrefix);
StringRef ParentPath = llvm::sys::path::parent_path(NewPath.str());
@@ -1447,13 +1446,13 @@ public:
MapVector<StringRef, BitcodeModule> &ModuleMap) override {
StringRef ModulePath = BM.getModuleIdentifier();
std::string NewModulePath =
- getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix);
+ getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix);
if (LinkedObjectsFile) {
std::string ObjectPrefix =
NativeObjectPrefix.empty() ? NewPrefix : NativeObjectPrefix;
- std::string LinkedObjectsFilePath = getThinLTOOutputFile(
- std::string(ModulePath), OldPrefix, ObjectPrefix);
+ std::string LinkedObjectsFilePath =
+ getThinLTOOutputFile(ModulePath, OldPrefix, ObjectPrefix);
*LinkedObjectsFile << LinkedObjectsFilePath << '\n';
}