77 Commits

Author SHA1 Message Date
swift-ci
367f0082fc Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 22:17:45 -07:00
Anthony Latsis
b04d6085f3 IRGen: Address llvm::InsertPosition ctor deprecation
See https://github.com/llvm/llvm-project/pull/102608.
2025-07-21 12:50:39 +01:00
Anthony Latsis
ed1d70fb3b IRGen: Address llvm::PointerType::get(Unqual) deprecations
See https://github.com/llvm/llvm-project/pull/134517.
2025-07-21 12:37:15 +01:00
Anthony Latsis
08e02af30d LLVMPasses: Remove no longer needed call to removed LLVM method
See https://github.com/llvm/llvm-project/pull/143746.
2025-07-19 02:00:36 +01:00
Anthony Latsis
bb9fb7286e LLVMPasses: Switch from obsoleted llvm::IRHash to llvm::stable_hash
Per 1941c5180b91d792200d5e868d45c96e99bda35e (llvm-project).
2025-04-24 01:52:45 +01:00
Anthony Latsis
0d2d6cb8a0 IRGen, LLVMPasses: Switch from obsoleted APIs to llvm::getPointerAuthStableSipHash
Per d68f8b96b1ff39cfcfcad94d5b16d28adaf6b5d0 (llvm-project).
2025-04-24 01:52:45 +01:00
Xi Ge
736ccef626 Merge remote-tracking branch 'apple/main' into rebranch 2024-06-20 15:16:55 -07: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
Ben Barham
bb9764cd1c [Opt] Make sure to set IsNewDbgInfoFormat when creating functions
This would be done automatically if the module was passed into
`Function::Create`, but we're quite specific about its insert location,
so just set it manually instead.
2024-04-08 08:58:59 -07:00
Ben Barham
2d05569626 [Opt] Move uses of FunctionHash to StructuralHash
These were consolidated in LLVM in 64da0be1fc06ee2199bd27c980736986e0eccd9d.
2024-04-08 08:58:59 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Arnold Schwaighofer
2f94890e5f IRGen: Remove supportsTypedPointers, getNonOpaquePointerElementType, isOpaqueOrPointeeTypeMatches
Typed pointers are no longer supported by llvm.

rdar://121083958
2024-01-17 07:33:30 -08:00
swift-ci
b57534c4db Merge remote-tracking branch 'origin/main' into rebranch 2023-08-16 21:40:49 -07:00
Erik Eckstein
fda5549908 SwiftMergeFunctionsPass: fix a problem with opaque pointers
Need to insert a cast for the return type of a call to a merged function.

Fixes an LLVM verifier crash.

rdar://113901800
2023-08-16 18:19:26 +02:00
Evan Wilde
8ce6ee8dd1 Updating API usages
LLVM deprecated, renamed, and removed a bunch of APIs. This patch
contains a lot of the changes needed to deal with that.

The SetVector type changed the template parameters.

APInt updated multiple names, countPopulation became popcount,
getAllOnesValue became getAllOnes, getNullValue became getZero, etc...

Clang type nullability check stopped taking a clang AST context.

The LLVM IRGen Function type stopped exposing basic block list directly,
but gained enough API surface that the translation isn't too bad.
(GenControl.cpp, LLVMMergeFunctions.cpp)

llvm::Optional had a transform function. That was being used in a couple
of places, so I've added a new implementation under STLExtras that
transforms valid optionals, otherwise it returns nullopt.
2023-07-17 10:53:42 -07:00
Evan Wilde
41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Erik Eckstein
190fea8acc IRGen: getPointerElementType -> getNonOpaquePointerElementType
`getPointerElementType` is deprecated in a newer LLVM.
2022-11-14 20:36:09 +01:00
Arnold Schwaighofer
39194124bb Fix SwiftMergeFunctions pass for opaque pointers
Under opaque pointers there is not need to fix-up byval and structret
attributes.
2022-10-20 11:03:51 -07:00
Arnold Schwaighofer
1cb6b4a82a SwiftMergeFunction: Rewrite the byval/structret attributes when we bitcast the function type
rdar://101089253
2022-10-13 17:07:48 -07:00
Arnold Schwaighofer
5c9eab0f6c Update Swift's LLVM passes to include new pass manager versions 2022-07-15 08:22:32 -07:00
Gabriel Secula
7e298df39f LLVMMergeFunctions: Must not merge function calls to objc_sendMsg$...
It is special.

rdar://91008731
rdar://91087454
2022-03-31 11:11:53 -07:00
Evan Wilde
52c5f1a5f1 Fix build failure in LLVMMergeFunctions
- 3e1c787b3160bed4146d3b2b5f922aeed3caafd7 `arg_operands` was replaced with `args`.
 - 80ea2bb57450a65cc724565ecfc9971ad93a3f15 `get*Attributes` was replaced with `get*Attrs`
2021-10-21 13:40:42 -07:00
Arnold Schwaighofer
cf9ed6e4e0 Disable swift function merging for swift async functions
It breaks withCheckedContinuation.

