Rename disable-llvm-arc-opts => disable-swift-specific-llvm-optzns and make sure that we actually disable /all/ LLVM passes.

For instance, we were always running merge functions unconditionally if -O was
passed.

rdar://40097698
This commit is contained in:
Michael Gottesman
2018-05-15 16:14:47 -07:00
parent 233d29a2ac
commit aa035e9563
6 changed files with 21 additions and 15 deletions

View File

@@ -106,8 +106,8 @@ public:
/// \brief Whether we should run LLVM optimizations after IRGen. /// \brief Whether we should run LLVM optimizations after IRGen.
unsigned DisableLLVMOptzns : 1; unsigned DisableLLVMOptzns : 1;
/// \brief Whether we should run LLVM ARC optimizations after IRGen. /// Whether we should run swift specific LLVM optimizations after IRGen.
unsigned DisableLLVMARCOpts : 1; unsigned DisableSwiftSpecificLLVMOptzns : 1;
/// \brief Whether we should run LLVM SLP vectorizer. /// \brief Whether we should run LLVM SLP vectorizer.
unsigned DisableLLVMSLPVectorizer : 1; unsigned DisableLLVMSLPVectorizer : 1;
@@ -182,7 +182,7 @@ public:
Verify(true), OptMode(OptimizationMode::NotSet), Verify(true), OptMode(OptimizationMode::NotSet),
Sanitizers(OptionSet<SanitizerKind>()), Sanitizers(OptionSet<SanitizerKind>()),
DebugInfoKind(IRGenDebugInfoKind::None), UseJIT(false), DebugInfoKind(IRGenDebugInfoKind::None), UseJIT(false),
DisableLLVMOptzns(false), DisableLLVMARCOpts(false), DisableLLVMOptzns(false), DisableSwiftSpecificLLVMOptzns(false),
DisableLLVMSLPVectorizer(false), DisableFPElim(true), Playground(false), DisableLLVMSLPVectorizer(false), DisableFPElim(true), Playground(false),
EmitStackPromotionChecks(false), PrintInlineTree(false), EmitStackPromotionChecks(false), PrintInlineTree(false),
EmbedMode(IRGenEmbedMode::None), HasValueNamesSetting(false), EmbedMode(IRGenEmbedMode::None), HasValueNamesSetting(false),
@@ -197,7 +197,7 @@ public:
unsigned getLLVMCodeGenOptionsHash() { unsigned getLLVMCodeGenOptionsHash() {
unsigned Hash = (unsigned)OptMode; unsigned Hash = (unsigned)OptMode;
Hash = (Hash << 1) | DisableLLVMOptzns; Hash = (Hash << 1) | DisableLLVMOptzns;
Hash = (Hash << 1) | DisableLLVMARCOpts; Hash = (Hash << 1) | DisableSwiftSpecificLLVMOptzns;
return Hash; return Hash;
} }

View File

@@ -217,8 +217,8 @@ def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
def disable_sil_perf_optzns : Flag<["-"], "disable-sil-perf-optzns">, def disable_sil_perf_optzns : Flag<["-"], "disable-sil-perf-optzns">,
HelpText<"Don't run SIL performance optimization passes">; HelpText<"Don't run SIL performance optimization passes">;
def disable_llvm_arc_opts : Flag<["-"], "disable-llvm-arc-opts">, def disable_swift_specific_llvm_optzns : Flag<["-"], "disable-swift-specific-llvm-optzns">,
HelpText<"Don't run LLVM ARC optimization passes.">; HelpText<"Don't run Swift specific LLVM optimization passes.">;
def disable_llvm_slp_vectorizer : Flag<["-"], "disable-llvm-slp-vectorizer">, def disable_llvm_slp_vectorizer : Flag<["-"], "disable-llvm-slp-vectorizer">,
HelpText<"Don't run LLVM SLP vectorizer">; HelpText<"Don't run LLVM SLP vectorizer">;

View File

@@ -812,7 +812,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
} }
Opts.DisableLLVMOptzns |= Args.hasArg(OPT_disable_llvm_optzns); Opts.DisableLLVMOptzns |= Args.hasArg(OPT_disable_llvm_optzns);
Opts.DisableLLVMARCOpts |= Args.hasArg(OPT_disable_llvm_arc_opts); Opts.DisableSwiftSpecificLLVMOptzns |=
Args.hasArg(OPT_disable_swift_specific_llvm_optzns);
Opts.DisableLLVMSLPVectorizer |= Args.hasArg(OPT_disable_llvm_slp_vectorizer); Opts.DisableLLVMSLPVectorizer |= Args.hasArg(OPT_disable_llvm_slp_vectorizer);
if (Args.hasArg(OPT_disable_llvm_verify)) if (Args.hasArg(OPT_disable_llvm_verify))
Opts.Verify = false; Opts.Verify = false;

