Skip to content

SIL: don't print operand types in textual SIL #77763

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
merged 3 commits into from
Nov 22, 2024

Conversation

eeckstein
Copy link
Contributor

Type annotations for instruction operands are omitted, e.g.

  %3 = struct $S(%1, %2)

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types are printed if the definition of the operand value was not printed yet.
This happens:

  • if the block with the definition appears after the block where the operand's instruction is located

  • if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with -Xllvm -sil-print-types.
This option is added to many existing test files which check for operand types in their check-lines.

Also add -Xllvm -sil-print-no-uses to not print use-list comments in textual SIL.

(This PR was originally part of #77714)

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@rjmccall I'm replying in this PR to your comment in #77714

I don't like the idea of having multiple dialects of SIL itself

It would not call this a dialect. It just makes printing the type annotations optional.
Anyway, with this PR I changed it to the default (and added -Xllvm -sil-print-types to force printing type annotations for all operands - which is the old behavior).

Or we could make operand types optional and then only print them when blocks are rendered out of order?

Yes, that's exactly how it works.

@eeckstein
Copy link
Contributor Author

@swift-ci test

The original intention of those REQUIRE lines where to limit the tests to run on 64 bit architectures.
Type annotations for instruction operands are omitted, e.g.

```
  %3 = struct $S(%1, %2)
```

Operand types are redundant anyway and were only used for sanity checking in the SIL parser.

But: operand types _are_ printed if the definition of the operand value was not printed yet.
This happens:

* if the block with the definition appears after the block where the operand's instruction is located

* if a block or instruction is printed in isolation, e.g. in a debugger

The old behavior can be restored with `-Xllvm -sil-print-types`.
This option is added to many existing test files which check for operand types in their check-lines.
@eeckstein
Copy link
Contributor Author

@swift-ci test

@rjmccall
Copy link
Contributor

@rjmccall I'm replying in this PR to your comment in #77714

I don't like the idea of having multiple dialects of SIL itself

It would not call this a dialect. It just makes printing the type annotations optional. Anyway, with this PR I changed it to the default (and added -Xllvm -sil-print-types to force printing type annotations for all operands - which is the old behavior).

Or we could make operand types optional and then only print them when blocks are rendered out of order?

Yes, that's exactly how it works.

Ah, yes, if that was the existing behavior of your patch, then (1) I definitely misunderstood what you were proposing and (2) I agree that this not a dialect. "Pure" SIL sounded much more like a dialect.


llvm::cl::opt<bool>
SILPrintNoUses("sil-print-no-uses", llvm::cl::init(false),
llvm::cl::desc("omit use comments in SIL output"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we have a bunch of this already, but we really need to kick the habit of using global llvm::cl::opts instead of breaking down the command line into a context and threading that context into passes. This stuff all turns into global constructors that have to run in every process that even links this code in. The Carbon folks are finding that the uses in the LLVM passes alone are a significant contributor to their compile times; admittedly, they have a much faster compiler overall, but still.

Anyway, just feedback for a later PR.

Copy link
Contributor Author

@eeckstein eeckstein Nov 21, 2024

Choose a reason for hiding this comment

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

Yeah, we should clean up our command line options

@eeckstein eeckstein merged commit 29f6f01 into swiftlang:main Nov 22, 2024
5 checks passed
@eeckstein eeckstein deleted the sil-printing branch November 22, 2024 05:42
eeckstein added a commit to eeckstein/swift that referenced this pull request Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants