Commit Graph

759 Commits

Author SHA1 Message Date
Arnold Schwaighofer
a39c831493 Add llvm:Attribute::Returned to the weak runtime functions
rdar://18172130
2017-09-13 14:10:28 -07:00
Arnold Schwaighofer
034241e440 Revert "Use clang's effective llvm triple for IR generation (#10211)"
This reverts commit 2e3522fafc because debugging
with thumb instructions is broken and being worked on.

rdar://32599805
2017-09-12 13:59:53 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
John McCall
10689a0e3f Add per-method flags to the v-table in class nominal type descriptors.
For now, just store a kind and whether the method was dynamic.
2017-08-26 01:44:10 -04:00
John McCall
9a228e96e1 Change the structure of emitted protocol and generic-wtable metadata:
- Always include an array of requirement descriptors in the protocol
  descriptor.  For now, this doesn't contain anything except a general
  requirement kind and an optional default implementation, but eventually
  this can be augmented with type / name metadata.  This array is always
  emitted as constant.

- Guarantee the value of the extent fields in a protocol descriptor and
  slightly tweak their meaning.

- Move the private-data field out of line in a generic witness table
  descriptor so that the main descriptor can be emitted as constant.

- Rely on IRGen's notion of the witness-table layout instead of assuming
  that SILWitnessTable and SILDefaultWitnessTable match the actual
  physical layout.

This version of the patch uses a hack in which we assign internal rather
than private linkage to certain symbols in order to work around a Darwin
linker bug.
2017-08-25 01:42:44 -04:00
Erik Eckstein
9c6fe76927 SIL, IRGen: add instructions "object" and "global_value” to support statically initialized objects.
This commit contains:
-) adding the new instructions + infrastructure, like parsing, printing, etc.
-) support in IRGen to generate global object-variables (i.e. "heap" objects) which are statically initialized in the data section.
-) IRGen for global_value which lazily initializes the object header and returns a reference to the object.