View File

@@ -1306,7 +1306,8 @@ llvm::Constant *IRGenModule::getFixLifetimeFn() {
/// optimizer not to touch this value. /// optimizer not to touch this value.
void IRGenFunction::emitFixLifetime(llvm::Value *value) { void IRGenFunction::emitFixLifetime(llvm::Value *value) {
// If we aren't running the LLVM ARC optimizer, we don't need to emit this. // If we aren't running the LLVM ARC optimizer, we don't need to emit this.
if (!IGM.IRGen.Opts.shouldOptimize() || IGM.IRGen.Opts.DisableLLVMARCOpts) if (!IGM.IRGen.Opts.shouldOptimize() ||
IGM.IRGen.Opts.DisableSwiftSpecificLLVMOptzns)
return; return;
if (doesNotRequireRefCounting(value)) return; if (doesNotRequireRefCounting(value)) return;
emitUnaryRefCountCall(*this, IGM.getFixLifetimeFn(), value); emitUnaryRefCountCall(*this, IGM.getFixLifetimeFn(), value);

View File

@@ -176,9 +176,12 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
llvm::createAlwaysInlinerLegacyPass(/*insertlifetime*/false); llvm::createAlwaysInlinerLegacyPass(/*insertlifetime*/false);
} }
bool RunSwiftSpecificLLVMOptzns =
!Opts.DisableSwiftSpecificLLVMOptzns && !Opts.DisableLLVMOptzns;
// If the optimizer is enabled, we run the ARCOpt pass in the scalar optimizer // If the optimizer is enabled, we run the ARCOpt pass in the scalar optimizer
// and the Contract pass as late as possible. // and the Contract pass as late as possible.
if (!Opts.DisableLLVMARCOpts && !Opts.DisableLLVMOptzns) { if (RunSwiftSpecificLLVMOptzns) {
PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate, PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
addSwiftARCOptPass); addSwiftARCOptPass);
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
@@ -208,11 +211,12 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
addSanitizerCoveragePass); addSanitizerCoveragePass);
} }
if (!Opts.DisableLLVMOptzns) if (RunSwiftSpecificLLVMOptzns)
addCoroutinePassesToExtensionPoints(PMBuilder); addCoroutinePassesToExtensionPoints(PMBuilder);
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast, if (RunSwiftSpecificLLVMOptzns)
addSwiftMergeFunctionsPass); PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
addSwiftMergeFunctionsPass);
// Configure the function passes. // Configure the function passes.
legacy::FunctionPassManager FunctionPasses(Module); legacy::FunctionPassManager FunctionPasses(Module);
@@ -224,7 +228,7 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
// The PMBuilder only knows about LLVM AA passes. We should explicitly add // The PMBuilder only knows about LLVM AA passes. We should explicitly add
// the swift AA pass after the other ones. // the swift AA pass after the other ones.
if (!Opts.DisableLLVMARCOpts && !Opts.DisableLLVMOptzns) { if (RunSwiftSpecificLLVMOptzns) {
FunctionPasses.add(createSwiftAAWrapperPass()); FunctionPasses.add(createSwiftAAWrapperPass());
FunctionPasses.add(createExternalAAWrapperPass([](Pass &P, Function &, FunctionPasses.add(createExternalAAWrapperPass([](Pass &P, Function &,
AAResults &AAR) { AAResults &AAR) {
@@ -253,7 +257,7 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
// The PMBuilder only knows about LLVM AA passes. We should explicitly add // The PMBuilder only knows about LLVM AA passes. We should explicitly add
// the swift AA pass after the other ones. // the swift AA pass after the other ones.
if (!Opts.DisableLLVMARCOpts && !Opts.DisableLLVMOptzns) { if (RunSwiftSpecificLLVMOptzns) {
ModulePasses.add(createSwiftAAWrapperPass()); ModulePasses.add(createSwiftAAWrapperPass());
ModulePasses.add(createExternalAAWrapperPass([](Pass &P, Function &, ModulePasses.add(createExternalAAWrapperPass([](Pass &P, Function &,
AAResults &AAR) { AAResults &AAR) {

View File

@@ -20,7 +20,7 @@ _swift_complete()
# Don't know how to get the help for llvm options automatically. # Don't know how to get the help for llvm options automatically.
# So we use a grep'ed static list. # So we use a grep'ed static list.
COMPREPLY=( $(compgen -W "\ COMPREPLY=( $(compgen -W "\
-disable-llvm-arc-opts \ -disable-swift-specific-llvm-optzns \
-stack-promotion-limit \ -stack-promotion-limit \
-view-cfg-max-columns \ -view-cfg-max-columns \
-view-cfg-long-line-behavior \ -view-cfg-long-line-behavior \