Commit Graph

816 Commits

Author SHA1 Message Date
Pavel Yaskevich
c18edfc632 [Mangling/ABI] NFC: Fix test failures uncovered by CI on i386 (IRGen/stdlib/DebugInfo) 2017-12-18 21:06:54 -08:00
Pavel Yaskevich
600b15821d [Mangling/ABI] NFC: Fix DebugInfo tests to reflect label mangling changes 2017-12-18 15:44:24 -08:00
Adrian Prantl
521de91ba7 Fix the debug info generated by the LoadableByAddress transformation.
And unbreak the LLDB testsuite.

This patch fixes three problems with the original implementation:
- Use SILBuilderWithScope instead of SILBuilder to avoid holes in the
  lexical scopes.
- Use an artificial location for stores to the alloca to avoid the debugger
  stopping before the variable is initialized.
- Recognize debug_value_addr instructions referring to an alloc_stack
  instruction to avoid introducing an extra indirection in the debug info.

rdar://problem/31975108
2017-12-02 16:48:34 -08:00
swift-ci
0d91b89948 Merge pull request #13145 from adrian-prantl/25772716 2017-11-29 11:59:45 -08:00
Adrian Prantl
64425c8525 Remove dead code and an obsolete testcase.
The debug location is now unconditionally being set for each
instruction, so resetting the location at the beginning of each basic
block is redundant.

<rdar://problem/25772716>
2017-11-29 10:02:13 -08:00
Slava Pestov
b74d1b1be8 Add test case that causes IRGen to construct a SIL type with unbound generics in it 2017-11-28 16:04:15 -08:00
Bob Wilson
7d8661a93a Fix test to avoid checking for named IR values
The previous change to the DebugInfo/linetable-cleanups.swift test
introduced FileCheck patterns with references to named IR values. In a
release build, the values are anonymous, so those patterns do not match.
rdar://problem/35639381
2017-11-19 21:29:31 -08:00
Joe Shajrawi
d8289aa3ec Code size: destroy_addr outline 2017-11-17 16:10:27 -08:00
swift-ci
80f0e66a04 Merge pull request #12967 from adrian-prantl/34326355 2017-11-16 13:48:48 -08:00
Adrian Prantl
e574aa765f Don't emit shadow copies for anonymous variables.
Switch statements generate at least one anonymous match variable per
case, which consumes both a lot of stack space and an explosion of
range extension depencies due to the way case statements are scoped.

rdar://problem/34326355
2017-11-16 10:41:40 -08:00
Arnold Schwaighofer
0971d82f70 SILGen: Remaining fixes for @callee_guaranteed closures and enable it
- Fix block to func reabstraction thunks block argument handling
- Forward cast ownership
- Fix applyPartiallyAppliedSuperMethod ownership for @callee_guaranteed closures
- Avoid a copy in buildBlockToFuncThunkBody
- Update tests for callee_guaranteed closures

SR-5441
rdar://33255593
2017-11-15 19:46:08 -08:00
Adrian Prantl
5e36991290 Debug Info / SILGen: fix the source location of variable assignments
by setting the location of the store emitted for a pattern binding
decl to the location of that PBD.

<rdar://problem/35430708>
2017-11-12 10:35:26 -08:00
swift-ci
2996e332b4 Merge pull request #12861 from adrian-prantl/35430708 2017-11-10 16:33:21 -08:00
swift-ci
b14077d6aa Merge pull request #12827 from adrian-prantl/unxfail 2017-11-10 15:22:16 -08:00
Adrian Prantl
b998c103fc Debug Info: Associate a function call with the beginning of the expression.
Before this change, stepping through the code
  1 foo(x,
  2     f(a)
  3     f(b)
  4   )

would visit the code in the order 2, 3, 4, with the function call
being on line 4.  After this patch the order is 2, 3, 1 with the
function call being on line 1. This is both closer to what clang
generates for simialar C code and more useful to the programmer since
it is easier to understand which function is being called in a nested
expression.

rdar://problem/35430708
2017-11-10 14:37:47 -08:00
Michael Gottesman
e74367f2b3 [pred-memopt] Only promote destroy_addr if we know that otherwise the allocation is dead.
Previously, we just always promoted destroy_addr. With ownership, this does not
work as well since we need to be able to reason about the take operation that we
are performing. In the general case, this would require adding code to
pred-memopts for tracking reads and for compensation store code since we would
need to eliminate the store of the taken value to prevent a double use.

I am going to loop back around later in the year and add back this code once the
time is available. I filed SR-6341. In case any third party contributor is
interested in looking at re-enabling this optimization before I get back to it.

