Commit Graph

5521 Commits

Author SHA1 Message Date
Doug Gregor
d192bfc7e5 Merge pull request #63125 from DougGregor/debug-info-dump-macro-expansion-buffers 2023-01-21 07:43:45 -08:00
Doug Gregor
456fbf84f5 [Debug info] Dump macro expansion buffers to disk for debug info to reference
When emitting debug info that references into a macro expansion, dump
the macro expansion buffer into a file on disk (in the temporary
directory) so that one can see the macro expansion buffers in the
source files themselves.

The test here validates that the generated LLVM IR looks correct, but
I'm having a problem getting LLDB to actually locate the source code
correctly.
2023-01-19 21:30:25 -08:00
John McCall
374c202b99 Add SIL instructions to generate pack indices 2023-01-19 23:57:22 -05:00
John McCall
595d923bd1 Fix doc comment on OpenPackElementInst to match the committed design 2023-01-19 23:57:13 -05:00
John McCall
7825d177a9 [NFC] Introduce NullaryInstructionWithTypeDependentOperandsBase
We have a similar helper class for the unary-but-for case, might
as well have one for the nullary-but-for case.
2023-01-19 23:57:13 -05:00
Erik Eckstein
d96ef3bedd Swift SIL: add some APIs to Location
* `var description`
* `func ==`
* `func hasSameSourceLocation(as:)`
2023-01-16 19:00:09 +01:00
Erik Eckstein
3f457eb1d4 Swift SIL: add IntegerLiteralInst.value 2023-01-16 19:00:09 +01:00
Erik Eckstein
221a16ba17 Swift SIL: add more arguments to Builder.createApply
add the `isNonThrowing` and `isNonAsync` flags and the `specializationInfo`
2023-01-16 19:00:09 +01:00
Erik Eckstein
cf8c68c6c4 Swift SIL: add Type.hasArchetype 2023-01-16 19:00:09 +01:00
Erik Eckstein
230c93df30 SIL Optimizer: add some SIL modification APIs
* `MutatingContext.notifyInvalidatedStackNesting` and `MutatingContext.needFixStackNesting`
* `MutatingContext.tryDeleteDeadClosure`
* `MutatingContext.erase(block:)`
* `Undef.get`
* `BasicBlock.moveAllInstructions`
* `BasicBlock.eraseAllArguments`
* `BasicBlock.moveAllArguments`
* `TermInst.replaceBranchTarget`
2023-01-16 19:00:09 +01:00
Erik Eckstein
edce513580 SIL: simplify replaceBranchTarget
Instead of re-creating all kind of terminator instructions, just re-assign the terminator's successor.
2023-01-16 18:55:35 +01:00
Erik Eckstein
0523dbee9d SILBitFields: don't set bitfields of deleted nodes 2023-01-16 16:16:51 +01:00
Andrew Trick
7dc9405131 Add a visited set for PrunedLiveness guaranteed value. 2023-01-13 14:16:15 -08:00
Andrew Trick
599b1d1ae4 Handle guaranteed phis conservatively in a few more places. 2023-01-13 08:55:16 -08:00
Andrew Trick
5279ac1f34 Document PrunedLiveness to explain guaranteed phis liveness.
In a sense, liveness is wrong for dead guaranteed phis that aren't
enclosed in a separate borrow scope:

     left:           // live-within
       br merge(%v)
     right:          // live-within
       br merge(%v)
     merge(%deadPhi) // dead

But this is the way that liveness layering works. PrunedLiveness
simply doesn't know which phis will "end" liveness. This will be the
job of OwnershipLiveness, which will have safe APIs for situations
where this weirdness matters.
2023-01-13 08:55:16 -08:00
John McCall
37baf9b2dc Add a SIL instruction to open a pack as an element archetype
IRGen not yet done.
2023-01-11 03:11:30 -05:00
John McCall
d673a45c88 More opened-existential vs. local-archetype fixes in SIL 2023-01-11 03:11:30 -05:00
Michael Gottesman
b405782727 Revert change to a comment. 2023-01-09 11:25:51 -08:00
Michael Gottesman
193348694f Merge pull request #62916 from gottesmm/pruned-liveness-boundary
[move-only-addr] Finish field sensitive pruned liveness boundary and use it in the move only address checker.
2023-01-09 08:02:19 -08:00
nate-chandler
fb01580e41 Merge pull request #62873 from nate-chandler/bug/20230105/1
[SSADestroyHoisting] Don't fold over trivial use.
2023-01-09 07:05:22 -08:00
Michael Gottesman
1c459b6c5b [move-only-addr] Wire up the move only address checker to Field Sensitive Pruned Liveness Boundary.
This let me fix an issue around hoisting destroy_addr/store [assign] when
working in multi-block cfgs.

