Commit Graph

160 Commits

Author SHA1 Message Date
Michael Gottesman
72a093da52 [semantic-arc-opts] Teach the guaranteed copy_value peephole how to handle instructions that can forward either owned or guaranteed ownership.
This fixes issues exposed by my turning off the Nominal Type RValue peephole. It
should give us some nice ARC wins as well potentially.
2019-03-21 13:50:41 -07:00
Slava Pestov
8915f96e3e SIL: Replace SILType::isTrivial(SILModule) with isTrivial(SILFunction) 2019-03-12 01:16:04 -04:00
Michael Gottesman
33e5aba554 Merge pull request #20855 from gottesmm/pr-94ee6e6c6e2d268f47f17dead77e4feb169c24e6
[ownership] Replace ValueOwnershipKind::Trivial with ValueOwnershipKi…
2018-12-05 14:47:04 -08:00
Michael Gottesman
0af0d5fddc [ownership] Replace ValueOwnershipKind::Trivial with ValueOwnershipKind::Any.
In a previous commit, I banned in the verifier any SILValue from producing
ValueOwnershipKind::Any in preparation for this.

This change arises out of discussions in between John, Andy, and I around
ValueOwnershipKind::Trivial. The specific realization was that this ownership
kind was an unnecessary conflation of the a type system idea (triviality) with
an ownership idea (@any, an ownership kind that is compatible with any other
ownership kind at value merge points and can only create). This caused the
ownership model to have to contort to handle the non-payloaded or trivial cases
of non-trivial enums. This is unnecessary if we just eliminate the any case and
in the verifier separately verify that trivial => @any (notice that we do not
verify that @any => trivial).

NOTE: This is technically an NFC intended change since I am just replacing
Trivial with Any. That is why if you look at the tests you will see that I
actually did not need to update anything except removing some @trivial ownership
since @any ownership is represented without writing @any in the parsed sil.

rdar://46294760
2018-12-04 23:01:43 -08:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Michael Gottesman
71c13b7594 [sil] Rename ValueOwnershipKindClassifier.cpp -> ValueOwnership.cpp and remove ValueOwnershipKindClassifier.h
This matches the name of OperandOwnership.cpp which performs an anologous
function. I also was able to eliminate an unneeded header.  The key thing here
is that the only reason that we had ValueOwnershipKindClassifier.h was because
we needed some defs from it in SILValue.cpp for SILValue::getOwnershipKind()
... which is great except for the fact that ValueOwnershipKindClassifier is
basically the implementation of SILValue::getOwnershipKind().

So what this patch does is moves the implementation of
SILValue::getOwnershipKind() from SILValue.cpp -> ValueOwnership.cpp and then
puts the visitor into an anonymous namespace in that file.

I also added a little comment in SILValue.h that says that
SILValue::getOwnershipKind() is implemented in ValueOwnership.cpp, not
SILValue.cpp.
2018-10-29 23:50:54 -07:00
Erik Eckstein
ac2b5720b0 SILOptimizer: support static large string literal generation for the new UTF8 String implementation
In the new string implementation there is a subtract of a (small) constant from the literal pointer. We convert

