mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -106,8 +106,8 @@ public:
|
||||
/// \brief Whether we should run LLVM optimizations after IRGen.
|
||||
unsigned DisableLLVMOptzns : 1;
|
||||
|
||||
/// \brief Whether we should run LLVM ARC optimizations after IRGen.
|
||||
unsigned DisableLLVMARCOpts : 1;
|
||||
/// Whether we should run swift specific LLVM optimizations after IRGen.
|
||||
unsigned DisableSwiftSpecificLLVMOptzns : 1;
|
||||
|
||||
/// \brief Whether we should run LLVM SLP vectorizer.
|
||||
unsigned DisableLLVMSLPVectorizer : 1;
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
Verify(true), OptMode(OptimizationMode::NotSet),
|
||||
Sanitizers(OptionSet<SanitizerKind>()),
|
||||
DebugInfoKind(IRGenDebugInfoKind::None), UseJIT(false),
|
||||
DisableLLVMOptzns(false), DisableLLVMARCOpts(false),
|
||||
DisableLLVMOptzns(false), DisableSwiftSpecificLLVMOptzns(false),
|
||||
DisableLLVMSLPVectorizer(false), DisableFPElim(true), Playground(false),
|
||||
EmitStackPromotionChecks(false), PrintInlineTree(false),
|
||||
EmbedMode(IRGenEmbedMode::None), HasValueNamesSetting(false),
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
unsigned getLLVMCodeGenOptionsHash() {
|
||||
unsigned Hash = (unsigned)OptMode;
|
||||
Hash = (Hash << 1) | DisableLLVMOptzns;
|
||||
Hash = (Hash << 1) | DisableLLVMARCOpts;
|
||||
Hash = (Hash << 1) | DisableSwiftSpecificLLVMOptzns;
|
||||
return Hash;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,8 +217,8 @@ def disable_llvm_optzns : Flag<["-"], "disable-llvm-optzns">,
|
||||
def disable_sil_perf_optzns : Flag<["-"], "disable-sil-perf-optzns">,
|
||||
HelpText<"Don't run SIL performance optimization passes">;
|
||||
|
||||
def disable_llvm_arc_opts : Flag<["-"], "disable-llvm-arc-opts">,
|
||||
HelpText<"Don't run LLVM ARC optimization passes.">;
|
||||
def disable_swift_specific_llvm_optzns : Flag<["-"], "disable-swift-specific-llvm-optzns">,
|
||||
HelpText<"Don't run Swift specific LLVM optimization passes.">;
|
||||
|
||||
def disable_llvm_slp_vectorizer : Flag<["-"], "disable-llvm-slp-vectorizer">,
|
||||
HelpText<"Don't run LLVM SLP vectorizer">;
|
||||
|
||||
@@ -812,7 +812,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
}
|
||||
|
||||
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);
|
||||
if (Args.hasArg(OPT_disable_llvm_verify))
|
||||
Opts.Verify = false;
|
||||
|
||||
@@ -1306,7 +1306,8 @@ llvm::Constant *IRGenModule::getFixLifetimeFn() {
|
||||
/// optimizer not to touch this value.
|
||||
void IRGenFunction::emitFixLifetime(llvm::Value *value) {
|
||||
// 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;
|
||||
if (doesNotRequireRefCounting(value)) return;
|
||||
emitUnaryRefCountCall(*this, IGM.getFixLifetimeFn(), value);
|
||||
|
||||
@@ -176,9 +176,12 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
|
||||
llvm::createAlwaysInlinerLegacyPass(/*insertlifetime*/false);
|
||||
}
|
||||
|
||||
bool RunSwiftSpecificLLVMOptzns =
|
||||
!Opts.DisableSwiftSpecificLLVMOptzns && !Opts.DisableLLVMOptzns;
|
||||
|
||||
// If the optimizer is enabled, we run the ARCOpt pass in the scalar optimizer
|
||||
// and the Contract pass as late as possible.
|
||||
if (!Opts.DisableLLVMARCOpts && !Opts.DisableLLVMOptzns) {
|
||||
if (RunSwiftSpecificLLVMOptzns) {
|
||||
PMBuilder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
|
||||
addSwiftARCOptPass);
|
||||
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
|
||||
@@ -208,9 +211,10 @@ void swift::performLLVMOptimizations(IRGenOptions &Opts, llvm::Module *Module,
|
||||
addSanitizerCoveragePass);
|
||||
}
|
||||
|
||||
if (!Opts.DisableLLVMOptzns)
|
||||
if (RunSwiftSpecificLLVMOptzns)
|
||||
addCoroutinePassesToExtensionPoints(PMBuilder);
|
||||
|
||||
if (RunSwiftSpecificLLVMOptzns)
|
||||
PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
|
||||
addSwiftMergeFunctionsPass);
|
||||
|
||||
@@ -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 swift AA pass after the other ones.
|
||||
if (!Opts.DisableLLVMARCOpts && !Opts.DisableLLVMOptzns) {
|
||||
if (RunSwiftSpecificLLVMOptzns) {
|
||||
FunctionPasses.add(createSwiftAAWrapperPass());
|
||||
FunctionPasses.add(createExternalAAWrapperPass([](Pass &P, Function &,
|
||||
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 swift AA pass after the other ones.
|
||||
if (!Opts.DisableLLVMARCOpts && !Opts.DisableLLVMOptzns) {
|
||||
if (RunSwiftSpecificLLVMOptzns) {
|
||||
ModulePasses.add(createSwiftAAWrapperPass());
|
||||
ModulePasses.add(createExternalAAWrapperPass([](Pass &P, Function &,
|
||||
AAResults &AAR) {
|
||||
|
||||
@@ -20,7 +20,7 @@ _swift_complete()
|
||||
# Don't know how to get the help for llvm options automatically.
|
||||
# So we use a grep'ed static list.
|
||||
COMPREPLY=( $(compgen -W "\
|
||||
-disable-llvm-arc-opts \
|
||||
-disable-swift-specific-llvm-optzns \
|
||||
-stack-promotion-limit \
|
||||
-view-cfg-max-columns \
|
||||
-view-cfg-long-line-behavior \
|
||||
|
||||
Reference in New Issue
Block a user