For details see the documentation of the new instructions in SIL.rst.
2017-08-23 09:15:49 -07:00
Arnold Schwaighofer
b489cde24f Attach LLVM's OptimizeForSize function attribute when compiling under Os 2017-08-17 14:57:22 -07:00
Kuba (Brecka) Mracek
d046f3f959 Set _swift_reportFatalErrorsToDebugger to true by default and remove all the staging parts (frontend flag, irgen changes). (#11329) 2017-08-03 15:23:23 -07:00
Chris Bieneman
9c35042ae6 Merge remote-tracking branch 'origin/master' into master-next 2017-07-28 09:51:36 -07:00
Arnold Schwaighofer
3ba3bf4f6c Remove fixme comment 2017-07-26 15:11:47 -07:00
Arnold Schwaighofer
ee17bab396 IRGen: Enable usage of attributes from RuntimeFunctions.def
* Add some ZExt function attributes on functions returning bool
* swift_dynamicCast is not readonly as it writes to the 'dest' buffer
* Fix tail_alloc.sil test

rdar://20802330
2017-07-26 14:39:28 -07: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
Michael Gottesman
78713ce07f Merge pull request #10519 from jrose-apple/ModuleMacro-master-next
WIP getting master-next up and running with clang::ModuleMacro
2017-06-30 14:52:09 -07:00
swift-ci
8612ba5c3a Merge remote-tracking branch 'origin/master' into master-next 2017-06-30 13:09:12 -07:00
Arnold Schwaighofer
8b2d85fee1 Make a copy of the string before mutation 2017-06-30 11:20:11 -07:00
Arnold Schwaighofer
1e794cdebf IRGen: Sort the target-features string
Function merging will not identify two otherwise equivalent if the order of the target-features list differs.

rdar://33057710
2017-06-30 10:25:53 -07:00
swift-ci
052653d9c7 Merge remote-tracking branch 'origin/master' into master-next 2017-06-29 09:29:03 -07:00
Kuba (Brecka) Mracek
4b88da2a2c Use the debugger hook, reportToDebugger, for all calls to _swift_stdlib_reportFatalError[InFile]. Only do this when a hidden frontend flag, -report-errors-to-debugger, is used. (#10617) 2017-06-29 09:12:26 -07:00
Jordan Rose
90ca8f119a WIP: [IRGen] Update for changes to how autolinking works in LLVM.
The tests still need to be updated.
2017-06-23 12:49:49 -07:00
swift-ci
4d37cd89e4 Merge remote-tracking branch 'origin/master' into master-next 2017-06-13 16:28:44 -07:00
Arnold Schwaighofer
2e3522fafc Use clang's effective llvm triple for IR generation (#10211)
* Use clang's effective llvm triple for IR generation

Instead of using the target that was passed to the driver. Use the target from
the clang importer that might have been changed by clang (i.e armv7 to thumbv7
on darwin)

rdar://32599805

* Address review comments

* Fix test case osx-targets.swift

* Fix pic.swift test case

* Fix test abi_v7k.swift

* Address review comment for test osx-targets.swift
2017-06-13 16:26:14 -07:00
swift-ci
9a1c2f49ca Merge remote-tracking branch 'origin/master' into master-next 2017-06-05 20:08:35 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
swift-ci
27424b37b0 Merge remote-tracking branch 'origin/master' into master-next 2017-05-17 13:08:40 -07:00
Joe Groff
80c6671c39 Runtime: Only complain about a deprecated ObjC entry point once.
We only need to alert the user once. rdar://problem/32229417
2017-05-17 12:05:53 -07:00
Bob Wilson
7bfd58e6f0 Merge pull request #9617 from bob-wilson/comment-out-runtime-attributes
Temporarily comment out code to set runtime function attributes.
2017-05-15 14:08:29 -07:00
swift-ci
dc6e1cf329 Merge remote-tracking branch 'origin/master' into master-next 2017-05-15 12:29:07 -07:00
Bob Wilson
4890a43e8b Temporarily comment out code to set runtime function attributes.
Before my change in e24a6f1d30, the previous code did nothing. I saw the
comment but did not think it really meant what it says. My change
caused the function attributes to be set and that led to all sorts of
mayhem. E.G., I know for sure that the “swift_dynamicCast” entry should
not be ReadOnly because it returns its result by assigning through one
of its arguments. We need to audit the attributes for those runtime
functions before we can turn this on (tracked in rdar://problem/20802330)
2017-05-15 11:54:02 -07:00
Doug Gregor
7955aa13e6 Rename @NSKeyedArchive* attributes.
@NSKeyedArchiveLegacy -> @NSKeyedArchiverClassName
@NSKeyedArchiveSubclassesOnly -> @NSKeyedArchiverEncodeNonGenericSubclassesOnly

Fixes rdar://problem/32178796.
2017-05-15 11:02:31 -07:00
Bob Wilson
45317fc03e Merge branch 'master' into master-next 2017-05-08 23:44:23 -07:00
Erik Eckstein
b1d5c77cec Runtime support for the NSArchiver class attributes.
Register class names for NSKeyedArchiver and NSKeyedUnarchiver based on the @NSKeyedArchiveLegacy and @_staticInitializeObjCMetadata class attributes.

@NSKeyedArchiveLegacy registers a class name translation.
@_staticInitializeObjCMetadata just makes sure that the metadata of a class is instantiated.

This registration code is executed as a static initializer, like a C++ global constructor.
2017-05-08 14:00:03 -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
d435c194ba Merge remote-tracking branch 'origin/master' into master-next 2017-05-04 09:28:57 -07:00
Adrian Prantl
0cb4a2865d Refactor/Cleanup IRGenDebugInfo to use a private implementation (NFC) 2017-05-03 08:34:06 -07:00
Adrian Prantl
c2b14dccd3 Debug info: Represent clang-imported submodules.
Previously an import of a submodule would emit debug info for
importing the root module.

<rdar://problem/17260802>
2017-05-03 08:33:55 -07:00
swift-ci
5ba89103a7 Merge remote-tracking branch 'origin/master' into master-next 2017-04-11 09:28:31 -07:00
Arnold Schwaighofer
b167b4475d Add SIL and IRGen support for a ConstantStringLiteral instruction
This supports a utf8 or utf16 encoding.

rdar://30545013
2017-04-11 08:43:47 -07:00
Bob Wilson
0cb50e1031 Merge remote-tracking branch 'origin/master' into master-next 2017-04-07 16:35:57 -07:00
Huon Wilson
ac0c76be12 [IRGen] Allow constructing UniversalLinkageInfo without an IRGenModule. 2017-04-06 17:31:45 -07:00
Bob Wilson
c6e37c1f0a Merge remote-tracking branch 'origin/master' into master-next 2017-04-05 17:26:52 -07:00
Huon Wilson
3105c6ed00 [IRGen] Expose LinkInfo publicly, like LinkEntity. 2017-04-05 09:54:19 -07:00
Saleem Abdulrasool
15565c116a Adjust for SVN r298393 2017-03-22 07:44:03 -07:00
Saleem Abdulrasool
70771a8975 IRGen: fix construction of ArrayRef
The type deduction may fail due to no explicit conversion to the
ArrayRef data type.  Add explicit casts.  Use the sizeof operator on the
value being constructed rather than the explicit type of the value to
allow the size to be deduced from the value.
2017-03-21 14:59:07 -07:00
Erik Eckstein
a16beaea3c Remove the now usused ConformanceCollector utility.
It was used for dead witness table elimination. But this is done now by lazy emission in IRGen.
Also update DeadFunctionElimination.
NFC.
2017-03-15 10:18:18 -07:00
Erik Eckstein
1e2945d63c IRGen: Consider the conforming type’s accessibility for lazy witness table emission.
...instead of the witness table’s linkage.
The WT linkage is derived from the minimum of the type’s and protocol’s visibility.
So if there is a public type conforming to a private protocol, we might not see the type’s metadata escaping (because it could be in another module).
2017-03-14 17:36:27 -07:00
Erik Eckstein
41c17a5b0c IRGen: emit type metadata and (value) witness tables lazily.
This gives big code size wins for unused types and also for types, which are never used in a generic context.
Also it reduces the amount of symbols in the symbol table.
The size wins heavily depend on the project. I have seen binary size reductions from 0 to 20% on real world projects.

rdar://problem/30119960
2017-03-10 12:50:43 -08:00
Arnold Schwaighofer
80732ead34 Non-witness implementations of init_existential_addr, deinit_existential_addr, open_existential_addr, copy_addr, destory_addr
For the boxed existential variant.
2017-03-09 17:22:35 -08:00
Erik Eckstein
5e80555c9b demangler: put the demangler into a separate library
Previously it was part of swiftBasic.

The demangler library does not depend on llvm (except some header-only utilities like StringRef). Putting it into its own library makes sure that no llvm stuff will be linked into clients which use the demangler library.

This change also contains other refactoring, like moving demangler code into different files. This makes it easier to remove the old demangler from the runtime library when we switch to the new symbol mangling.

Also in this commit: remove some unused API functions from the demangler Context.

fixes rdar://problem/30503344
2017-03-09 13:42:43 -08:00
John McCall
d61d966451 Use ConstantInitBuilder in most kinds of metadata emission.
This is NFC in intent, but I had to restructure the code to emit more
of the lists "inline", which means I inevitably altered some IRGen
emission patterns in ways that are visible to tests:

- GenClass emits property/ivar/whatever descriptors in a somewhat
  different order.

- An ext method type list is now emitted as just an array, not a struct
  containing only that array.

- Protocol descriptors are no longer emitted as packed structs.

I was sorely tempted to stop using packed structs for all the metadata
emission, but didn't really want to update that many tests in one go.
2017-03-06 14:18:47 -05:00