Skip to content

[Test] Run copy-propagation on SILOptimizer/opaque_values_mandatory.sil. #38179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions test/SILOptimizer/opaque_values_mandatory.sil
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// RUN: %target-sil-opt -diagnostics -enable-sil-opaque-values %s | \
// RUN: %target-sil-opt -Onone-performance -enable-sil-opaque-values -emit-sorted-sil -sil-disable-pass=mandatory-copy-propagation | \
// RUN: %target-sil-opt -Onone-performance -enable-sil-verify-all \
// RUN: -enable-sil-opaque-values -emit-sorted-sil \
// RUN: -enable-ossa-modules -enable-copy-propagation | \
// RUN: %FileCheck %s

// Using -sil-disable-pass=mandatory-copy-propagation to pattern match
// against older SIL output. At least until -enable-copy-propagation
// has been around long enough in the same form to be worth rewriting
// CHECK lines.

import Builtin

sil_stage raw
Expand Down
10 changes: 10 additions & 0 deletions tools/sil-opt/SILOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ static llvm::cl::opt<bool> EnableOSSAModules(
"this is disabled we do not serialize in OSSA "
"form when optimizing."));

static llvm::cl::opt<bool> EnableCopyPropagation(
Copy link
Contributor

@atrick atrick Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually have two options -enable-copy-propagation and -disable-copy-propagation, both of which default to 'false'. Enabling either one overrides the default pipeline behavior, which depends on the optimization level and whether OSSA is enabled.
That should fix the test failures.

Copy link
Contributor Author

@nate-chandler nate-chandler Jul 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like swift-frontend has those flags to control the EnableCopyPropagation and DisableCopyPropagation flags of the SILOptions class, but sil-opt doesn't (yet). Considering that they both have independent effects, it seems likely that at some point they'll both be useful for sil-opt. I went ahead and pushed another commit ( 7e5747b ) to add -disable-copy-propagation to sil-opt to set DisableCopyPropagation to true ( like -enable-copy-propagation does for EnableCopyPropagation in sil-opt as of 7e5747b ).

The test failures were

  Swift(macosx-x86_64) :: Interpreter/SDK/objc_bridge_cast.swift
  Swift(macosx-x86_64) :: Interpreter/SDK/objc_dealloc.swift

and seem to be unrelated, affecting other PRs, like https://ci.swift.org/job/swift-PR-macos/28081/consoleText .

"enable-copy-propagation",
llvm::cl::desc("Enable the copy propagation pass."));

static llvm::cl::opt<bool> DisableCopyPropagation(
"disable-copy-propagation",
llvm::cl::desc("Disable the copy propagation pass."));

namespace {
enum class EnforceExclusivityMode {
Unchecked, // static only
Expand Down Expand Up @@ -470,6 +478,8 @@ int main(int argc, char **argv) {
SILOpts.EnableSpeculativeDevirtualization = EnableSpeculativeDevirtualization;
SILOpts.IgnoreAlwaysInline = IgnoreAlwaysInline;
SILOpts.EnableOSSAModules = EnableOSSAModules;
SILOpts.EnableCopyPropagation = EnableCopyPropagation;
SILOpts.DisableCopyPropagation = DisableCopyPropagation;

serialization::ExtendedValidationInfo extendedInfo;
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
Expand Down