From 937eb076101a14460c5ff08c3265aded6574a925 Mon Sep 17 00:00:00 2001 From: Anirudh Prasad Date: Tue, 28 Jul 2020 06:40:47 -0400 Subject: [PATCH] [Support] Use InitLLVM in llvm-stress, sancov and TableGen This patch refactors the llvm tools namely, llvm-stress and sancov, as well as the llvm TableGen utility, to use the new InitLLVM interface which encapsulates PrettyStackTrace. This is from https://reviews.llvm.org/D70702, but only for LLVM. Reviewed-by: Kai Differential Revision: https://reviews.llvm.org/D83484 --- tools/llvm-stress/llvm-stress.cpp | 7 ++----- tools/sancov/sancov.cpp | 9 ++------- utils/TableGen/TableGen.cpp | 9 ++------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/tools/llvm-stress/llvm-stress.cpp b/tools/llvm-stress/llvm-stress.cpp index 22f530dde16..77cc5983912 100644 --- a/tools/llvm-stress/llvm-stress.cpp +++ b/tools/llvm-stress/llvm-stress.cpp @@ -38,8 +38,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/InitLLVM.h" #include "llvm/Support/ToolOutputFile.h" #include "llvm/Support/raw_ostream.h" #include @@ -733,10 +732,8 @@ static void IntroduceControlFlow(Function *F, Random &R) { int main(int argc, char **argv) { using namespace llvm; - // Init LLVM, call llvm_shutdown() on exit, parse args, etc. - PrettyStackTraceProgram X(argc, argv); + InitLLVM X(argc, argv); cl::ParseCommandLineOptions(argc, argv, "llvm codegen stress-tester\n"); - llvm_shutdown_obj Y; auto M = std::make_unique("/tmp/autogen.bc", Context); Function *F = GenEmptyFunction(M.get()); diff --git a/tools/sancov/sancov.cpp b/tools/sancov/sancov.cpp index 37d06e38547..f1d756f216d 100644 --- a/tools/sancov/sancov.cpp +++ b/tools/sancov/sancov.cpp @@ -32,15 +32,13 @@ #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/MD5.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" -#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Regex.h" #include "llvm/Support/SHA1.h" -#include "llvm/Support/Signals.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/SpecialCaseList.h" #include "llvm/Support/TargetRegistry.h" @@ -1134,10 +1132,7 @@ readSymbolizeAndMergeCmdArguments(std::vector FileNames) { } // namespace int main(int Argc, char **Argv) { - // Print stack trace if we signal out. - sys::PrintStackTraceOnErrorSignal(Argv[0]); - PrettyStackTraceProgram X(Argc, Argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. + llvm::InitLLVM X(Argc, Argv); llvm::InitializeAllTargetInfos(); llvm::InitializeAllTargetMCs(); diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index 8015a58471c..5215c30b707 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -12,9 +12,7 @@ #include "TableGenBackends.h" // Declares all backends. #include "llvm/Support/CommandLine.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" +#include "llvm/Support/InitLLVM.h" #include "llvm/TableGen/Main.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/SetTheory.h" @@ -278,12 +276,9 @@ bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) { } int main(int argc, char **argv) { - sys::PrintStackTraceOnErrorSignal(argv[0]); - PrettyStackTraceProgram X(argc, argv); + InitLLVM X(argc, argv); cl::ParseCommandLineOptions(argc, argv); - llvm_shutdown_obj Y; - return TableGenMain(argv[0], &LLVMTableGenMain); }