mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Remarks] Add a specialized RemarkStreamer for SIL remarks
This allows the usage of the whole remark infrastructure developed in LLVM, which includes a new binary format, metadata in object files, etc. This gets rid of the YAMLTraits-based remark serialization and does the plumbing for hooking to LLVM's main remark streamer. For more about the idea behind LLVM's main remark streamer, see the docs/Remarks.rst changes in https://reviews.llvm.org/D73676. The flags are now: * -save-optimization-record: enable remarks, defaults to YAML * -save-optimization-record=<format>: enable remarks, use <format> for serialization * -save-optimization-record-passes <regex>: only serialize passes that match <regex>. The YAMLTraits in swift had a different `flow` setting for the debug location, resulting in some test changes.
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "llvm/Option/Arg.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Option/OptTable.h"
|
||||
#include "llvm/Remarks/RemarkFormat.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
@@ -1941,7 +1942,8 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
|
||||
case file_types::TY_ImportedModules:
|
||||
case file_types::TY_TBD:
|
||||
case file_types::TY_ModuleTrace:
|
||||
case file_types::TY_OptRecord:
|
||||
case file_types::TY_YAMLOptRecord:
|
||||
case file_types::TY_BitstreamOptRecord:
|
||||
case file_types::TY_SwiftModuleInterfaceFile:
|
||||
case file_types::TY_PrivateSwiftModuleInterfaceFile:
|
||||
case file_types::TY_SwiftCrossImportDir:
|
||||
@@ -2766,6 +2768,7 @@ Job *Driver::buildJobsForAction(Compilation &C, const JobAction *JA,
|
||||
Output.get());
|
||||
|
||||
if (C.getArgs().hasArg(options::OPT_save_optimization_record,
|
||||
options::OPT_save_optimization_record_EQ,
|
||||
options::OPT_save_optimization_record_path))
|
||||
chooseOptimizationRecordPath(C, workingDirectory, Buf, Output.get());
|
||||
|
||||
@@ -3202,12 +3205,18 @@ void Driver::chooseOptimizationRecordPath(Compilation &C,
|
||||
CommandOutput *Output) const {
|
||||
const OutputInfo &OI = C.getOutputInfo();
|
||||
if (OI.CompilerMode == OutputInfo::Mode::SingleCompile) {
|
||||
llvm::Expected<file_types::ID> FileType =
|
||||
C.getToolChain().remarkFileTypeFromArgs(C.getArgs());
|
||||
if (!FileType) {
|
||||
Diags.diagnose({}, diag::error_creating_remark_serializer,
|
||||
llvm::toString(FileType.takeError()));
|
||||
return;
|
||||
}
|
||||
auto filename = *getOutputFilenameFromPathArgOrAsTopLevel(
|
||||
OI, C.getArgs(), options::OPT_save_optimization_record_path,
|
||||
file_types::TY_OptRecord, /*TreatAsTopLevelOutput=*/true,
|
||||
workingDirectory, Buf);
|
||||
OI, C.getArgs(), options::OPT_save_optimization_record_path, *FileType,
|
||||
/*TreatAsTopLevelOutput=*/true, workingDirectory, Buf);
|
||||
|
||||
Output->setAdditionalOutputForType(file_types::TY_OptRecord, filename);
|
||||
Output->setAdditionalOutputForType(*FileType, filename);
|
||||
} else
|
||||
// FIXME: We should use the OutputMap in this case.
|
||||
Diags.diagnose({}, diag::warn_opt_remark_disabled);
|
||||
|
||||
Reference in New Issue
Block a user