Commit Graph

80 Commits

Author SHA1 Message Date
Nadav Rotem
9eddbf670c CSE static class_method instructions.
Swift SVN r27539
2015-04-21 23:21:16 +00:00
Chris Lattner
42b4a966b0 Introduce a new null_class SIL instruction for forming a null pointer
reference to something of class type.  This is required to model
RebindSelfInConstructorExpr correctly to DI, since in the class case, 
self.init and super.init *take* a value out of class box so that it 
can pass the +1 value without performing an extra retain.  Nothing
else in the compiler uninitializes a DI-controlled memory object
like this, so nothing else needs this.  DI really doesn't like something
going from initialized to uninitialized.

Yes, I feel super-gross about this and am really unhappy about it.  I
may end up reverting this if I can find an alternate solution to this
problem.



Swift SVN r27525
2015-04-21 05:56:55 +00:00
Nadav Rotem
240ff14db1 Split DominanceAnalysis into Dom and PDom using FunctionAnalysisBase.
This commit splits DominanceAnalysis into two analysis (Dom and PDom) that
can be cached and invalidates using the common FunctionAnalysisBase interface
independent of one another.

Swift SVN r26643
2015-03-27 20:54:28 +00:00
Mark Lacey
1f23ff27bb Remove the transparent bit from apply instructions.
We no longer need or use it since we can always refer to the same bit on
the applied function when deciding whether to inline during mandatory
inlining.

Resolves rdar://problem/19478366.

Swift SVN r26534
2015-03-25 08:36:34 +00:00
Erik Eckstein
b0f55d701d Enable bridge_object_to_word instruction for CSE.
Swift SVN r26488
2015-03-24 15:45:56 +00:00
Nadav Rotem
d78b376d07 [passes] Replace the old invalidation lattice with a new invalidation scheme.
The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis.  In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.

Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.

Swift SVN r26449
2015-03-23 21:18:58 +00:00
Arnold Schwaighofer
f7c01f2061 Nuke isReadNone function
We can now compute the same result with Inst.mayReadOrWriteMemory(). NFC.

Swift SVN r25743
2015-03-04 05:03:45 +00:00
Dmitri Hrybenko
61286f0260 Fix warnings produced by a newer version of Clang
Swift SVN r25257
2015-02-12 23:50:47 +00:00
Mark Lacey
fa49f01edf Support CSE of thin_function_to_pointer/pointer_to_thin_function.
Fixes <rdar://problem/19285001>

Patch by Luqman Aden <luqman_aden@apple.com>.

Swift SVN r24604
2015-01-21 19:36:51 +00:00
Arnold Schwaighofer
e9d650d01c CSE: handle RefToBridgeObjectInst and BridgeObjectToRefInst
rdar://19009279

Swift SVN r23414
2014-11-18 21:46:43 +00:00
Roman Levenstein
f016754ef9 Add a new select_value instruction. This instruction should be the equivalent of select_enum, just for builtin int types. Such an instruction is needed e.g. to efficiently implement conversions of Int raw values to C-like enums.
rdar://18812325

Swift SVN r23036
2014-10-31 20:44:11 +00:00
Joe Groff
3f23b82e6d SIL: Rename SILGlobalAddr to GlobalAddr.
All globals are SIL globals now.

Swift SVN r22827
2014-10-18 17:08:28 +00:00
Joe Groff
ea65d1e60b SIL: Remove the builtin_function_ref instruction.
Swift SVN r22797
2014-10-16 16:18:40 +00:00
Joe Groff
e3f9a2035c SIL: Move SILGen and passes over to use "builtin" instead of "apply (builtin_function_ref)".
Swift SVN r22785
2014-10-15 23:37:22 +00:00
Joe Groff
bb46f4bbd9 SIL: Remove the global_addr instruction.
It's no longer needed now that we always lower to SIL globals.

