[lld] [clang] [llvm] [llvm-driver] Fix usage of `InitLLVM` on Windows (PR #76306)
Alexandre Ganea via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 30 19:46:13 PST 2023
https://github.com/aganea updated https://github.com/llvm/llvm-project/pull/76306
>From 8187e95ea4e04793fbfc85045aa21f9633bbc03d Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Sat, 23 Dec 2023 19:17:06 -0500
Subject: [PATCH 1/2] [llvm-driver] Fix tool re-entrance on Windows.
Previously, some tools such as `clang` or `lld` which require strict order for certain command-line options, such as `clang -cc1` or `lld -flavor` would not long work on Windows, when these tools were linked as part of `llvm-driver`. This was caused by `InitLLVM` which was part of the `main()` function of these tools, which in turn calls `windows::GetCommandLineArguments`. This function completly replaces argc/argv by new UTF-8 contents, so any ajustements to argc/argv made by `llvm-driver` prior to calling these tools would be reset.
We now call `InitLLVM` as part of the `llvm-driver`. Any further usages to `InitLLVM` on the stack, after the first call in the process would have no effect. In the same way, the last `InitLLVM` on the stack will clear the `ManagedStatics` as usual.
---
llvm/cmake/modules/llvm-driver-template.cpp.in | 2 ++
llvm/lib/Support/InitLLVM.cpp | 6 ++++++
llvm/tools/llvm-driver/llvm-driver.cpp | 6 +++++-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/llvm/cmake/modules/llvm-driver-template.cpp.in b/llvm/cmake/modules/llvm-driver-template.cpp.in
index 16c4fb34714638..71aca6cd140cb5 100644
--- a/llvm/cmake/modules/llvm-driver-template.cpp.in
+++ b/llvm/cmake/modules/llvm-driver-template.cpp.in
@@ -8,9 +8,11 @@
#include "llvm/Support/LLVMDriver.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/InitLLVM.h"
int @TOOL_NAME at _main(int argc, char **, const llvm::ToolContext &);
int main(int argc, char **argv) {
+ llvm::InitLLVM X(argc, argv);
return @TOOL_NAME at _main(argc, argv, {argv[0], nullptr, false});
}
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index 7f475f42f3cb81..2a2e6c254c795a 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -36,8 +36,12 @@ void CleanupStdHandles(void *Cookie) {
using namespace llvm;
using namespace llvm::sys;
+static std::atomic<unsigned> UsageCount{0};
+
InitLLVM::InitLLVM(int &Argc, const char **&Argv,
bool InstallPipeSignalExitHandler) {
+ if (UsageCount++)
+ return;
#ifdef __MVS__
// Bring stdin/stdout/stderr into a known state.
sys::AddSignalHandler(CleanupStdHandles, nullptr);
@@ -94,6 +98,8 @@ InitLLVM::InitLLVM(int &Argc, const char **&Argv,
}
InitLLVM::~InitLLVM() {
+ if (--UsageCount)
+ return;
#ifdef __MVS__
CleanupStdHandles(nullptr);
#endif
diff --git a/llvm/tools/llvm-driver/llvm-driver.cpp b/llvm/tools/llvm-driver/llvm-driver.cpp
index a0f1ca831d93b6..53a8b9357e3780 100644
--- a/llvm/tools/llvm-driver/llvm-driver.cpp
+++ b/llvm/tools/llvm-driver/llvm-driver.cpp
@@ -10,6 +10,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/WithColor.h"
@@ -79,4 +80,7 @@ static int findTool(int Argc, char **Argv, const char *Argv0) {
return 1;
}
-int main(int Argc, char **Argv) { return findTool(Argc, Argv, Argv[0]); }
+int main(int Argc, char **Argv) {
+ llvm::InitLLVM X(Argc, Argv);
+ return findTool(Argc, Argv, Argv[0]);
+}
>From 03d24462dbc2e113bf0f740f3d95f519367c1abd Mon Sep 17 00:00:00 2001
From: Alexandre Ganea <alex_toresh at yahoo.fr>
Date: Sat, 30 Dec 2023 22:45:58 -0500
Subject: [PATCH 2/2] Remove `InitLLVM` from all the tools participating in the
`llvm-driver`.
---
clang/tools/clang-scan-deps/ClangScanDeps.cpp | 2 --
clang/tools/driver/driver.cpp | 2 --
lld/Common/DriverDispatcher.cpp | 1 -
lld/tools/lld/lld.cpp | 2 --
llvm/lib/Support/InitLLVM.cpp | 11 +++++------
llvm/tools/dsymutil/dsymutil.cpp | 3 ---
llvm/tools/llvm-ar/llvm-ar.cpp | 2 --
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp | 2 --
llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp | 2 --
llvm/tools/llvm-dwp/llvm-dwp.cpp | 3 ---
.../tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp | 2 --
llvm/tools/llvm-lipo/llvm-lipo.cpp | 2 --
llvm/tools/llvm-ml/llvm-ml.cpp | 2 --
llvm/tools/llvm-mt/llvm-mt.cpp | 3 ---
llvm/tools/llvm-nm/llvm-nm.cpp | 2 --
llvm/tools/llvm-objcopy/llvm-objcopy.cpp | 2 --
llvm/tools/llvm-objdump/llvm-objdump.cpp | 2 --
llvm/tools/llvm-profdata/llvm-profdata.cpp | 2 --
llvm/tools/llvm-rc/llvm-rc.cpp | 2 --
llvm/tools/llvm-readobj/llvm-readobj.cpp | 2 --
llvm/tools/llvm-size/llvm-size.cpp | 2 --
llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp | 2 --
llvm/tools/sancov/sancov.cpp | 3 ---
23 files changed, 5 insertions(+), 53 deletions(-)
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 75aa4ae97c618c..fb42dc1085afb3 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -20,7 +20,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Program.h"
@@ -699,7 +698,6 @@ static std::string getModuleCachePath(ArrayRef<std::string> Args) {
// form specified command line after the positional parameter "--".
static std::unique_ptr<tooling::CompilationDatabase>
getCompilationDataBase(int argc, char **argv, std::string &ErrorMessage) {
- llvm::InitLLVM X(argc, argv);
ParseArgs(argc, argv);
if (!CompilationDB.empty())
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 4adc7f7ad0dac3..a46d5169719bc9 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -36,7 +36,6 @@
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
@@ -377,7 +376,6 @@ static int ExecuteCC1Tool(SmallVectorImpl<const char *> &ArgV,
int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
noteBottomOfStack();
- llvm::InitLLVM X(Argc, Argv);
llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL
" and include the crash backtrace, preprocessed "
"source, and associated run script.\n");
diff --git a/lld/Common/DriverDispatcher.cpp b/lld/Common/DriverDispatcher.cpp
index 379a4c6ddabead..435acfd277654b 100644
--- a/lld/Common/DriverDispatcher.cpp
+++ b/lld/Common/DriverDispatcher.cpp
@@ -16,7 +16,6 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/CrashRecoveryContext.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/TargetParser/Host.h"
diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp
index a0a7cb0be8f133..d6800fa1eea4b9 100644
--- a/lld/tools/lld/lld.cpp
+++ b/lld/tools/lld/lld.cpp
@@ -33,7 +33,6 @@
#include "llvm/ADT/Twine.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/CrashRecoveryContext.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PluginLoader.h"
@@ -74,7 +73,6 @@ LLD_HAS_DRIVER(macho)
LLD_HAS_DRIVER(wasm)
int lld_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM x(argc, argv);
sys::Process::UseANSIEscapeCodes(true);
if (::getenv("FORCE_LLD_DIAGNOSTICS_CRASH")) {
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index 2a2e6c254c795a..b7e463a19122db 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -36,12 +36,13 @@ void CleanupStdHandles(void *Cookie) {
using namespace llvm;
using namespace llvm::sys;
-static std::atomic<unsigned> UsageCount{0};
-
InitLLVM::InitLLVM(int &Argc, const char **&Argv,
bool InstallPipeSignalExitHandler) {
- if (UsageCount++)
- return;
+#ifndef NDEBUG
+ static std::atomic<bool> Initialized{false};
+ assert(!Initialized && "InitLLVM was already initialized!");
+ Initialized = true;
+#endif
#ifdef __MVS__
// Bring stdin/stdout/stderr into a known state.
sys::AddSignalHandler(CleanupStdHandles, nullptr);
@@ -98,8 +99,6 @@ InitLLVM::InitLLVM(int &Argc, const char **&Argv,
}
InitLLVM::~InitLLVM() {
- if (--UsageCount)
- return;
#ifdef __MVS__
CleanupStdHandles(nullptr);
#endif
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index 2dd123318e00bd..094727cb44e61c 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -37,7 +37,6 @@
#include "llvm/Support/FileCollector.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetSelect.h"
@@ -607,8 +606,6 @@ getOutputFileName(StringRef InputFile, const DsymutilOptions &Options) {
}
int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
-
// Parse arguments.
DsymutilOptTable T;
unsigned MAI;
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index fcb6392a1d9555..6f819cbfd525c6 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -25,7 +25,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -1501,7 +1500,6 @@ static int ranlib_main(int argc, char **argv) {
}
int llvm_ar_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
ToolName = argv[0];
llvm::InitializeAllTargetInfos();
diff --git a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
index 4b9d88a650666e..97f28ab84dc318 100644
--- a/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
+++ b/llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
@@ -13,7 +13,6 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
@@ -144,7 +143,6 @@ static void demangleLine(llvm::raw_ostream &OS, StringRef Mangled, bool Split) {
}
int llvm_cxxfilt_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
BumpPtrAllocator A;
StringSaver Saver(A);
CxxfiltOptTable Tbl;
diff --git a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
index b9e2c6747187e2..9d347dbd68f395 100644
--- a/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
+++ b/llvm/tools/llvm-debuginfod/llvm-debuginfod.cpp
@@ -22,7 +22,6 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/ThreadPool.h"
@@ -121,7 +120,6 @@ static void parseArgs(int argc, char **argv) {
}
int llvm_debuginfod_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
HTTPClient::initialize();
parseArgs(argc, argv);
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index a6b8643a590382..81556b3ad4bcbd 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -27,7 +27,6 @@
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/TargetSelect.h"
@@ -120,8 +119,6 @@ static Expected<Triple> readTargetTriple(StringRef FileName) {
}
int llvm_dwp_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
-
DwpOptTable Tbl;
llvm::BumpPtrAllocator A;
llvm::StringSaver Saver{A};
diff --git a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
index 45e04d8f9dd044..77ae9b41d88854 100644
--- a/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
+++ b/llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
@@ -23,7 +23,6 @@
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/TargetSelect.h"
@@ -727,7 +726,6 @@ static Expected<Config> parseCommandLine(int Argc, char **Argv) {
}
int llvm_libtool_darwin_main(int Argc, char **Argv, const llvm::ToolContext &) {
- InitLLVM X(Argc, Argv);
Expected<Config> ConfigOrErr = parseCommandLine(Argc, Argv);
if (!ConfigOrErr) {
WithColor::defaultErrorHandler(ConfigOrErr.takeError());
diff --git a/llvm/tools/llvm-lipo/llvm-lipo.cpp b/llvm/tools/llvm-lipo/llvm-lipo.cpp
index 7e3275773b8add..083a922af0c4c6 100644
--- a/llvm/tools/llvm-lipo/llvm-lipo.cpp
+++ b/llvm/tools/llvm-lipo/llvm-lipo.cpp
@@ -26,7 +26,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileOutputBuffer.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/WithColor.h"
@@ -724,7 +723,6 @@ replaceSlices(LLVMContext &LLVMCtx,
}
int llvm_lipo_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index 1c713304e4ea17..1cac576f54e77f 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -34,7 +34,6 @@
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
@@ -187,7 +186,6 @@ static int AssembleInput(StringRef ProgName, const Target *TheTarget,
}
int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) {
- InitLLVM X(Argc, Argv);
StringRef ProgName = sys::path::filename(Argv[0]);
// Initialize targets and assembly printers/parsers.
diff --git a/llvm/tools/llvm-mt/llvm-mt.cpp b/llvm/tools/llvm-mt/llvm-mt.cpp
index 246e092898b3bd..158088dc77d851 100644
--- a/llvm/tools/llvm-mt/llvm-mt.cpp
+++ b/llvm/tools/llvm-mt/llvm-mt.cpp
@@ -16,7 +16,6 @@
#include "llvm/Option/Option.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileOutputBuffer.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
@@ -77,8 +76,6 @@ static void error(Error EC) {
}
int llvm_mt_main(int Argc, char **Argv, const llvm::ToolContext &) {
- InitLLVM X(Argc, Argv);
-
CvtResOptTable T;
unsigned MAI, MAC;
ArrayRef<const char *> ArgsArr = ArrayRef(Argv + 1, Argc - 1);
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index 19ee5374979c87..da5998b70ea3f3 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -42,7 +42,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Program.h"
@@ -2405,7 +2404,6 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
}
int llvm_nm_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
BumpPtrAllocator A;
StringSaver Saver(A);
NmOptTable Tbl;
diff --git a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
index 558359eca3cd72..730f423daa12f2 100644
--- a/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ b/llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -42,7 +42,6 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Path.h"
@@ -224,7 +223,6 @@ static Error executeObjcopy(ConfigManager &ConfigMgr) {
}
int llvm_objcopy_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
ToolName = argv[0];
// Expand response files.
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 7467a6062b5a8b..8944965ccf80ad 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -71,7 +71,6 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/GraphWriter.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
@@ -3417,7 +3416,6 @@ static void parseObjdumpOptions(const llvm::opt::InputArgList &InputArgs) {
int llvm_objdump_main(int argc, char **argv, const llvm::ToolContext &) {
using namespace llvm;
- InitLLVM X(argc, argv);
ToolName = argv[0];
std::unique_ptr<CommonOptTable> T;
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 12b81d411cfa91..9c98a6c89f1676 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -30,7 +30,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -3171,7 +3170,6 @@ static int order_main(int argc, const char *argv[]) {
int llvm_profdata_main(int argc, char **argvNonConst,
const llvm::ToolContext &) {
const char **argv = const_cast<const char **>(argvNonConst);
- InitLLVM X(argc, argv);
StringRef ProgName(sys::path::filename(argv[0]));
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 78ab96492acc75..ec366766364984 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -26,7 +26,6 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
@@ -731,7 +730,6 @@ void doCvtres(std::string Src, std::string Dest, std::string TargetTriple) {
} // anonymous namespace
int llvm_rc_main(int Argc, char **Argv, const llvm::ToolContext &) {
- InitLLVM X(Argc, Argv);
ExitOnErr.setBanner("llvm-rc: ");
char **DashDash = std::find_if(Argv + 1, Argv + Argc,
diff --git a/llvm/tools/llvm-readobj/llvm-readobj.cpp b/llvm/tools/llvm-readobj/llvm-readobj.cpp
index ca633ceff90800..f9d605d35244bf 100644
--- a/llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ b/llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -42,7 +42,6 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/ScopedPrinter.h"
@@ -633,7 +632,6 @@ std::unique_ptr<ScopedPrinter> createWriter() {
}
int llvm_readobj_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
BumpPtrAllocator A;
StringSaver Saver(A);
ReadobjOptTable Tbl;
diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp
index c0d1a1b104b891..78b207eeeb1212 100644
--- a/llvm/tools/llvm-size/llvm-size.cpp
+++ b/llvm/tools/llvm-size/llvm-size.cpp
@@ -25,7 +25,6 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/WithColor.h"
@@ -863,7 +862,6 @@ static void printBerkeleyTotals() {
}
int llvm_size_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
BumpPtrAllocator A;
StringSaver Saver(A);
SizeOptTable Tbl;
diff --git a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
index 74cc2da4e1ca23..b98bdbc388faf2 100644
--- a/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -34,7 +34,6 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/StringSaver.h"
@@ -462,7 +461,6 @@ static void filterMarkup(const opt::InputArgList &Args, LLVMSymbolizer &Symboliz
}
int llvm_symbolizer_main(int argc, char **argv, const llvm::ToolContext &) {
- InitLLVM X(argc, argv);
sys::InitializeCOMRAII COM(sys::COMThreadingMode::MultiThreaded);
ToolName = argv[0];
diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp
index d30bdf3e5c60d2..e5b0875d46a11f 100644
--- a/llvm/tools/sancov/sancov.cpp
+++ b/llvm/tools/sancov/sancov.cpp
@@ -36,7 +36,6 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/InitLLVM.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/LLVMDriver.h"
#include "llvm/Support/MD5.h"
@@ -1215,8 +1214,6 @@ static void parseArgs(int Argc, char **Argv) {
}
int sancov_main(int Argc, char **Argv, const llvm::ToolContext &) {
- llvm::InitLLVM X(Argc, Argv);
-
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
More information about the cfe-commits
mailing list