[NFC] Grab the private discriminator for a file in IRGenDebugInfo

This was being done at an odd point in the frontend presumably because by that point the private discriminator had been fully computed.  Instead, push the conditions for generating the prefix data down to debug info generation and stop mutating IRGenOptions::DebugFlag in the frontend.
This commit is contained in:
Robert Widmann
2020-01-10 11:17:05 -08:00
parent fad29a306c
commit eb61931012
10 changed files with 52 additions and 40 deletions

View File

@@ -1371,21 +1371,6 @@ static bool performCompile(CompilerInstance &Instance,
ReturnValue, observer, Stats);
}
/// Get the main source file's private discriminator and attach it to
/// the compile unit's flags.
static void setPrivateDiscriminatorIfNeeded(IRGenOptions &IRGenOpts,
ModuleOrSourceFile MSF) {
if (IRGenOpts.DebugInfoLevel == IRGenDebugInfoLevel::None ||
!MSF.is<SourceFile *>())
return;
Identifier PD = MSF.get<SourceFile *>()->getPrivateDiscriminator();
if (!PD.empty()) {
if (!IRGenOpts.DebugFlags.empty())
IRGenOpts.DebugFlags += " ";
IRGenOpts.DebugFlags += ("-private-discriminator " + PD.str()).str();
}
}
static bool serializeSIB(SILModule *SM, const PrimarySpecificPaths &PSPs,
ASTContext &Context, ModuleOrSourceFile MSF) {
const std::string &moduleOutputPath =
@@ -1414,6 +1399,7 @@ static void generateIR(IRGenOptions &IRGenOpts, std::unique_ptr<SILModule> SM,
IRModule = MSF.is<SourceFile *>()
? performIRGeneration(IRGenOpts, *MSF.get<SourceFile *>(),
std::move(SM), OutputFilename, PSPs,
MSF.get<SourceFile *>()->getPrivateDiscriminator().str(),
LLVMContext, &HashGlobal,
&LinkerDirectives)
: performIRGeneration(IRGenOpts, MSF.get<ModuleDecl *>(),
@@ -1601,8 +1587,6 @@ static bool performCompileStepsPostSILGen(
emitAnyWholeModulePostTypeCheckSupplementaryOutputs(Instance, Invocation,
moduleIsPublic);
setPrivateDiscriminatorIfNeeded(IRGenOpts, MSF);
if (Action == FrontendOptions::ActionType::EmitSIB)
return serializeSIB(SM.get(), PSPs, Instance.getASTContext(), MSF);