Commit Graph

644 Commits

Author SHA1 Message Date
John McCall
1f3f33e67d Clean up the internal APIs around dynamic allocas to structurally
discourage accidental use of them.  Relatedly, fix several bugs
where we were accidentally using dynamic allocas.
2017-12-19 00:29:43 -05:00
Arnold Schwaighofer
ac0db46f79 Fix for linux 2017-12-14 10:22:34 -08:00
Arnold Schwaighofer
bfb8f15e43 Fix test case failure 2017-12-14 08:17:19 -08:00
Arnold Schwaighofer
066a627ca0 Reapply "IRGen: The partial application forwarder needs to cast { swift.refcounted* } to swift.refcounted* for AnyObject types on linux"
With fix and test case for failed case.

This reverts commit d14cd40916.

SR-6547
rdar://problem/35911150
2017-12-14 06:41:30 -08:00
Doug Gregor
d14cd40916 Revert "IRGen: The partial application forwarder needs to cast { swift.refcounted* } to swift.refcounted* for AnyObject types on linux" 2017-12-13 22:49:13 -08:00
Arnold Schwaighofer
8610670d0e IRGen: The partial application forwarder needs to cast { swift.refcounted* } to swift.refcounted* for AnyObject types on linux
SR-6547
2017-12-13 14:31:44 -08:00
Joe Shajrawi
d8289aa3ec Code size: destroy_addr outline 2017-11-17 16:10:27 -08:00
Joe Shajrawi
62d823c56d Code size: Do not use a global state for isOutlined 2017-11-15 15:28:27 -08:00
Zac Bowling
4d2877f83e [IRGen] fix const inferred return type in lambda 2017-08-15 20:00:53 -04:00
John McCall
ec80b4f72b Avoid doing an aggregate store to initialize the block header.
NFC except for IR patterns.
2017-08-09 23:22:36 -04:00
John McCall
c2e352c0ce Clean up IRGen's handling of function pointers for partial_apply.
NFC except for cast placement.
2017-08-09 00:04:42 -04:00
John McCall
d4d2145ad8 Merge branch 'master' into master-next 2017-07-29 15:48:00 -04:00
John McCall
a0f20f673d Switch all of the indirect-call code in IRGen to FunctionPointer.
To make this stick, I've disallowed direct use of that overload of
CreateCall.  I've left the Constant overloads available, but eventually
we might want to consider fixing those, too, just to get all of this
code out of the business of manually remembering to pass around
attributes and calling conventions.

The test changes reflect the fact that we weren't really setting
attributes consistently at all, in this case on value witnesses.
2017-07-28 23:26:35 -04:00
swift-ci
3ba52033f4 Merge remote-tracking branch 'origin/master' into master-next 2017-07-26 05:48:56 -07:00
Arnold Schwaighofer
a15eff356a IRGen: Fix partial applies of generic functions capturing the generic parameters in an argument
The code assumed if there is no context object but rather the captured argument
is reused as the context object that the parameter index for this argument is
going to be the last one. This is not true if there are empty types in the
parameter list.

rdar://33502272
2017-07-25 12:49:53 -07:00
Bob Wilson
5f02db4d3e Merge remote-tracking branch 'origin/master' into master-next 2017-07-20 21:59:23 -07:00
John McCall
750d397909 Substantially rework how IRGen handles function pointers.
The goals here are four-fold:
  - provide cleaner internal abstractions
  - avoid IR bloat from extra bitcasts
  - avoid recomputing function-type lowering information
  - allow more information to be propagated from the function
    access site (e.g. class_method) to the call site

Use this framework immediately for class and protocol methods.
2017-07-20 14:33:18 -04:00
swift-ci
e98182387b Merge remote-tracking branch 'origin/master' into master-next 2017-07-11 12:23:35 -07:00
Joe Groff
101788dbd4 IRGen: Support for computed properties with dependent generic context.
Use the KeyPath implementation's new support for instantiating and dealing with captures to lower the generic context required to dispatch computed accessors with dependent generics.
2017-07-06 20:07:41 -07:00
swift-ci
096075de56 Merge remote-tracking branch 'origin/master' into master-next 2017-05-24 14:48:34 -07:00
Arnold Schwaighofer
d8f6c8e57e IRGen: Bind metatypes from captured or regular arguments in partial apply
forwarding thunks

We omit passing some metatype parameters if they can be reconstructed from
regular arguments. However, the partial apply forwarder so far did not
reconstructing them from such arguments.

SR-4854
rdar://32134723
2017-05-24 11:36:11 -07:00
Bob Wilson
e24a6f1d30 Adjust addAttributes calls for LLVM r301981
These now take an AttrBuilder argument instead of an AttributeList.
2017-05-06 21:37:22 -07:00
swift-ci
502bda365b Merge remote-tracking branch 'origin/master' into master-next 2017-05-05 13:48:34 -07:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
swift-ci
1378be1c6d Merge remote-tracking branch 'origin/master' into master-next 2017-05-01 15:55:31 -07:00
Joe Shajrawi
d17258cac7 @in_constant calling convention - part of passing large loadable types by address 2017-04-30 10:13:02 -07:00
swift-ci
4ef7b46971 Merge remote-tracking branch 'origin/master' into master-next 2017-04-21 18:08:32 -07:00
Joe Groff
595e0e4ede Merge branch 'master' into keypaths 2017-04-19 18:38:24 -07:00
Joe Groff
25eaa09463 wip irgen generic/computed key paths 2017-04-17 11:34:31 -07:00
swift-ci
b91640b044 Merge remote-tracking branch 'origin/master' into master-next 2017-04-10 08:08:43 -07:00
Arnold Schwaighofer
09246d3718 IRGen: Fix partial_apply of arguments that lower to empty values
We would run into an assertion during building the partial apply forwarding
thunk because we passed down a parameter convention of an empty argument
although we ignore it for the purpose of adding to the closure context.
However, the code path for the non-allocated closure context (0 or one capture)
would assert that there is only one convention.

