[llvm] aab488a - [dsymutil] Compute the output location once per input file (NFC)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Mon May 24 16:30:14 PDT 2021
Author: Jonas Devlieghere
Date: 2021-05-24T16:29:05-07:00
New Revision: aab488ac2a56d5829c6d51471987e5c630951074
URL: https://github.com/llvm/llvm-project/commit/aab488ac2a56d5829c6d51471987e5c630951074
DIFF: https://github.com/llvm/llvm-project/commit/aab488ac2a56d5829c6d51471987e5c630951074.diff
LOG: [dsymutil] Compute the output location once per input file (NFC)
Compute the location of the output file just once outside the loop over
the different architectures.
Added:
Modified:
llvm/tools/dsymutil/dsymutil.cpp
Removed:
################################################################################
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 87369f2bc3cf..d9760b5c2ab8 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -436,6 +436,11 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
(Options.LinkOpts.Update || !Options.SymbolMap.empty()))
return OutputLocation(std::string(InputFile));
+ // When dumping the debug map, just return an empty output location. This
+ // allows us to compute the output location once.
+ if (Options.DumpDebugMap)
+ return OutputLocation("");
+
// If a flat dSYM has been requested, things are pretty simple.
if (Options.Flat) {
if (Options.OutputFile.empty()) {
@@ -580,6 +585,15 @@ int main(int argc, char **argv) {
// Shared a single binary holder for all the link steps.
BinaryHolder BinHolder(Options.LinkOpts.VFS);
+ // Compute the output location and update the resource directory.
+ Expected<OutputLocation> OutputLocationOrErr =
+ getOutputFileName(InputFile, Options);
+ if (!OutputLocationOrErr) {
+ WithColor::error() << toString(OutputLocationOrErr.takeError());
+ return 1;
+ }
+ Options.LinkOpts.ResourceDir = OutputLocationOrErr->getResourceDir();
+
// Statistics only require
diff erent architectures to be processed
// sequentially, the link itself can still happen in parallel. Change the
// thread pool strategy here instead of modifying LinkOpts.Threads.
@@ -621,14 +635,6 @@ int main(int argc, char **argv) {
// types don't work with std::bind in the ThreadPool implementation.
std::shared_ptr<raw_fd_ostream> OS;
- Expected<OutputLocation> OutputLocationOrErr =
- getOutputFileName(InputFile, Options);
- if (!OutputLocationOrErr) {
- WithColor::error() << toString(OutputLocationOrErr.takeError());
- return 1;
- }
- Options.LinkOpts.ResourceDir = OutputLocationOrErr->getResourceDir();
-
std::string OutputFile = OutputLocationOrErr->DWARFFile;
if (NeedsTempFiles) {
TempFiles.emplace_back(Map->getTriple().getArchName().str());
@@ -678,12 +684,6 @@ int main(int argc, char **argv) {
return 1;
if (NeedsTempFiles) {
- Expected<OutputLocation> OutputLocationOrErr =
- getOutputFileName(InputFile, Options);
- if (!OutputLocationOrErr) {
- WithColor::error() << toString(OutputLocationOrErr.takeError());
- return 1;
- }
if (!MachOUtils::generateUniversalBinary(TempFiles,
OutputLocationOrErr->DWARFFile,
Options.LinkOpts, SDKPath))
More information about the llvm-commits
mailing list