Merge remote-tracking branch 'origin/master' into master-next

This commit is contained in:
swift-ci
2018-02-28 20:12:23 -08:00
17 changed files with 48 additions and 36 deletions

View File

@@ -10,34 +10,33 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// A file that declares a macro for initializing all parts of LLVM that various // A file that declares macros for initializing all parts of LLVM that various
// binaries in swift use. Please call the macro in the main routine of all // binaries in swift use. Please call PROGRAM_START in the main routine of all
// binaries. // binaries, and INITIALIZE_LLVM in anything that uses Clang or LLVM IR.
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef SWIFT_BASIC_LLVMINITIALIZE_H #ifndef SWIFT_BASIC_LLVMINITIALIZE_H
#define SWIFT_BASIC_LLVMINITIALIZE_H #define SWIFT_BASIC_LLVMINITIALIZE_H
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h" #include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#define INITIALIZE_LLVM(argc, argv) \ #define PROGRAM_START(argc, argv) \
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); \ llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); \
llvm::PrettyStackTraceProgram _INITIALIZE_LLVM_STACKTRACE(argc, argv); \ llvm::PrettyStackTraceProgram _INITIALIZE_LLVM_STACKTRACE(argc, argv); \
llvm::llvm_shutdown_obj _INITIALIZE_LLVM_SHUTDOWN_OBJ; \ llvm::llvm_shutdown_obj _INITIALIZE_LLVM_SHUTDOWN_OBJ
llvm::InitializeAllTargets(); \
llvm::InitializeAllTargetMCs(); \ #define INITIALIZE_LLVM() \
llvm::InitializeAllAsmPrinters(); \ do { \
llvm::InitializeAllAsmParsers(); \ llvm::InitializeAllTargets(); \
llvm::InitializeAllDisassemblers(); \ llvm::InitializeAllTargetMCs(); \
llvm::InitializeAllTargetInfos(); llvm::InitializeAllAsmPrinters(); \
llvm::InitializeAllAsmParsers(); \
llvm::InitializeAllDisassemblers(); \
llvm::InitializeAllTargetInfos(); \
} while (0)
#endif // SWIFT_BASIC_LLVMINITIALIZE_H #endif // SWIFT_BASIC_LLVMINITIALIZE_H

View File