((ptr - offset) | bits

to

(ptr + (bits - offset))

which can still be represented as a relocation.
2018-10-25 10:18:23 -07:00
Michael Gottesman
157091d5c6 [ownership] Extract out from SILOwnershipVerifier the OperandOwnershipKindMapClassifier
NOTE: This is not the final form of how operand ownership restraints will be
represented. This patch is instead an incremental change that extracts out this
functionality from the ownership verifier as a pure refactor.

rdar://44667493
2018-10-01 22:14:41 -07:00
Jason Mittertreiner
8ac9a657a8 Fix 'operator ==' is ambiguous with MSVC (#19501)
When compiling with MSVC on Windows, this error among other similar
conflicts with AnyValue occur:

Defined the overloads so it selects the correct one.
2018-09-24 12:39:44 -07:00
Michael Gottesman
af7d301512 [sil] Make ValueOwnershipKind(unsigned) explicit to prevent implicit casts from ints/bools to ValueOwnershipKind.
I hit this problem while splitting classifying operand ownership from the
ownership verifier itself. There is no reason to allow for this implicit
conversion. Just makes updating code more error prone.

rdar://44667493
2018-09-21 09:58:02 -07:00
Sho Ikeda
03fbd4a6de [gardening][SIL] Replace typedef with using 2018-04-05 13:53:20 +09:00
swift-ci
d830b970db Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-19 10:50:38 -08:00
Michael Gottesman
71b508e402 Refactor compatibleOwnershipKind, trivialOrCompatibleOwnershipKinds onto ValueOwnershipKind instead of being free functions.
I have a bunch of work that I have done on a side branch some time ago to split
determining what value ownership kinds are able to be associated with a specific
operand.

This PR just upstreams a small part of the larger change.
2018-02-19 07:01:44 -08:00
swift-ci
00cf2a4070 Merge remote-tracking branch 'origin/master' into master-next 2017-12-28 08:49:22 -08:00
David Zarzycki
68c696dbc1 [SIL] NFC: Replace boilerplate projection with swift::ArrayRefView 2017-12-28 09:51:29 -05:00
swift-ci
f8dde3619a Merge remote-tracking branch 'origin/master' into master-next 2017-12-27 10:49:23 -08:00
David Zarzycki
3910c0d211 [SIL] NFC: Remove TailAllocatedOperandList template
Please use InstructionBaseWithTrailingOperands template now. It is more type safe and more space efficient.
2017-12-27 11:18:54 -05:00
swift-ci
0302515cf0 Merge remote-tracking branch 'origin/master' into master-next 2017-12-18 12:48:55 -08:00
David Zarzycki
7368cc9a8b [SIL] NFC: Convert SILNode to new inline bitfield macros 2017-12-16 09:31:21 -05:00
swift-ci
7ad712de8e Merge remote-tracking branch 'origin/master' into master-next 2017-10-24 18:49:07 -07:00
Michael Gottesman
36a8d0d5c0 [sil] Add support for the destructure_{struct,tuple} instructions.
rdar://31521023
2017-10-24 18:36:37 -07:00
Michael Gottesman
6df5462ee2 [sil] Add support for multiple value instructions by adding MultipleValueInstruction{,Result}.
rdar://31521023
2017-10-24 18:36:37 -07:00
swift-ci
34c8e98893 Merge remote-tracking branch 'origin/master' into master-next 2017-10-15 16:29:23 -07:00
Chris Lattner
cd99f859e3 NFC code cleanup changes:
- Hoist a duplicated static function with a fixme out to SILValue::getLoc()
 - Fix a whitespace issue.
2017-10-15 15:31:41 -07:00
swift-ci
135a4286b5 Merge remote-tracking branch 'origin/master' into master-next 2017-09-25 10:29:30 -07:00
John McCall
ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
introduce a common superclass, SILNode.

This is in preparation for allowing instructions to have multiple
results.  It is also a somewhat more elegant representation for
instructions that have zero results.  Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction.  Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.

A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.

Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
2017-09-25 02:06:26 -04:00
swift-ci
b51e2e6837 Merge remote-tracking branch 'origin/master' into master-next 2017-09-15 13:29:49 -07:00
Joe Groff
78d75428d6 SILGen: Lower key path subscript indexes.
And fill out SIL support for parsing, printing, and serializing key path
patterns with captured indexes.
2017-09-15 10:00:32 -07:00
swift-ci
546836ceff Merge remote-tracking branch 'origin/master' into master-next 2017-09-11 15:08:53 -07:00
Roman Levenstein
74908ce818 Create utility functions for mapping between the numeric opcode of a SILValue/SILInstruction and its mnemonic name
Use it for the stats collection, but also for SIL printing.
2017-09-10 21:47:55 -07:00
Davide Italiano
d98a15875d [SILValue] Prefer const_cast<> to C-style cast.
Prevents a quite spammy warning with new versions of clang
(in the particular case, trunk as per today).
2017-09-09 16:59:16 -07:00
John McCall
a5d328690d PointerLikeTypeTraits is now a struct, not a class.
We compile with a pedantic warning that complains about these things,
and the massive flood of warnings is actually causing problems for the
build infrastructure.
2017-08-17 17:01:17 -04:00
Erik Eckstein
6377cc095a SIL: Replace TransitivelyUnreachableBlocks with DeadEndBlocks
We had both utilities doing the same thing.
NFC
2017-07-24 09:50:42 -07:00
Michael Gottesman
38cd78024b Add template <T> ValueBase::getSingleUserOfType.
Looping over all users and returning the only user of a specific type is a
common pattern in the compiler. This method just allows for the loop to be
eliminated.
2017-07-13 14:22:42 -07:00
Michael Gottesman
c3a5c51586 [gardening] Move SILInstruction::replaceAllUsesWithUndef onto ValueBase.
This allows this method to also be used on SILArguments.
2017-06-05 17:01:02 -07:00
Michael Gottesman
c28a62d97c [ome] Make sure to rewire all project_box we insert through the mark_uninitialized project_box to preserve DI behavior.
Once I update DI in a bit, this will no longer be necessary.

rdar://29870610
2017-04-03 12:17:44 -07:00
Michael Gottesman
00bcd15765 [sil] Add a new API ValueBase::getSingleUser()
This API returns nullptr if the ValueBase has more than one user and an
Operand * otherwise.
2017-04-02 10:51:08 -07:00
Michael Gottesman
cfb5893663 [silgen] Fix destroying destructor to use proper ownership with its @owned return value.
rdar://29791263
2017-03-02 17:17:17 -08:00
Michael Gottesman
784d5d16fc [silgen] Change emitClassConstructorInitializer to use ownership and make calling designated/chaining initializes use proper ownership.
rdar://29791263
2017-02-23 08:48:58 -08:00
Michael Gottesman
ed67bf9f21 [ownership-verifier] Teach the ownership verifier how to handle unreachable code.
There are a few different use cases here:

1. In Raw SIL, no return folding may not have been run yet implying that a call
to a no-return function /can/ have arbitrary control flow after it (consider
mandatory inlined functions). We need to recognize that the region of code that
is strictly post dominated by the no-return function is "transitively
unreachable" and thus leaking is ok from that point. *Footnote 1*.

2. In Canonical and Raw SIL, we must recognize that unreachables and no-return
functions constitute places where we are allowed to leak.

rdar://29791263

----

*Footnote 1*: The reason why this is done is since we want to emit unreachable
code diagnostics when we run no-return folding. By leaving in the relevant code,
we have preserved all of the SILLocations on that code allowing us to create
really nice diagnostics.
2017-02-13 16:36:01 -08:00
Michael Gottesman
ea1f804207 [semantic-sil] Eliminate ValueOwnershipKind::Any from SILPHIArguments in Semantic SIL.
Most of this involved sprinkling ValueOwnershipKind::Owned in many places. In
some of these places, I am sure I was too cavalier and I expect some of them to
be trivial. The verifier will help me to track those down.

On the other hand, I do expect there to be some places where we are willing to
accept guaranteed+trivial or owned+trivial. In those cases, I am going to
provide an aggregate ValueOwnershipKind that will then tell SILArgument that it
should disambiguate using the type. This will eliminate the ackwardness from
such code.

I am going to use a verifier to fix such cases.

This commit also begins the serialization of ValueOwnershipKind of arguments,
but does not implement parsing of value ownership kinds. That and undef are the
last places that we still use ValueOwnershipKind::Any.

rdar://29791263
2017-01-10 20:05:23 -08:00
Michael Gottesman
6b9aba8d2c [semantic-sil] Add a constructor for making a ValueOwnershipKind from a SILArgumentConvention. 2017-01-08 00:22:54 -08:00
Michael Gottesman
f23086bfaf [semantic-sil] Change ValueOwnershipKind into a struct enum and change helper functions to be helper methods. 2017-01-08 00:22:54 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Michael Gottesman
d77bcdce57 [sil-ownership-verifier] Fix a few bugs and add a few tests. 2016-12-21 22:28:29 -08:00
Michael Gottesman
4931161929 [semantic-sil] Implement the dataflow checker behind the -enable-semantic-sil flag.
This commit includes the dataflow verifier and plugs in the use checker into the
dataflow verifier.

Some specific checks in the use checker need revision, but I for today
this is good enough. As I go through SILGen I am going to fix them.

rdar://29671437
2016-12-18 22:55:03 -08:00
practicalswift
a3ce1601ca [gardening] Fix typos. 2016-12-18 09:58:19 +01:00
practicalswift
8f0330e424 Merge pull request #6347 from practicalswift/namespace-normalization
[gardening] Normalize end-of-namespace comments
2016-12-17 23:14:28 +01:00
practicalswift
9d0b2abfc2 [gardening] Normalize end-of-namespace comments 2016-12-17 22:29:07 +01:00
Michael Gottesman
a178ac97e0 [sil-ownership] Fix some cases in SILValue::getOwnershipKind().
I fixed a few things. Now I am finally hitting cases where we have
guaranteed/owned arguments, so I really need to do the SILGen work. But this was
a good first step.

rdar://29671437
2016-12-17 01:23:52 -08:00