Reconcile this by not adding the empty parameter to the convention array.

rdar://31487947
2017-04-08 08:17:30 -07:00
swift-ci
01b79011fe Merge remote-tracking branch 'origin/master' into master-next 2017-03-29 06:48:52 -07:00
practicalswift
91bc2d2993 [gardening] Remove comparison to false 2017-03-28 21:40:06 +02:00
Saleem Abdulrasool
15565c116a Adjust for SVN r298393 2017-03-22 07:44:03 -07:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
Arnold Schwaighofer
ecb8b15261 IRGen: Fix partial_apply of instantiated generic return values
We might have to reabstract the return type.

SR-4253
2017-03-17 13:30:53 -07:00
John McCall
ec667cae55 Adopt ConstantInitBuilder in a few places. 2017-03-06 14:18:47 -05:00
Slava Pestov
0611d663b8 SIL: Remove SILType::getSwiftType() 2017-02-27 20:01:35 -08:00
Mikio Takeuchi
488d531846 Enhance -assume-single-threaded option (SR-3945) 2017-02-27 12:17:53 +09:00
Slava Pestov
18550b171d IRGen: witness_method function values no longer carry witness table
This was an unnecessary complication and didn't make a lot of
logical sense, because we can recover the witness table from
substitutions when we call a @convention(witness_method) anyway.

Also, to fix materializeForSet for generic subscripts, I want the
materializeForSet *callback* of a protocol witness to have
@convention(witness_method), which requires representing such
functions as a single function pointer in IRGen.
2017-02-25 16:42:51 -08:00
Arnold Schwaighofer
fecec3cc07 Silence warning of disabled code
SR-4041
2017-02-22 17:21:25 -08:00
Slava Pestov
6e2f1f356b IRGen: Fix crash when emitting partial apply of concrete witness_method
The hasPolymorphicParameters() method always returns true for a
SILFunctionType with witness_method calling convention, because
we have to pass the type metadata for 'Self'.

However, it is possible for a witness_method to have no generic
signature, if we're directly calling a concrete witness method
thunk, as can happen after devirtualization.

In this case, we would crash if the witness_method was partially
applied. Handle this case.

This fixes a regression from the recent cleanup to have IRGen use
SubstitutionMap: <https://github.com/apple/swift/pull/7211>
2017-02-16 17:59:03 -08:00
Arnold Schwaighofer
39fa2f0228 Use the swift calling convention for swift functions
Use the generic type lowering algorithm described in
"docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion
type to the type expected by the ABI.

Change IRGen to use the swift calling convention (swiftcc) for native swift
functions.

Use the 'swiftself' attribute on self parameters and for closures contexts.

Use the 'swifterror' parameter for swift error parameters.

Change functions in the runtime that are called as native swift functions to use
the swift calling convention.

rdar://19978563
2017-02-14 12:17:57 -08:00
Hugh Bellamy
cb3bdcc2a3 Merge pull request #7408 from hughbe/llvm-fallthrough
Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH
2017-02-13 17:39:59 +07:00
Slava Pestov
5296d02485 AST: More include-what-you-use gardening 2017-02-12 00:51:26 -08:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Slava Pestov
3519e0cd25 AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
SubstitutionList is going to be a more compact representation of
a SubstitutionMap, suitable for inline allocation inside another
object.

For now, it's just a typedef for ArrayRef<Substitution>.
2017-02-06 21:36:33 -08:00
Slava Pestov
c90a77df31 IRGen: Use SubstitutionMap instead of ArrayRef<Substitution> in a few places
The crazy indexing logic is gone.
2017-02-03 19:55:41 -08:00
Andrew Trick
1abeddcc5d [SILType] SILFunctionConventions API.
Separate formal lowered types from SIL types.
The SIL type of an argument will depend on the SIL module's conventions.
The module conventions are determined by the SIL stage and LangOpts.

Almost NFC, but specialized manglings are broken incidentally as a result of
fixes to the way passes handle book-keeping of aruments. The mangler is fixed in
the subsequent commit.

Otherwise, NFC is intended, but quite possible do to rewriting the logic in many
places.
2017-01-26 15:35:48 -08:00
Han Sangjin
b8dd577693 [swiftc] Fixed for Cygwin
Fixed for the difference of Cygwin with other Windows variants (MSVC,
Itanium, MinGW).

- The platform name is renamed to "cygwin" from "windows" which is used
  for searching the standard libraries.

- The consideration for DLL storage class (DllExport/DllImport) is not
  required for Cygwin and MinGW. There is no problem when linking in
  these environment.

- Cygwin should use large memory model as default.(This may be changed
  if someone ports to 32bit)

- Cygwin and MinGW should use the autolink feature in the sameway of
  Linux due to the linker's limit.
2017-01-19 05:48:24 +09:00