@@ -40,6 +40,7 @@
#include "swift/Basic/FileSystem.h" #include "swift/Basic/FileSystem.h"
#include "swift/Basic/JSONSerialization.h" #include "swift/Basic/JSONSerialization.h"
#include "swift/Basic/LLVMContext.h" #include "swift/Basic/LLVMContext.h"
#include "swift/Basic/LLVMInitialize.h"
#include "swift/Basic/SourceManager.h" #include "swift/Basic/SourceManager.h"
#include "swift/Basic/Statistic.h" #include "swift/Basic/Statistic.h"
#include "swift/Basic/Timer.h" #include "swift/Basic/Timer.h"
@@ -1511,10 +1512,7 @@ computeStatsReporter(const CompilerInvocation &Invocation, CompilerInstance *Ins
int swift::performFrontend(ArrayRef<const char *> Args, int swift::performFrontend(ArrayRef<const char *> Args,
const char *Argv0, void *MainAddr, const char *Argv0, void *MainAddr,
FrontendObserver *observer) { FrontendObserver *observer) {
llvm::InitializeAllTargets(); INITIALIZE_LLVM();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllAsmParsers();
PrintingDiagnosticConsumer PDC; PrintingDiagnosticConsumer PDC;

View File

@@ -110,7 +110,7 @@ static bool shouldRunAsSubcommand(StringRef ExecName,
extern int apinotes_main(ArrayRef<const char *> Args); extern int apinotes_main(ArrayRef<const char *> Args);
int main(int argc_, const char **argv_) { int main(int argc_, const char **argv_) {
INITIALIZE_LLVM(argc_, argv_); PROGRAM_START(argc_, argv_);
SmallVector<const char *, 256> argv; SmallVector<const char *, 256> argv;
llvm::SpecificBumpPtrAllocator<char> ArgAllocator; llvm::SpecificBumpPtrAllocator<char> ArgAllocator;

View File

@@ -18,6 +18,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "swift/AST/DiagnosticsFrontend.h" #include "swift/AST/DiagnosticsFrontend.h"
#include "swift/Basic/LLVMInitialize.h"
#include "swift/Frontend/Frontend.h" #include "swift/Frontend/Frontend.h"
#include "swift/Frontend/PrintingDiagnosticConsumer.h" #include "swift/Frontend/PrintingDiagnosticConsumer.h"
#include "swift/Option/Options.h" #include "swift/Option/Options.h"
@@ -113,10 +114,7 @@ public:
int modulewrap_main(ArrayRef<const char *> Args, const char *Argv0, int modulewrap_main(ArrayRef<const char *> Args, const char *Argv0,
void *MainAddr) { void *MainAddr) {
llvm::InitializeAllTargets(); INITIALIZE_LLVM();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllAsmParsers();
CompilerInstance Instance; CompilerInstance Instance;
PrintingDiagnosticConsumer PDC; PrintingDiagnosticConsumer PDC;

View File

@@ -62,7 +62,8 @@ static void printValidationInfo(llvm::StringRef data) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
// Command line handling. // Command line handling.
llvm::cl::list<std::string> InputNames( llvm::cl::list<std::string> InputNames(

View File

@@ -225,7 +225,8 @@ void removeUnwantedFunctions(SILModule *M, ArrayRef<std::string> MangledNames,
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SIL Extractor\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SIL Extractor\n");

View File

@@ -113,7 +113,8 @@ static llvm::cl::opt<IRGenOutputKind>
void anchorForGetMainExecutable() {} void anchorForGetMainExecutable() {}
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift LLVM IR Generator\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift LLVM IR Generator\n");

View File

@@ -139,7 +139,8 @@ static void nmModule(SILModule *M) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, "SIL NM\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "SIL NM\n");

View File

@@ -264,7 +264,8 @@ static void runCommandLineSelectedPasses(SILModule *Module,
void anchorForGetMainExecutable() {} void anchorForGetMainExecutable() {}
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SIL optimizer\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SIL optimizer\n");

View File

@@ -44,7 +44,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &os, PassPipelineKind Kind) {
} // namespace llvm } // namespace llvm
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, llvm::cl::ParseCommandLineOptions(argc, argv,
"Swift SIL Pass Pipeline Dumper\n"); "Swift SIL Pass Pipeline Dumper\n");

View File

@@ -3610,7 +3610,8 @@ static int deserializeSDKDump(StringRef dumpPath, StringRef OutputPath) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SDK Digester\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SDK Digester\n");
CompilerInvocation InitInvok; CompilerInvocation InitInvok;

View File

@@ -2928,7 +2928,8 @@ static int doTestCompilerInvocationFromModule(StringRef ModuleFilePath) {
void anchorForGetMainExecutable() {} void anchorForGetMainExecutable() {}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
if (argc > 1) { if (argc > 1) {
// Handle integrated test tools which do not use // Handle integrated test tools which do not use

View File

@@ -212,7 +212,8 @@ static void runSpecificPasses(StringRef Binary, llvm::Module *M,
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
int main(int argc, char **argv) { int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
// Initialize passes // Initialize passes
PassRegistry &Registry = *PassRegistry::getPassRegistry(); PassRegistry &Registry = *PassRegistry::getPassRegistry();

View File

@@ -10,12 +10,13 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Support/CommandLine.h"
#include "swift/Basic/LLVMInitialize.h" #include "swift/Basic/LLVMInitialize.h"
#include "swift/Frontend/Frontend.h" #include "swift/Frontend/Frontend.h"
#include "swift/Frontend/PrintingDiagnosticConsumer.h" #include "swift/Frontend/PrintingDiagnosticConsumer.h"
#include "swift/IDE/Refactoring.h" #include "swift/IDE/Refactoring.h"
#include "swift/IDE/Utils.h" #include "swift/IDE/Utils.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include <regex> #include <regex>
@@ -218,7 +219,8 @@ RangeConfig getRange(unsigned BufferID, SourceManager &SM,
void anchorForGetMainExecutable() {} void anchorForGetMainExecutable() {}
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
INITIALIZE_LLVM(argc, argv); PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift refactor\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift refactor\n");
if (options::SourceFilename.empty()) { if (options::SourceFilename.empty()) {
llvm::errs() << "cannot find source filename\n"; llvm::errs() << "cannot find source filename\n";

View File

@@ -293,6 +293,7 @@ static int doDumpReflectionSections(ArrayRef<std::string> binaryFilenames,
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
PROGRAM_START(argc, argv);
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift Reflection Dump\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift Reflection Dump\n");
return doDumpReflectionSections(options::BinaryFilename, return doDumpReflectionSections(options::BinaryFilename,
options::Architecture, options::Architecture,

View File

@@ -19,6 +19,7 @@
#include "swift/Frontend/Frontend.h" #include "swift/Frontend/Frontend.h"
#include "swift/FrontendTool/FrontendTool.h" #include "swift/FrontendTool/FrontendTool.h"
#include "swift/Basic/LLVM.h" #include "swift/Basic/LLVM.h"
#include "swift/Basic/LLVMInitialize.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <cassert> #include <cassert>
@@ -143,6 +144,8 @@ struct Observer : public FrontendObserver {
} // end anonymous namespace } // end anonymous namespace
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
PROGRAM_START(argc, argv);
unsigned numForwardedArgs = argc unsigned numForwardedArgs = argc
- 1 // we drop argv[0] - 1 // we drop argv[0]
+ 1; // -interpret + 1; // -interpret

View File

@@ -21,6 +21,7 @@
#include "swift/AST/DiagnosticEngine.h" #include "swift/AST/DiagnosticEngine.h"
#include "swift/AST/DiagnosticsFrontend.h" #include "swift/AST/DiagnosticsFrontend.h"
#include "swift/Basic/LangOptions.h" #include "swift/Basic/LangOptions.h"
#include "swift/Basic/LLVMInitialize.h"
#include "swift/Basic/SourceManager.h" #include "swift/Basic/SourceManager.h"
#include "swift/Frontend/Frontend.h" #include "swift/Frontend/Frontend.h"
#include "swift/Frontend/PrintingDiagnosticConsumer.h" #include "swift/Frontend/PrintingDiagnosticConsumer.h"
@@ -281,6 +282,7 @@ int dumpEOFSourceLoc(const char *MainExecutablePath,
}// end of anonymous namespace }// end of anonymous namespace
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
PROGRAM_START(argc, argv);
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift Syntax Test\n"); llvm::cl::ParseCommandLineOptions(argc, argv, "Swift Syntax Test\n");
int ExitCode = EXIT_SUCCESS; int ExitCode = EXIT_SUCCESS;