8 Commits

Author SHA1 Message Date
Chirag Ramani
5179bc9609 Add IRPGO and CSIRPGO options to Swift (#84335)
This PR introduces three new instrumentation flags and plumbs them
through to IRGen:

1. `-ir-profile-generate` - enable IR-level instrumentation.
2. `-cs-profile-generate` - enable context-sensitive IR-level
instrumentation.
3. `-ir-profile-use` - IR-level PGO input profdata file to enable
profile-guided optimization (both IRPGO and CSIRPGO)

**Context:**
https://forums.swift.org/t/ir-level-pgo-instrumentation-in-swift/82123

**Swift-driver PR:** https://github.com/swiftlang/swift-driver/pull/1992

**Tests and validation:**
This PR includes ir level verification tests, also checks few edge-cases
when `-ir-profile-use` supplied profile is either missing or is an
invalid IR profile.

However, for argument validation, linking, and generating IR profiles
that can later be consumed by -cs-profile-generate, I’ll need
corresponding swift-driver changes. Those changes are being tracked in
https://github.com/swiftlang/swift-driver/pull/1992
2025-10-09 17:41:47 -07:00
Yuta Saito
e12642f917 [Legacy Driver][wasm] Pass --table-base to reserve low function addresses
WebAssembly does not have a reserved address space by default, so we
need to explicitly reserve low addresses for extra inhabitants for
enum types with pointer payloads. https://github.com/swiftlang/swift/pull/39300
added `--global-base` to reserve low data addresses, but we also need
to reserve low function addresses with `--table-base` for function
pointers because WebAssembly uses a separate address space for function
pointers.
2025-09-15 06:22:20 +00:00
Yuta Saito
6915a36895 [NFC][wasm] Fix incorrect comment about reserved low addresses 2025-09-15 06:21:35 +00:00
Saleem Abdulrasool
ef39af0f55 Driver: support -nostartfiles in the C++ driver
This is required to bootstrap the `-static-stdlib` support for Windows.
With this, we are able to properly build the Swift SDK both dynamically
and statically, which is needed to enable us to make further progress
towards an early swift-driver.
2025-02-07 17:40:26 -08: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
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
Yuta Saito
6fd3ae7812 [Wasm] Specify the least valid pointer for wasm32
WebAssembly doesn't reserve low addresses but without "extra inhabitants" of
the pointer representation, runtime performance and memory footprint are
worse. So assume that compiler driver uses wasm-ld and --global-base=1024 to
reserve low 1KB.
2022-04-03 07:00:32 +00:00
Max Desiatov
710816d3e0 Driver: add support for the Wasm toolchain 2021-09-14 13:02:42 +01:00