Swift SVN r22693
2014-10-12 17:19:06 +00:00
Joe Groff
9205bf64cf SIL: Remove enum_is_tag.
Swift SVN r22616
2014-10-09 05:03:43 +00:00
Joe Groff
c2fc9f58b8 SIL passes: Work with select_enum instead of enum_is_tag.
Simplify binary switches to select_enum instead of enum_is_tag, and make a first attempt at changing passes over to recognize limited forms of select_enum instead of enum_is_tag. There is one case in test/SILPasses/simplify_cfg.sil I wasn't able to figure out, and there are a lot more general passes we could define in terms of select_enum.

Swift SVN r22615
2014-10-09 03:49:31 +00:00
Roman Levenstein
1f635d0510 Add a CSE support for 15 SIL instructions that were not covered by the CSE pass yet.
rdar://16652567

Swift SVN r22281
2014-09-25 11:44:51 +00:00
Manman Ren
a952c556c9 [Global Opt] replace GlobalAddrInst with SILGlobalAddrInst.
Update SILGen to create SILGlobalVariable and SILGlobalAddrInst instead of
GlobalAddrInst. When we see a definition for a global variable, we create
the corrsponding SILGlobalVariable definition.

When creating SILGlobalVariable from a global VarDecl, we mangle the global
VarDecl in the same way as we mangle it at IRGen. The SILLinkage is also
set in the same way as we set it at IRGen.

At IRGen, we use the associated VarDecl for SILGlobalVariable if it exists,
to have better debugging information.

We set the initializer for SILGlobalVariable definition only.

We also handle SILGlobalAddrInst in various SILPasses, in the similar way
as we handle GlobalAddrInst.

rdar://15493694


Swift SVN r21887
2014-09-11 20:00:39 +00:00
Michael Gottesman
6e485700c6 Move SimplifyInstruction into SILAnalysis since it is an analysis.
This will hopefully make it clearer as we onboard people that
SimplifyInstruction should not add instructions to the IR by making it clearer
that it is an analysis, not a pass.

Swift SVN r21752
2014-09-05 22:56:26 +00:00
Mark Lacey
0e66624c38 CSE ThickToObjCMetatypeInst.
No significant perf changes on the pre-commit perf suite.

Swift SVN r21344
2014-08-21 06:00:35 +00:00
Arnold Schwaighofer
88372515bd Add an isReadNone API for function refs and use it in CSE
This looks for @effects(readnone) on functions. A follow up commit will mark
_swift_isClassOrObjCExistential as readnone allowing us to CSE it.

rdar://17961249

Swift SVN r21285
2014-08-19 18:05:41 +00:00
Arnold Schwaighofer
cbf6f1521b CSE: Calls that participate in cse need to be readnone
Currently this should not matter because isSideEffectFree calls isReadNone for
swift builtins. The only difference between isReadNone and isSideEffectFree is
that isSideEffectFree allows llvm intrinsics that are readonly.
Looking at llvm's intrinsic td file I did not see any readonly functions so we
should also be safe before this change. But better safe than sorry - especially
if someone changes the implementation of isSideEffectFree to be more permissable
later.

Swift SVN r21239
2014-08-15 22:45:54 +00:00
Michael Gottesman
f0043de416 [cse] Add support for address_to_pointer and index_addr.
This reduces the number of optimizable retain, release pairs in a swap on Strings from 6 to 2:

func foo(inout T : [String]) {
  swap(&T[9], &T[1])
}

Swift SVN r21191
2014-08-14 01:45:34 +00:00
Pete Cooper
65d8cb9ad2 CSE upcast instructions. <rdar://problem/17625307>
Swift SVN r19847
2014-07-11 11:18:23 +00:00
Pete Cooper
c183cebfea CSE ref_to_raw_pointer
Swift SVN r19739
2014-07-09 20:19:50 +00:00
Pete Cooper
267fc43b6b Assert in CSE that instructions are equal to themselves. This will catch errors where key lookups won't match themselves because some instructions are not implemented in InstructionIdentityComparer
Swift SVN r19738
2014-07-09 20:19:44 +00:00
Nadav Rotem
0ad0c46a19 CSE: add support to the new bitcast instructions.
Swift SVN r19197
2014-06-26 00:10:17 +00:00
Mark Lacey
19fd2ce0d2 Clean-up hashing in CSE by using the stored kind of the inst.
Swift SVN r18703
2014-06-04 18:21:59 +00:00
Mark Lacey
5115536a50 Align case labels with switch statement.
Swift SVN r18702
2014-06-04 18:21:57 +00:00
Michael Gottesman
eb9a804a75 [sil-cse] Teach CSE how to handle unchecked_enum_data.
Swift SVN r18694
2014-06-03 08:31:09 +00:00
Michael Gottesman
45b45b8b7a [cse] Teach CSE how to handle enum insts.
rdar://16560688

