Nate Chandler
9825b26e3a
[Test] Underscored simplify_cfg_simplify_argument.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
2878b053ec
[Test] Underscored simplify_cfg_simplify_block_args.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
dd19acdf68
[Test] Underscored simplify_cfg_canonicalize_switch_enum.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
4329512fb0
[Test] Underscored simplify_cfg_simplify_term_with_identical_dest_blocks.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
b0bb97467f
[Test] Underscored simplify_cfg_simplify_switch_enum_block.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:17 -07:00
Nate Chandler
c0d95c121b
[Test] Underscored simplify_cfg_simplify_switch_enum_on_objc_class_optional.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:50:14 -07:00
Nate Chandler
7470c29cfe
[Test] Underscored simplify_cfg_simplify_switch_enum_unreachable_blocks.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:48:22 -07:00
Nate Chandler
8d3a5a17d9
[Test] Underscored simplify_cfg_try_jump_threading.
...
Use underscores rather than hyphens so that text editors understand the
name as a single word.
2024-07-25 13:47:45 -07:00
Erik Eckstein
3e750f9f1c
SimplifyCFG: Fix a missing borrowed-from when doing jump threading
...
Fixes a compiler crash
rdar://129805179
2024-07-03 13:52:52 +02:00
Tim Kientzle
1d961ba22d
Add #include "swift/Basic/Assertions.h" to a lot of source files
...
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Slava Pestov
a1462ef184
SIL: Promote removeDeadBlock() from SILOptimizer to a method on SILBasicBlock
2024-05-21 13:52:58 -04:00
Erik Eckstein
e14c1d1f62
SIL, Optimizer: update and handle borrowed-from instructions
...
Compute, update and handle borrowed-from instruction in various utilities and passes.
Also, used borrowed-from to simplify `gatherBorrowIntroducers` and `gatherEnclosingValues`.
Replace those utilities by `Value.getBorrowIntroducers` and `Value.getEnclosingValues`, which return a lazily computed Sequence of borrowed/enclosing values.
2024-04-10 13:38:10 +02:00
Meghana Gupta
5bfa560b35
Update SimplifyCFG's replacement of phi with its incoming value
...
Previously we replaced phi with its incoming values when all incoming values were the same.
If the phi had itself as incoming value, it wasn't optimized. This PR handles such cases.
2024-04-03 10:46:05 -07:00
Michael Gottesman
11f0ff6e32
[sil] Ensure that all SILValues have a parent function by making it so that SILUndef is uniqued at the function instead of module level.
...
For years, optimizer engineers have been hitting a common bug caused by passes
assuming all SILValues have a parent function only to be surprised by SILUndef.
Generally we see SILUndef not that often so we see this come up later in
testing. This patch eliminates that problem by making SILUndef uniqued at the
function level instead of the module level. This ensures that it makes sense for
SILUndef to have a parent function, eliminating this possibility since we can
define an API to get its parent function.
rdar://123484595
2024-02-27 13:14:47 -08:00
Ben Barham
ef8825bfe6
Migrate llvm::Optional to std::optional
...
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Meghana Gupta
79c8f5da2d
Handle ossa instructions in SimplifyCFG
...
This can in turn trigger try_apply -> apply [nothrow] transformation.
2024-01-05 13:20:52 -08:00
Erik Eckstein
3ba935605e
SimplifyCFG: fix try_apply -> apply transformation for indirect error results
...
Indirect error results must not be included in the final apply arguments which they are not present in the callee.
2023-11-27 08:51:12 +01:00
Slava Pestov
05ccd9734c
SIL: Introduce ThrowAddrInst
2023-10-31 16:58:54 -04:00
Tony Allevato
5f5b24f96e
[C++20] Make operator{==,!=}s const.
...
In C++20, the compiler will synthesize a version of the operator
with its arguments reversed to ease commutativity. This reversed
version is ambiguous with the hand-written operator when the
argument is const but `this` isn't.
2023-10-03 17:10:57 -04:00
Meghana Gupta
9311e948a5
Avoid unnecessary block arguments in SimplifyCFG::threadEdge and SimplifyCFG::simplifyThreadedTerminators
2023-08-17 10:33:22 -07:00
Meghana Gupta
bbd6a87e2b
Fix simplifyArguments for a few edges cases in OSSA
2023-08-16 23:14:36 -07:00
Meghana Gupta
93d6f93435
Fixes to SimplifyCFG::threadEdge for OSSA
2023-08-14 11:36:05 -07:00
Meghana Gupta
05c7d64511
We don't consider it profitable to jump thread when we could optimize arc in OSSA.
...
Copy propagation should be able to handle such cases without jump threading.
2023-08-14 11:36:04 -07:00
Meghana Gupta
e3a98e88f3
Add new flags to enable specific SimplifyCFG operations
2023-08-14 11:36:04 -07:00
Meghana Gupta
a303bb4519
Disable SimplifyCFG::tailDuplicateObjCMethodCallSuccessorBlocks in OSSA
...
Support for this needs to be added
2023-08-14 11:36:04 -07:00
Meghana Gupta
bf68e3ff39
Disable ArgumentSplitter for non trivial types in ossa
2023-08-14 11:36:04 -07:00
Evan Wilde
83b044f5fb
Migrating LLVM API usage on main
...
This patch migrates the compiler off of the deprecated LLVM APIs where I
can.
- APInt::getAllOnesValue -> APInt::getAllOnes
- APInt::getNullValue -> APInt::getZero
- APInt::isNullValue -> APInt::isZero
- APInt::getMinSignedBits -> APInt::getSignificantBits
- clang::Module::submodule_{begin,end} -> clang::Module::submodules
2023-07-13 11:22:35 -07:00
Nate Chandler
b9b286eff2
[Test] Ensourced simplify-cfg-try-jump-threading.
...
Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
f1d61afdfb
[Test] Ensourced simplify-cfg-simplify....
...
-term-with-identical-dest-blocks. Moved the test next to the code it
calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
736b1afb4d
[Test] Ensourced simplify-cfg-simplify-switch....
...
-enum-unreachable-blocks. Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
d57b1e5fee
[Test] Ensourced simplify-cfg-simplify-switch....
...
-enum-on-objc-class-optional. Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
49bc5a66d4
[Test] Ensourced simplify-cfg-simplify-switch....
...
-enum-block. Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
bf229c357e
[Test] Ensourced simplify-cfg-canonicalize....
...
-switch-enum. Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
df02726e7b
[Test] Ensourced simplify-cfg-simplify-block-args.
...
Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Nate Chandler
bc909e5b28
[Test] Ensourced simplify-cfg-simplify-argument.
...
Moved the test next to the code it calls.
2023-07-04 11:52:13 -07:00
Meghana Gupta
16c300c2af
Remove OwnershipForwardingConversionInst, ConversionInst.
...
Add new ConversionOperation abstraction, use this in place of ConversionInst
2023-06-15 10:53:28 -07:00
Meghana Gupta
5d401fb70a
Remove select_value SIL instruction
2023-06-13 14:13:43 -07:00
Meghana Gupta
1dc713e2f7
Add new flags "reborrow" and "escaping" to SILArgument.
...
"reborrow" flag on the SILArgument avoids transitive walk over the phi operandsi
to determine if it is a reborrow in multiple utilities.
SIL transforms must keep the flag up-to-date by calling SILArgument::setReborrow.
SILVerifier checks to ensure the flag is not invalidated.
Currently "escaping" is not used anywhere.
2023-05-11 12:31:37 -07: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
Meghana Gupta
dac6c0303f
Add tests for simple jump threading
2023-01-08 00:15:17 -08:00
Meghana Gupta
5d2967ca75
Fix SimplifyCFG::simplifySwitchEnumOnObjcClassOptional for OSSA
2023-01-08 00:15:17 -08:00
Meghana Gupta
cdbd0f4743
Fix SimplifyCFG::simplifyArgs for OSSA
2023-01-08 00:15:12 -08:00
Meghana Gupta
3660a1e6a9
Remove borrow scope adjustment for @guaranteed phi args
2023-01-06 23:50:07 -08:00
Meghana Gupta
900d8c3f63
Add ossa unit tests for SimplifyCFG::simplifyTermWithIdenticalDestBlocks
2023-01-06 23:50:07 -08:00
Meghana Gupta
73cd7a9dc1
Add ossa unit tests for SimplifyCFG::simplifySwitchEnumUnreachableBlocks
2023-01-06 23:50:07 -08:00
Meghana Gupta
1fc0d0aba1
SimplifyCFG: Modify DestBB before replacing branch target
2023-01-06 23:50:07 -08:00
Meghana Gupta
94f8841374
Fix SimplifyCFG::simplifySwitchEnumBlock for OSSA
2023-01-06 23:50:07 -08:00
Meghana Gupta
ff4ab7de11
Enable SimplifyCFG::canonicalizeSwitchEnums and add unit tests
2022-10-21 23:08:43 -07:00
Meghana Gupta
97013100dc
[NFC] Move SimplifyCFG class to its own header so that it can be accessed by the unit test infra
2022-10-21 16:48:28 -07:00
Erik Eckstein
ecbcacdecf
SIL Analysis: Rename InvalidationKind::FunctionData to InvalidationKind::Effects
...
This invalidation kind is used when a compute-effects pass changes function effects.
Also, let optimization passes which don't change effects only invalidate the `FunctionBody` and not `Everything`.
2022-10-20 09:20:28 +02:00