I also added some .sil tests.
2023-01-08 21:51:40 -08:00
Michael Gottesman
0e7b04acf3 [field-pruned-liveness] Add two helper constructors to TypeTreeLeafTypeRange.
The first is a default constructor that initializes both startEltOffset and
endEltOffset to 0. This is used to ensure that we can use certain standard
algorithms that expect to be able to perform a default constructor when
inserting an initial value into a collection.

The second adds the ability to construct a TypeTreeLeafTypeRange for a
SILType/SILFunction if one has a type without an actual value.
2023-01-08 14:54:48 -08:00
Michael Gottesman
c2adaa9b75 [field-pruned-liveness] Add helper for TypeSubElementCount that takes a SILFunction.
This just calls TypeSubElementCount(SILType, SILModule &, TypeExpansionContext)
using the module and type expansion context from the SILFunction.
2023-01-08 14:53:04 -08:00
Michael Gottesman
c16e0cfac8 [sil] Implement helper function SILType::getFieldType(VarDecl *, SILFunction *) const.
This just calls:

```
SILType::getFieldType(VarDecl *, SILModule &, TypeExpansionContext) const
```

using the state in the SILFunction to handle the SILModule and
TypeExpansionContext parameters.

Just trimming down a larger commit into smaller commits.
2023-01-08 14:03:52 -08:00
Michael Gottesman
e6b63fbf3d [pruned-liveness] Change markBlockLive to call the scalar implementation for each bit rather than attempt to do it for all bits at the same time. 2023-01-07 14:29:48 -08:00
Michael Gottesman
82abf02883 [pruned-liveness] Change the internal machinery of updateForUse to use only scalar logic.
I did this by doing the following:

1. I renamed computeUseBlockLiveness to computeScalarUseBlockLiveness and
changed it to take a specific bit that it is testing for.

2. I changed the logic that already existed in this code path that worked scalar
by scalar to use scalar logic rather than call the broken multi-bit at a time
code path.