rdar://31521023
2017-11-10 13:01:22 -08:00
Adrian Prantl
b3088e2d84 Un-XFAIL and update test. 2017-11-08 17:05:13 -08:00
Slava Pestov
2a0cb060f8 SILGen: Look up the callee method after evaluating arguments 2017-11-08 01:31:55 -08:00
Andrew Trick
d369aa4070 Support @noescape SIL function types. (#12420)
Support for @noescape SILFunctionTypes.

These are the underlying SIL changes necessary to implement the new
closure capture ABI.

Note: This includes a change to function name mangling that
primarily affects reabstraction thunks.

The new ABI will allow stack allocation of non-escaping closures as a
simple optimization.

The new ABI, and the stack allocation optimization, also require
closure context to be @guaranteed. That will be implemented as the
next step.

Many SIL passes pattern match partial_apply sequences. These all
needed to be fixed to handle the convert_function that SILGen now
emits. The conversion is now needed whenever a function declaration,
which has an escaping type, is passed into a @NoEscape argument.

In addition to supporting new SIL patterns, some optimizations like
inlining and SIL combine are now stronger which could perturb some
benchmark results.

These underlying SIL changes should be merged now to avoid conflicting
with other work. Minor benchmark discrepancies can be investigated as part of
the stack-allocation work.

* Add a noescape attribute to SILFunctionType.

And set this attribute correctly when lowering formal function types to SILFunctionTypes based on @escaping.

This will allow stack allocation of closures, and unblock a related ABI change.

* Flip the polarity on @noescape on SILFunctionType and clarify that
we don't default it.

* Emit withoutActuallyEscaping using a convert_function instruction.

It might be better to use a specialized instruction here, but I'll leave that up to Andy.

Andy: And I'll leave that to Arnold who is implementing SIL support for guaranteed ownership of thick function types.

* Fix SILGen and SIL Parsing.

* Fix the LoadableByAddress pass.

* Fix ClosureSpecializer.

* Fix performance inliner constant propagation.

* Fix the PartialApplyCombiner.

* Adjust SILFunctionType for thunks.

* Add mangling for @noescape/@escaping.

* Fix test cases for @noescape attribute, mangling, convert_function, etc.

* Fix exclusivity test cases.

* Fix AccessEnforcement.

* Fix SILCombine of convert_function -> apply.

* Fix ObjC bridging thunks.

* Various MandatoryInlining fixes.

* Fix SILCombine optimizeApplyOfConvertFunction.

* Fix more test cases after merging (again).

* Fix ClosureSpecializer. Hande convert_function cloning.

Be conservative when combining convert_function. Most of our code doesn't know
how to deal with function type mismatches yet.

* Fix MandatoryInlining.

Be conservative with function conversion. The inliner does not yet know how to
cast arguments or convert between throwing forms.

* Fix PartialApplyCombiner.
2017-10-17 13:07:25 -07:00
Adrian Prantl
44aa4822e0 Debug Info: Represent private discriminators in DWARF.
... using an inline namespace as the parent of the outermost
declaration(s) that have private or fileprivate accessability. Once
LLDB supports this we can retire the existing hack of storing it as a
fake command line argument.

rdar://problem/18296829
2017-10-09 15:32:06 -07:00
adrian-prantl
80911b5a59 Merge pull request #11888 from adrian-prantl/dwarfdump
Adapt testcases to upstream changes in llvm-dwarfdump.
2017-09-13 10:19:01 -07:00
Greg Parker
b7f744c302 [test] Replace CPU=i386_or_x86_64 with CPU=i386 || CPU=x86_64. (#11889) 2017-09-12 19:34:08 -07:00
Adrian Prantl
8e309c0570 Adapt testcases to upstream changes in llvm-dwarfdump. 2017-09-12 16:04:06 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
Adrian Prantl
a2d36afda1 Adapt testcase to upstream LLVM changes. 2017-08-24 15:56:48 -07:00
Adrian Prantl
dc24c29bc8 Adapt to upstream LLVM changes in pretty-printing DIExpression. 2017-08-24 08:53:22 -07:00
Adrian Prantl
1b486eda4e Make test more robust. file(1) may not always recognize CPCH as data. 2017-08-21 14:30:15 -07:00
Adrian Prantl
f7742121a5 Debug Info: Record the base name for inout types and fix tests for i386.
rdar://problem/33761763
2017-08-09 15:22:13 -07:00
Adrian Prantl
b5c68bcf1e Disable test on i386 because of the large-types optimization.
rdar://problem/33761763
2017-08-09 15:22:04 -07:00
Arnold Schwaighofer
b57a2dc859 Fix test case test/DebugInfo/dbgvalue-insertpt.swift for unoptimized builds
rdar://33753333
2017-08-07 09:44:03 -07:00
Arnold Schwaighofer
f442dd93bd CompilerInvocation: If no optimization flag is set default to Onone
I noticed in a follow-up patch that if you just swiftc without passing Onone
these flags are not set and sometimes happen to default to right thing ... or
not; as can be seen by the test cases modified. For example, at Onone we are
supposed to include an extra swift module "SwiftOnoneSupport".
2017-08-04 11:49:16 -07:00
swift-ci
d87f99294f Merge remote-tracking branch 'origin/master' into master-next 2017-08-03 13:28:56 -07:00
Joe Shajrawi
84994dc786 Enable large loadable types by default 2017-08-03 11:45:28 -07:00
Bob Wilson
028aaab633 [master-next] Update test to match llvm.dbg.value change
The filecheck pattern in DebugInfo/liverange-extension-vector.swift
was failing because llvm.dbg.value now has two metadata arguments. The
"[[P]]" pattern was matching "%4, metadata !60" instead of only the "%4".
2017-08-01 13:08:52 -07:00
Adrian Prantl
ff0397bdaa Update to upstream llvm changes (remove offset from llvm.dbg.value)
rdar://problem/33580047
2017-07-28 14:16:10 -07:00
Jordan Rose
6e0515f644 [test] Update tests for upstream changes in LLVM/Clang. 2017-07-25 14:46:17 -07:00
adrian-prantl
6c88463f25 Merge pull request #11046 from adrian-prantl/32993231
Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile).
2017-07-18 18:12:15 -07:00
Adrian Prantl
b85f1d679b Update for LLVM IR metadata changes (DIImportedEntity now needs a DIFile).
rdar://problem/32993231
2017-07-18 18:09:55 -07:00
swift-ci
099e540ca7 Merge remote-tracking branch 'origin/master' into master-next 2017-07-14 23:48:49 -07:00
John McCall
80b180a9a1 Implement a syntactic peephole to recognize explicit bridging
conversions that reverse an implicit conversion done to align
foreign declarations with their imported types.

For example, consider an Objective-C method that returns an NSString*:
  - (nonnull NSString*) foo;
This will be imported into Swift as a method returning a String:
  func foo() -> String
A call to this method will implicitly convert the result to String
behind the scenes.  If the user then casts the result back to NSString*,
that would normally be compiled as an additional conversion.  The
compiler cannot simply eliminate the conversion because that is not
necessarily semantically equivalent.

This peephole recognizes as-casts that immediately reverse a bridging
conversion as a special case and gives them special power to eliminate
both conversions.  For example, 'foo() as NSString' will simply return
the original return value.  In addition to call results, this also
applies to call arguments, property accesses, and subscript accesses.
2017-07-15 01:13:41 -04:00
swift-ci
43aa0058ea Merge remote-tracking branch 'origin/master' into master-next 2017-06-04 13:08:36 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
486cab447d tests: replace 'rm -rf %t && mkdir -p %t' with '%empty-directory(%t)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
swift-ci
707eff71a0 Merge remote-tracking branch 'origin/master' into master-next 2017-05-24 15:28:33 -07:00
swift-ci
935535414d Merge pull request #9913 from adrian-prantl/32327266 2017-05-24 15:27:02 -07:00
Adrian Prantl
17496f3012 Simplify IRGenDebugInfo submodule creation and support homonymous submodules. 2017-05-24 14:00:07 -07:00
swift-ci
c7d6a4a348 Merge remote-tracking branch 'origin/master' into master-next 2017-05-24 11:08:35 -07:00
Adrian Prantl
84d9238315 Emit llvm.dbg.declare intrisics immediately after the described alloca.
This cleanup change doesn't change the semantics, but it makes the
resulting IR much easier to read and debug.
2017-05-24 09:13:41 -07:00
swift-ci
1daeac92f5 Merge remote-tracking branch 'origin/master' into master-next 2017-05-23 19:10:58 -07:00
Adrian Prantl
05ada87d46 Emit the code to setup debug shadow copies of variables in the same scope
as the variable is in. If ASAN inserts additional basic blocks to sanitize
the store, it will reuse the location and scope. If the scope is not a
descendant of the scope of the variable an optimization in the live debug
values pass will kill all DEBUG_VALUEs and thus prevent them from being
propagated.

rdar://problem/30433661
2017-05-23 17:11:03 -07:00