I have not gotten to the bottom of why. But for now disable the pass for
all async functions until we can fix it.

rdar://77166575
2021-04-29 11:45:52 -07:00
Varun Gandhi
b78e3b8615 Use musttail when merging swifttail calls.
Fixes rdar://75899459.
2021-03-26 16:38:19 -07:00
Arnold Schwaighofer
cd67830685 Update AArch64SubArch_arm64e triple name to match LLVM 2020-12-04 10:16:44 -08:00
Erik Eckstein
e4e5484ab4 LLVM-Passes: add pointer authentication to Swift's function merge pass.
If during merging a function pointer is passed as a parameter to the merged function, it needs to be signed on arm64e.

rdar://problem/66797689
2020-09-23 16:25:17 +02:00
Erik Eckstein
145b8ae35d LLVMMergeFunctions: allow more parameters if the function is bigger
We had a fixed limit of 4 added parameters for merged functions. But if a function is big, it makes sense to allow more parameters to be added.
Now, derived the maximum number of parameters from the function size.

This increases the chances that big functions (which likely require more parameters) are merged.
2020-08-06 19:02:11 +02:00
Michael Forster
1e1aa4635a Inline deprecated CallBase::getCalledValue
This function has already been removed on upstream LLVM. Inlining it
here fixes a compile issue on `master-next`.
2020-04-29 18:04:42 +02:00
Erik Eckstein
e196932f67 Remove includes to llvm's CallSite.h
Fixes a master-next compile problem
2020-04-28 11:58:38 +02:00
Robert Widmann
e2cab420f3 Excise the Global LLVM Context
Add a private scratch context to the ASTContext and allow IntrinsicInfo sole access to it so it can allocate attributes into it. This removes the final dependency on the global context.
2020-04-17 17:48:31 -07:00
Erik Eckstein
f1b4101295 MergeFunctions: use new LLVM API to create a call.
rdar://problem/61734317
2020-04-14 12:28:51 +02:00
Saleem Abdulrasool
71e8f866bb LLVMPasses: mark the dump as debug code
This limits the dumping of the variables to the debug build since
`llvm::Value::dump` is only available in debug builds of LLVM.
2020-02-29 20:47:20 -08:00
Saleem Abdulrasool
2c91da5d88 lib: update for LLVM API change
TerminatorInst has been removed and been made into a regular Instruction.  Use
the `isTerminator` function instead of the dyn_cast.
2019-02-07 17:54:59 -08:00
Vedant Kumar
0db7e4864f [mergefunc] Avoid eliminating dtrace patchpoints (#21305)
Dtrace has special linker support to detect and patch probe call sites.

Each call to a dtrace probe must resolve to a unique patchpoint.

rdar://45738058
2018-12-13 15:57:52 -08:00
Erik Eckstein
bcc13e8060 Fix a miscompile in the swift function merging pass.
In rare corner cases the pass merged two functions which contain incompatible call instructions.
See source comment in the change for details.

rdar://problem/43051718
2018-08-09 14:46:06 -07:00
Bob Wilson
8e330ee344 NFC: Fix indentation around the newly renamed LLVM_DEBUG macro.
Jordan used a sed command to rename DEBUG to LLVM_DEBUG. That caused some
lines to wrap and messed up indentiation for multi-line arguments.
2018-07-21 00:56:18 -07:00
Jordan Rose
cefb0b62ba Replace old DEBUG macro with new LLVM_DEBUG
...using a sed command provided by Vedant:

$ find . -name \*.cpp -print -exec sed -i "" -E "s/ DEBUG\(/ LLVM_DEBUG(/g" {} \;
2018-07-20 14:37:26 -07:00
Sho Ikeda
7e6220c572 [gardening][LLVMPasses] Replace typedef with using 2018-03-28 21:39:12 +09:00
Joe Shajrawi
91d763e5ac Lower the FunctionMergeThreshold from 30 to 15 2017-12-19 11:20:33 -08:00
swift-ci
a9bcdddb77 Merge remote-tracking branch 'origin/master' into master-next 2017-05-24 17:48:35 -07:00
Erik Eckstein
d342041420 Mangling: use ‘Tm’ mangling for merged functions
Previously merged functions just got the name with a “_merged” suffix
2017-05-24 17:00:16 -07:00
Bob Wilson
8d61e93e81 Adapt to LLVM r301812 rename of WeakVH to WeakTrackingVH 2017-05-07 22:25:49 -07:00
Bob Wilson
e917b3cabf Tidy loop iterator to match the MergeFunctions.cpp change from LLVM r273808 2017-05-07 22:23:34 -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
Bob Wilson
c35eed4964 Update SwiftMergeFunctions::replaceDirectCallers to match LLVM r300272 2017-04-16 22:05:15 -07:00
Bob Wilson
bd81b41de4 Update Swift master-next after LLVM API change in r300014.
AttributeSet was added back again, wrapping AttributeSetNode*.
2017-04-13 11:25:22 -07:00