3. We took advantage of resultingFoundLiveness now only returning the requested
bits instead of all bits. This ensures that we do not run
computeScalarUseBlockLiveness for those unneeded dead bits resulting in liveness
being inappropriately propagated into predecessors.
2023-01-07 14:28:41 -08:00
Michael Gottesman
be50c56f55 [pruned-liveness] Specialize scalar pruned liveness routines
Just a small cleanup that will improve performance in the scalar case which is
important for OSSA utilities.
2023-01-07 14:14:59 -08:00
Michael Gottesman
2637c0b637 [pruned-liveness] Change PrunedLiveBlocks::getLiveness(...) to return only one entry per live bit.
Previously, we would pan the array with isDead. The thinking is that this would
make it easier to bitmask directly against. In practice, this usage was a minor
use case and doing this lead to a bunch of logic mistakes in forthcoming code.
2023-01-07 14:14:59 -08:00
Nate Chandler
b3f033759e [MemAccessUtils] Added PathNode::isPrefixOf.
It's just a passthrough to the same method on IndexTrieNode.
2023-01-05 15:05:38 -08:00
Pavel Yaskevich
449acae01f Merge pull request #62813 from xedin/expand-sildeclref-kind-by-one-bit
[SILDeclRef] Expand `kind` by one bit because `RuntimeAttributeGenera…
2023-01-04 09:48:40 -08:00
eeckstein
bc2bb5bf7a Merge pull request #62771 from eeckstein/debug-info
Some small debug-info fixes
2023-01-04 11:24:39 +01:00
Pavel Yaskevich
733e51f6ad [SILDeclRef] Expand kind by one bit because RuntimeAttributeGenerator is 16th entry 2023-01-03 11:00:21 -08:00
Andrew Trick
0a9484597f Add findEnclosingDefs and findBorrowIntroducers utilities.
These APIs are essential for complete OSSA liveness analysis.  The
existing ad-hoc OSSA logic always misses some of the cases handled by
these new utilities. We need to start replacing that ad-hoc logic with
new utilities built on top of these APIs to define away potential
latent bugs.

Add FIXMEs to the inverse API: visitAdjacentBorrowsOfPhi. It should
probably be redesigned in terms of these new APIs.
2023-01-03 09:33:39 -08:00
Andrew Trick
c2ae7e0359 Add visitForwardedGuaranteedOperands utility.
Factors a mess of code in MemAccessUtils to handle forwarding
instruction types into a simpler utility. This utility is also needed
for ownership APIs, which need to be extended to handle these cases.
2023-01-03 09:33:39 -08:00
Andrew Trick
6e12fff564 80-col formatting 2023-01-03 09:33:39 -08:00
Erik Eckstein
6711c907d9 SILBuilder: add an assertion in getInsertionPointLoc() 2023-01-02 13:37:31 +01:00
Allan Shortlidge
2e8857d867 IRGen: Add #_hasSymbol support for clang function decls and ObjC classes.
Resolves rdar://103408651.
2022-12-22 10:55:30 -05:00
Meghana Gupta
4cf6f79938 Merge pull request #62714 from meg-gupta/fixassert
Create begin_borrow in OSSA only
2022-12-20 21:49:55 -08:00
Meghana Gupta
18fd845732 Create begin_borrow in OSSA only
Fixes rdar://103512260

Creating begin_borrow in non-ossa can raise asserts or reach unreachable in some utils.
2022-12-20 14:37:37 -08:00
Pavel Yaskevich
b83b0943b5 [SILDeclRef] RuntimeMetadata: Add a special kind for runtime attribute generator
A new `RuntimeAttributeGenerator` is used to reference runtime
attribute generator functions synthesized by SILGen.
`#function` magic literal points to the declaration that declaration
attribute is attached to.
2022-12-20 09:45:01 -08:00
Pavel Yaskevich
3fb69b3c3c [SIL] SILFunction: Add runtime accessible function attribute
This attribute indicates that the given SILFunction has to be
added to "accessible functions" section and could be looked up
at runtime using a special API.
2022-12-20 09:33:44 -08:00
Pavel Yaskevich
84c2ff6445 [SILDeclRef] Make it possible to identify references to runtime accessible entities
`asRuntimeAccessible` is going to be coupled with a flag on `SILFunction`
and would allow IRGen to emit such functions into a special section.
2022-12-20 09:33:44 -08:00
Andrew Trick
02f7450759 At -Onone preserve debug info after splitting loads
Load splitting converts an aggregate load into a set of subobject
loads. This is required at -Onone for exclusivity diagnostics.

We cannot preserve the original debug information by redirecting debug
info to the memory address, because that might result in incorrect
debug values if the memory is reused.

Before this fix, we "conservatively" drop debug info in those
cases. This fix preserves full debug info by keeping the original
aggregate load intact alongside the new subobject loads. To avoid
exclusivity violations, it create a new unsafe access scope for the
old load.

Fixes LLDB missing variables in certain case #62241
2022-12-19 00:02:18 -08:00
Meghana Gupta
6ee4c17abe Merge pull request #62573 from meg-gupta/sbiverify
Update store_borrow checking in MemoryLifetimeVerifier and fix ForEachLoopUnroll and GenericCloner
2022-12-15 09:53:00 -08:00
Michael Gottesman
6fff307328 Merge pull request #62592 from gottesmm/pr-cbfd912fd4d58ff272d3f1fe4ceb8cf02589da9a
[sil] Add a new attribute called @closureCaptured to SILFunctionArguments that are closure capture arguments.
2022-12-15 01:14:46 -08:00
John McCall
6d4588c40b Change SIL to track all LocalArchetypes and not just OpenedArchetypes. 2022-12-14 19:43:23 -05:00
Michael Gottesman
9e44011e4d [sil] Add a new attribute called @closureCaptured to SILFunctionArguments that are closure capture arguments.
I am adding this to make it easy to determine if a SILFunction that is not inout
aliasable is captured. This is useful when emitting certain types of
diagnostics like I need to emit with move only.
2022-12-14 15:16:43 -08:00
Meghana Gupta
b79a383386 Delete unused/vague apis 2022-12-14 02:11:19 -08:00
swift-ci
6d0a3257a3 Merge pull request #62454 from meg-gupta/guaranteedforwardingphiverify
Update guaranteed forwarding phi apis and verification
2022-12-13 20:04:00 -08:00
Meghana Gupta
511739b494 Delete OperandOwnership::GuaranteedForwardingPhi
Use OperandOwnership::GuaranteedForwarding instead.
2022-12-13 12:51:31 -08:00