Swift SVN r16310
2014-04-14 11:05:41 +00:00
Nadav Rotem
51087ea8b0 CSE cond_fail.
Swift SVN r15111
2014-03-16 04:27:07 +00:00
Nadav Rotem
6b6761fa08 CSE ApplyInst of BuiltIns with no side effects.
Swift SVN r15110
2014-03-16 03:52:18 +00:00
Nadav Rotem
9583261228 CSE two more instructions.
Swift SVN r15102
2014-03-15 07:25:26 +00:00
Chris Lattner
001c1890e5 put all the SIL*Transform classes in anonymous namespaces, there is
no need for their symbols to be exported out of their implementation
file.


Swift SVN r14714
2014-03-06 01:49:53 +00:00
Andrew Trick
0825258b80 SIL transforms should only invalidate when things change.
-sil-print-all shows a nice readable evolution now.

Oh yeah, and we don't unnecessarilly rerun passes.

Swift SVN r13677
2014-02-08 08:20:45 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Nadav Rotem
27a1a63134 Remove unneeded empty virtual destructors.
Swift SVN r13599
2014-02-06 22:24:33 +00:00
Nadav Rotem
1ef0d157ca PassManager: Inject the function/module into the Transformation.
Now the pass does not need to know about the pass manager. We also don't have
runOnFunction or runOnModule anymore because the trnasformation knows
which module it is processing. The Pass itself knows how to invalidate the
analysis, based on the injected pass manager that is internal to the
transformation.

Now our DCE transformation looks like this:

class DCE : public SILModuleTransform {
  void run() {
    performSILDeadCodeElimination(getModule());
    invalidateAnalysis(SILAnalysis::InvalidationKind::All);
  }
};





Swift SVN r13598
2014-02-06 22:11:21 +00:00
Michael Gottesman
3b43e09bae Change getAnalysis<T> to be asserting and provide a new entry point getAnalysisOrNull<T>. Remove all of the unneeded asserts in the various passes.
Swift SVN r13576
2014-02-06 10:06:18 +00:00
Nadav Rotem
0651b9bbd0 Add a new Dominance Analysis that wraps DomInfo and PDomInfo, and migrate the
passes that use them.



Swift SVN r13571
2014-02-06 07:52:16 +00:00
Nadav Rotem
99b075c32a Rename SILFunctionTrans -> SILFunctionTransform
Swift SVN r13536
2014-02-06 01:32:10 +00:00
Nadav Rotem
f8c7b54d28 Delete the unused performXXX() functions.
Swift SVN r13531
2014-02-06 00:57:28 +00:00
Michael Gottesman
631f9326ab [PM] Change enum => enum class everywhere in the PM code. Additionally fix some typos.
Swift SVN r13507
2014-02-05 21:25:15 +00:00
Nadav Rotem
baa1d1679a Teach some of the passes about the new PM.
Swift SVN r13494
2014-02-05 18:58:23 +00:00
Nadav Rotem
4096605491 vim-format the file. Convert 4-space indents into 2.
Swift SVN r13156
2014-01-30 18:26:16 +00:00
Nadav Rotem
9c119bae56 clang-format the file.
Swift SVN r13152
2014-01-30 17:37:40 +00:00
Nadav Rotem
230842221e Move the code motion optimizations into a new pass. NFC.
Swift SVN r13150
2014-01-30 17:32:57 +00:00
Nadav Rotem
75b0cffd9f When sinking instructions from predecessors look in a small window of instructions.
This gives a 2X boost on StringSort.



Swift SVN r13142
2014-01-30 06:01:28 +00:00