Commit Graph

84 Commits

Author SHA1 Message Date
Roman Levenstein
2ff5755dc3 Use the "rt_" prefix for all generated wrappers to distinguish them from the actual runtime functions. 2016-02-25 06:00:30 -08:00
Roman Levenstein
99fd8b6080 Rename some macros based on the PR review comments.
- use  the SWIFT prefix for all macros
- make names of some macros shorter
2016-02-25 05:31:00 -08:00
Roman Levenstein
de3b850ce8 Use more descriptive names for calling conventions.
Rename RuntimeCC into DefaultCC
Rename RuntimeCC1 into RegisterPreservingCC
Remove RuntimeCC0 because it was identical to DefaultCC.
2016-02-25 05:31:00 -08:00
Roman Levenstein
ec04b22145 Properly propagate the calling convention into LLVM's call instructions.
Each runtime function definition in RuntimeFunctions.def states which calling convention
should be used for this runtime function.  But IRGen and LLVMPasses were not always
properly propagating this declared calling convention all the way down to llvm's Call instructions.
In many cases, the standard C convention was set for the call irrespective of the actual calling
convention defined for a given runtime function. As a result, incorrect code was generated.

This commit tries to fix all those places, where such a mismatch was found. In many cases this is
achieved by defining a helper function CreateCall in such a way that makes sure that the call instruction
gets the same calling convention as the one used by its callee operand.
2016-02-25 05:30:59 -08:00
Roman Levenstein
7350fee0e3 LLVMPasses should generate LLVM IR declarations of runtime functions in the same way as done by IRGen.
Make use of the re-usable functionality provided by IRGen. This ensures that LLVM IR generated by IRGen and
LLVMPasses for runtime functions declarations or wrappers is always in sync.
2016-02-25 05:30:58 -08:00
Roman Levenstein
4a93b3e78b Add include guards to LLVMArcOpts.h. 2016-02-17 16:12:09 -08:00
practicalswift
dd3508c785 [gardening] Fix header consistency for newly introduced file. 2016-02-10 22:14:58 +01:00
Erik Eckstein
9e28192ea3 Option -print-llvm-inline-tree for printing the inline-tree of the LLVM module.
This is useful to get information about what inlined functions contribute to the code size.
2016-02-10 12:14:23 -08:00
practicalswift
ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
149b50d901 Fix typos in code (non-comment/documentation typos). 2015-12-28 11:42:15 +01:00
Slava Pestov
36ddea64ae Merge pull request #729 from ken0nek/fix-can-not
Convert [Cc]an not -> [Cc]annot
2015-12-22 16:06:20 -08:00
practicalswift
6e3b700b44 Fix typos. 2015-12-23 00:31:13 +01:00
ken0nek
fcd8fcee91 Convert [Cc]an not -> [Cc]annot 2015-12-23 00:55:48 +09:00
Joe Groff
cf87b9d571 IRGen: Generate swift_fixLifetime marker as a private stub.
This lets us remove `swift_fixLifetime` as a real runtime entry point. Also, avoid generating the marker at all if the LLVM ARC optimizer won't be run, as in -Onone or -disable-llvm-arc-optimizer mode.
2015-12-21 18:06:18 -08:00
practicalswift
cd7d8dfaff Fix alignment as requested by @gribozavr in #692 2015-12-21 08:54:24 +01:00
practicalswift
176f487d76 Fix incorrect filenames in headers. 2015-12-20 23:59:05 +01:00
practicalswift
8ab8847684 Fix typos. 2015-12-16 22:09:32 +01:00
Simone Ferrini
ce4031f240 Removed unnecessary semicolons 2015-12-03 21:24:40 +01:00
Xin Tong
0b79ecf51c Rename swift-arc-optimize to swift-llvm-arc-optimize as this is a LLVM pass 2015-11-18 11:53:23 -08:00
Michael Gottesman
9fb54bf4bf Fix for upstream ilist changes. 2015-11-11 16:07:41 -08:00
Erik Eckstein
ce848c648d And again: re-apply the StackPromotion commit 0dd045ca04.
The problem of the failure was a bug in instruction cloning, which is fixed in the previous commit.
2015-11-08 15:51:00 -08:00
Mark Lacey
e9718f619e Revert "Another try to re-apply the StackPromotion commit 0dd045ca04dcc10a33abf57f7e1b08260c4e3de1."
This reverts commit 7d70aa39dc because
it may be responsible for a bot breakage.
2015-11-07 16:51:24 -08:00
Erik Eckstein
7d70aa39dc Another try to re-apply the StackPromotion commit 0dd045ca04.
One bug fixed in escape analysis (previous commit) and one bug fixed in StackPromotion itself.
2015-11-06 16:16:36 -08:00
Arnold Schwaighofer
fd662987c8 Revert the StackPromotion pass - bots hit an assert.
Assertion failed: (NumUsePointsToFind > 0 && "There must be at least one
releasing instruction for an alloc"), function canPromoteAlloc

Revert "Fix comment for StackPromotion pass in SIL Passes"
Revert "Reapply the StackPromotion commit
0dd045ca04dcc10a33abf57f7e1b08260c4e3de1."

This reverts commit 3f4b1496bd and commit
199cfca13b.
2015-11-06 06:40:05 -08:00
Erik Eckstein
199cfca13b Reapply the StackPromotion commit 0dd045ca04.
This time with fixing a crash.
2015-11-05 22:01:27 -08:00
Erik Eckstein
d7b7fc76ea Revert "Add a stack promotion optimization."
This reverts commit 0dd045ca04.

StackPromotion crashes when compiling MatMult in stdlib-asserts configuration
2015-11-05 21:34:05 -08:00
Erik Eckstein
0dd045ca04 Add a stack promotion optimization.
It promotes allocations of native swift objects and array buffers to the stack if it is possible.
The SIL StackPromotion pass is the main part of the optimization. For details see comments there.
Unfortunately we need an additional LLVM pass to handle array buffers, which is not very nice.
I hope that we can get rid of it in future (again: for details see the comments in StackPromotion.cpp)

The optimization gives performance improvements in some benchmarks, mostly related to array literals:
ArrayLiteral: +12%
Combos: +16%
DictionaryLiteral: + 37%
RIPEMD: +10%
StringBuilder: +27%
StringInterpolation: +11%
And last but not least the new benchmark which is dedicated to test stack promotion:
ObjectAllocation: +52%
2015-11-05 16:52:59 -08:00
Michael Gottesman
9ebc0d214b Move the declaration of initializeSwiftARCContractPass and initializeSwiftARCOptPass from {LLVMARCContarct,LLVMARCOpts}.cpp => PassesFwd.h so swift-llvm-opts can use them.
Swift SVN r32807
2015-10-21 21:45:19 +00:00
Michael Gottesman
72f5063f3c Update SwiftAA for upstream AA changes.
Swift SVN r32800
2015-10-21 21:45:13 +00:00
Chris Lattner
fe78e77783 silence some warnings.
Swift SVN r32176
2015-09-23 05:06:51 +00:00
Xin Tong
921a951b63 Fix a compiler crasher with replaceAllUsesWith in LLVMARCOpt.
Swift SVN r32148
2015-09-22 16:20:45 +00:00
Xin Tong
ecc7cc091c Use LLVM RC Identity for LLVMARCOpt Retain/Release code motion.rdar://22774326
Swift SVN r32146
2015-09-22 05:58:07 +00:00
Xin Tong
2b546cd6b5 Implement bridgeobject_retain/release merging in LLVMARCContract. rdar://22108790
recommit for r32132.

Swift SVN r32145
2015-09-22 04:34:53 +00:00
Dmitri Hrybenko
55c6c8bd98 Revert "Implement bridgeobject_retain/release merging in LLVMARCContract. rdar://22108790"
This reverts commit r32132.  It broke tests:

Swift :: 1_stdlib/FloatingPoint.swift.gyb
Swift :: 1_stdlib/NSStringAPI.swift
Swift :: 1_stdlib/Runtime.swift
Swift :: Interpreter/SDK/CoreGraphics_CGFloat.swift

Swift SVN r32142
2015-09-22 01:08:02 +00:00
Xin Tong
3eb7000b8f Implement bridgeobject_retain/release merging in LLVMARCContract. rdar://22108790
Swift SVN r32132
2015-09-21 23:06:19 +00:00
Xin Tong
c9f43c824c LLVM level RC identity, strip off pointer casts as well as reference forwarding
for some of the entry points. rdar://22774326

Swift SVN r32124
2015-09-21 21:16:22 +00:00
Xin Tong
720d49be49 update comments for swift_retain, i.e. it returns no reference now
Swift SVN r32095
2015-09-19 16:38:31 +00:00
Xin Tong
768a6011de Add retain_n entry points to SwiftAA. rdar://22765670
Swift SVN r32094
2015-09-19 16:37:27 +00:00
Xin Tong
33193ef2d8 Strength reduce unknownRetain to retain.
when an object is passed to unknownRetain and retain, the unknownRetain
can be strength reduced to retain.  same for unknownRelease and release.

Swift SVN r32087
2015-09-18 23:20:20 +00:00
Xin Tong
75385d0501 merge multiple unknownRetain/unknownReleases to
unknownRetain_n/unknownRelease_n rdar://21945003

Swift SVN r32084
2015-09-18 22:25:59 +00:00
Xin Tong
dca508bfbb This is part of a series of commits to remove reference forwarding for
some of the ARC entry points. rdar://22724641. After this commit,
swift_retain_noresult will be completely replaced by swift_retain.
LLVMARCOpts pass is modified NOT to rewrite swift_retain to
swift_retain_noresult which forward no reference.

Swift SVN r32082
2015-09-18 21:56:50 +00:00
Xin Tong
bc3fe169b4 This is part of a series of commits to remove reference forwarding for some of the ARC entry points. rdar://22724641.
After this commit, swift_retain will return no reference and LLVMARCContract pass is modified NOT to rewrite
swift_retain_noresult to old swift_retain which forwarded the reference.

Swift SVN r32075
2015-09-18 20:35:39 +00:00
Michael Gottesman
121ef3ef9f Revert the series of commits for removing the return value from swift_retain_noresult.
I asked that the patches were split up so I could do post commit review.

This reverts commit r32059.
This reverts commit r32058.
This reverts commit r32056.
This reverts commit r32055.

Swift SVN r32060
2015-09-18 02:31:24 +00:00
Xin Tong
4e46dacc3d Completely replace swift_retain_noresult with swift_retain. this is part of a series of commits
to remove reference forwarding for some of the ARC entry points. rdar://22724641. After this
commit, swift_retain_noresult will be completely replaced by swift_retain and LLVMARCOpts.cpp
will no longer canonicalize swift_retain to swift_retain_noresult as now swift_retain returns no
reference.

Swift SVN r32058
2015-09-18 01:51:17 +00:00
Xin Tong
955e4ed652 Change swift_retain/swift_retain_n to return no value. this is part of a series of commits
to remove reference forwarding for some of the ARC entry points. rdar://22724641. After this
commit, swift_retain will be the same as swift_retain_noresult, returning no reference.
LLVMARCContract pass is also modified NOT to rewrite swift_retain_noresult to the
old swift_retain which forwards the reference.

Swift SVN r32055
2015-09-18 00:41:35 +00:00
Michael Gottesman
72f7476ce9 Adjust to upstream changes in the ModRefResult enum
Swift SVN r31799
2015-09-09 04:37:15 +00:00
Michael Gottesman
8e9bc84677 Perform the RRN optimization early/clear when we see an unknown call.
If we have an unknown call, we need to create any retainN calls we
have seen. The reason why is that we do not want to move retains,
releases over isUniquelyReferenced calls. Specifically imagine this:

retain(x); unknown(x); release(x); isUniquelyReferenced(x); retain(x);

In this case we would with this optimization merge the last retain
with the first. This would then create an additional copy. The
release side of this is:

retain(x); unknown(x); release(x); isUniquelyReferenced(x); release(x);

Again in such a case by merging the first release with the second
release, we would be introducing an additional copy.

Thus if we see an unknown call we merge together all retains and
releases before to get some optimization without any loss of
correctness. This could be made more aggressive through appropriate
alias analysis and usage of LLVM's function attributes to determine that
a function does not touch globals.

Swift SVN r30394
2015-07-20 06:34:57 +00:00
Michael Gottesman
0db8d77e4c Refactor LLVMARCContract => LLVMARCContract.cpp.
Swift SVN r30393
2015-07-20 06:34:55 +00:00